k8s部署ElasticSearch

k8s部署ElasticSearch

apiVersion: v1
kind: ConfigMap
metadata:
  name: es-7
  namespace: pie-engine-infra
data:
  elasticsearch.yml: |
    node.name: master
    cluster.initial_master_nodes: ["master"]
    network.host: 0.0.0.0
    path.data: /data
    http.cors.enabled: true
    http.cors.allow-origin: "*"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: elasticsearch7-single
  namespace: pie-engine-infra
spec:
  replicas: 1
  selector:
    matchLabels:
      name: elasticsearch7
  template:
    metadata:
      labels:
        name: elasticsearch7
    spec:
      initContainers:
      - name: init-sysctl
        image: busybox:stable
        imagePullPolicy: IfNotPresent
        command:
        - sysctl
        - -w
        - vm.max_map_count=655360
        securityContext:
          privileged: true
      containers:
      - name: elasticsearch
        image: infra/elasticsearch:7.5.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9200
        - containerPort: 9300
        volumeMounts:
        - name: es-data
          mountPath: /data
        - name: es-plugins
          mountPath: /usr/share/elasticsearch/plugins
        - name: es-conf
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
          subPath: elasticsearch.yml
      volumes:
      - name: es-data
        hostPath:
          path: /data/resource/middleware/es7/data
      - name: es-plugins
        hostPath:
          path: /home/software/elasticsearch/k8s-es/plugins
      - name: es-conf
        configMap:
            name: es-7
---
apiVersion: v1
kind: Service
metadata:
  name: elasticsearch7-single
  namespace: pie-engine-infra
  labels:
    name: elasticsearch7
spec:
  type: NodePort
  ports:
  - port: 9200
    targetPort: 9200
    nodePort: 30920
    name: elasticsearch7-single1
  - port: 9300
    targetPort: 9300
    nodePort: 30930
    name: elasticsearch7-single2
  selector:
    name: elasticsearch7

注意:数据挂载的目录要给权限 chomd 777 挂载目录


版权声明:本文为weixin_47284857原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。