k8s集群部署es

集群内创建需要用到存储,此处举例使用腾讯云cfs共享存储

内存limits限制不需要加,否则会经常内存溢出导致es集群故障

yaml 复制代码
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: es7-cluster
  namespace: elasticsearch
spec:
  serviceName: es-cluster
  replicas: 3
  selector:
    matchLabels:
      app: es-cluster
  template:
    metadata:
      labels:
        app: es-cluster
    spec:
      containers:
      - name: es-cluster
        image: elasticsearch:7.16.2
        resources:
            limits:
              cpu: 2
            requests:
              cpu: 2
        ports:
        - containerPort: 9200
          name: rest
          protocol: TCP
        - containerPort: 9300
          name: inter-node
          protocol: TCP
        volumeMounts:
        - name: data
          mountPath: /usr/share/elasticsearch/data
        env:
          - name: cluster.name
            value: k8s-logs
          - name: node.name
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: discovery.zen.minimum_master_nodes
            value: "2"
          - name: discovery.seed_hosts
            value: "es7-cluster-0.es-cluster,es7-cluster-1.es-cluster,es7-cluster-2.es-cluster"
          - name: cluster.initial_master_nodes
            value: "es7-cluster-0,es7-cluster-1,es7-cluster-2"
          - name: ES_JAVA_OPTS
            value: "-Xms4g -Xmx4g"
      initContainers:
      - name: fix-permissions
        image: busybox
        command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
        securityContext:
          privileged: true
        volumeMounts:
        - name: data
          mountPath: /usr/share/elasticsearch/data
      - name: increase-vm-max-map
        image: busybox
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      - name: increase-fd-ulimit
        image: busybox
        command: ["sh", "-c", "ulimit -n 65536"]
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "cfs"
      resources:
        requests:
          storage: 100Gi
---
apiVersion: v1
kind: Service
metadata:
  name: es-cluster
  namespace: elasticsearch
spec:
  selector:
    app: es-cluster
  type: NodePort
  ports:
  - port: 9200
    targetPort: 9200
相关推荐
yunson_Liu2 小时前
jenkins更新了gitlab后出现报错
运维·gitlab·jenkins
荣光波比2 小时前
K8S(一)—— 云原生与Kubernetes(K8S)从入门到实践:基础概念与操作全解析
云原生·容器·kubernetes
problc2 小时前
PostgreSQL + Redis + Elasticsearch 实时同步方案实践:从触发器到高性能搜索
redis·elasticsearch·postgresql
Elastic 中国社区官方博客2 小时前
如何减少 Elasticsearch 集群中的分片数量
大数据·数据库·elasticsearch·搜索引擎·全文检索
顧棟2 小时前
【ES实战】ES6.8到9.1.4的常用客户端变化
elasticsearch
知识浅谈3 小时前
Elasticsearch 核心知识点全景解读
大数据·elasticsearch·搜索引擎
hello_2503 小时前
k8s基础监控promql
云原生·容器·kubernetes
Komorebi_99994 小时前
Git 常用命令完整指南
大数据·git·elasticsearch
还是鼠鼠5 小时前
《黑马商城》Elasticsearch基础-详细介绍【简单易懂注释版】
java·spring boot·spring·elasticsearch·搜索引擎·spring cloud·全文检索
静谧之心5 小时前
在 K8s 上可靠运行 PD 分离推理:RBG 的设计与实现
云原生·容器·golang·kubernetes·开源·pd分离