帮我写一个k8s部署es集群的yaml
时间: 2023-03-14 09:08:02 浏览: 114
非常乐意为你提供以下Kubernetes YAML文件,用于部署Elasticsearch集群:apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch
spec:
selector:
matchLabels:
app: elasticsearch
serviceName: elasticsearch
replicas: 3
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
ports:
- containerPort: 9200
name: es-http
- containerPort: 9300
name: es-tcp
env:
- name: cluster.name
value: "my-es-cluster"
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: discovery.seed_hosts
value: "elasticsearch-0.elasticsearch,elasticsearch-1.elasticsearch,elasticsearch-2.elasticsearch"
- name: cluster.initial_master_nodes
value: "elasticsearch-0,elasticsearch-1,elasticsearch-2"
- name: ES_JAVA_OPTS
value: "-Xms512m -Xmx512m"
volumeMounts:
- name: datadir
mountPath: /usr/share/elasticsearch/data
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 8Gi
阅读全文