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
相关推荐
.柒宇.8 小时前
ELK日志分析系统实战指南:Elasticsearch搭建与入门(8.18.8版本)
运维·elk·elasticsearch·logback·日志系统
Linux-187419 小时前
分布式链路追踪系统之二进制安装skywalking
elasticsearch·云原生·skywalking·分布式链路追踪系统·应用程序性能监控
阿里云大数据AI技术1 天前
阿里云 Elasticsearch 日志采集与加工服务:让日志链路少一串组件,多一份稳定
人工智能·elasticsearch
heimeiyingwang1 天前
【架构实战】可观测性三支柱:日志、指标、链路的融合
elasticsearch·架构·kubernetes
Elasticsearch1 天前
Elastic Observability 中的 Prometheus 指标:你的 PromQL 可以保持不变地运行
elasticsearch
Elasticsearch1 天前
为什么 Elasticsearch 平台是你的 AI 技术栈中缺失的一块拼图
elasticsearch
Elasticsearch1 天前
数据平台赌注:为什么金融 AI 计划停滞,以及成功者如何扩展规模
elasticsearch
Elasticsearch1 天前
在金融服务领域扩展 AI 从治理和架构开始
elasticsearch
CodexDave1 天前
数据库连接池耗尽:排查顺序与三层兜底
服务器·前端·数据库·git·云原生·容器·kubernetes
weixin_307779131 天前
Linux下Jenkins数据故障的系统化排查Shell脚本
linux·运维·服务器·jenkins