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
相关推荐
全栈陈序员4 小时前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
weirong6 小时前
给 Operator 加 Admission Webhook 踩的 4 个坑(其中 3 个本可以不踩)
kubernetes
Goboy7 小时前
夯爆了,我被一个一句话接入的免费可观测平台策反了,那一刻我决定放弃用了3年的Prometheus
后端·docker·kubernetes
吴声子夜歌8 小时前
Kubernetes权威指南——深入掌握Service(一)
云原生·容器·kubernetes
Percep_gan9 小时前
Linux中安装gitea,很详细
linux·elasticsearch·gitea
木棉软糖1 天前
5 步确认 TiDB 历史抽数的 Logstash 有没有真的写进 ES
elasticsearch·oracle·tidb
weirong1 天前
图解 client-go Informer:手写一个 mini-Informer 才敢说懂
kubernetes
.冰块.1 天前
流量大了自动加 Pod!K8s HPA 扩缩容与 ResourceQuota/LimitRange 资源管控实战
linux·云原生·容器·kubernetes·hpa·quota·limitrange
全栈陈序员1 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
Elasticsearch1 天前
Elasticsearch:稠密向量字段类型
elasticsearch