k8s中部署elasticsearch6.3.2

使用官方镜像,解决部署中遇到的vm.max_map_count值问题

使用yml配置,如下

使用初始化镜像busybox,执行sysctl命令

  1. apiVersion: apps/v1beta1
    kind: Deployment
    metadata:
      name: base-elasticsearch6-deployment
    spec:
      replicas: 1 # tells deployment to run 2 pods matching the template
      template: # create pods using pod definition in this template
        metadata:
          labels:
            name: base-elasticsearch6
        spec:
          initContainers:
          - name: init-sysctl
            image: busybox:1.27.2
            command:
            - sysctl
            - -w
            - vm.max_map_count=262144
            securityContext:
              privileged: true
          containers: 
          - name: web-base-elasticsearch6
            image: 你的镜像名称
            #image: elasticsearch:2.4.2
            imagePullPolicy: IfNotPresent
            resources:
              # need more cpu upon initialization, therefore burstable class
              limits:
                cpu: 1000m
              requests:
                cpu: 100m
            env: 
            - name: ES_JAVA_OPTS
              value: -Xms512m -Xmx512m
            ports: 
            - containerPort: 9200
            - containerPort: 9300
            volumeMounts:
            - name: elasticsearch
              mountPath: /mnt/search
          nodeSelector:
            elasticsearch: "base"    
          volumes:
          - name: elasticsearch
            hostPath:
              path: /mnt/search/student
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: base-elasticsearch6
      labels:
        name: base-elasticsearch6
    spec:
      type: NodePort
      ports:
      - name:  web-9200
        port: 9200
        targetPort: 9200
        protocol: TCP
      - name:  web-9300
        port: 9300
        targetPort: 9300
        protocol: TCP
      selector:
        name: base-elasticsearch6
  1.  

猜你喜欢

转载自www.cnblogs.com/leomy/p/10171121.html