参考:
k8s安装elasticsearch集群
k8s安装elasticsearch集群_k8s部署elasticsearch集群_MasonYyp的博客-CSDN博客1 环境简述搭建es集群需要使用的技术如下:k8s集群、StatefulSet控制器、Service(NodePort)服务、PV、PVC、volumeClaimTemplates(存储卷申请模板)。StatefulSet控制器创建的Pod适合用于分布式存储系统,它最大的特点是各个Pod的数据不一样,各个Pod无法使用同一个存储卷。注意StatefulSet会给所有的Pod从0开始编号,编号的规则是${statuefulset名称}-${序号}。如果StatefulSet的Pod被误删除,State_k8s部署elasticsearch集群https://blog.csdn.net/make_progress/article/details/124638272
参考2
云原生 | K8S集群部署es集群+kibana
云原生 | K8S集群部署es集群+kibana_Theshy!的博客-CSDN博客K8S集群部署es集群+kibanahttps://blog.csdn.net/m0_70331483/article/details/130098234
参考3文章来源:https://www.toymoban.com/news/detail-701800.html
vim es.yamlapiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: elasticsearch-pdb
spec:
selector:
matchLabels:
app: elasticsearch
maxUnavailable: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch
spec:
serviceName: elasticsearch-hs
replicas: 3
selector:
matchLabels:
app: elasticsearch
updateStrategy:
type: RollingUpdate
podManagementPolicy: Parallel
template:
metadata:
labels:
app: elasticsearch
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- elasticsearch
topologyKey: "kubernetes.io/hostname"
containers:
- name: elasticsearch
image: harbor.kp.com/keepwork/elasticsearch:7.5.0
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 0.01
memory: 2Gi
ports:
- containerPort: 9200
name: rest
protocol: TCP
- containerPort: 9300
name: inter-node
protocol: TCP
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
- name: plugins
mountPath: /usr/share/elasticsearch/plugins
env:
- name: cluster.name
value: k8s-logs
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: discovery.zen.ping.unicast.hosts
value: "elasticsearch-0.elasticsearch-hs,elasticsearch-1.elasticsearch-hs,elasticsearch-2.elasticsearch-hs"
- name: discovery.zen.minimum_master_nodes
value: "2"
- name: cluster.initial_master_nodes #此参数es7以上才能设置
value: elasticsearch-0,elasticsearch-1
- name: ES_JAVA_OPTS
value: "-Xms1536m -Xmx1536m"
- name: TZ
value: "Asia/Shanghai"
initContainers:
- name: fix-permissions-data
image: registry.cn-hangzhou.aliyuncs.com/caosx-public/busybox:1.28.3
command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
securityContext:
privileged: true
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
- name: fix-permissions-plugins
image: registry.cn-hangzhou.aliyuncs.com/caosx-public/busybox:1.28.3
command: ["sh", "-c", "rm -fr /usr/share/elasticsearch/plugins/lost+found && chown -R 1000:1000 /usr/share/elasticsearch/plugins"]
securityContext:
privileged: true
volumeMounts:
- name: plugins
mountPath: /usr/share/elasticsearch/plugins
- name: increase-vm-max-map
image: registry.cn-hangzhou.aliyuncs.com/caosx-public/busybox:1.28.3
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
- name: increase-fd-ulimit
image: registry.cn-hangzhou.aliyuncs.com/caosx-public/busybox:1.28.3
command: ["sh", "-c", "ulimit -n 65536"]
securityContext:
privileged: true
volumeClaimTemplates:
- metadata:
name: data
labels:
app: elasticsearch
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: local
resources:
requests:
storage: 20Gi
- metadata:
name: plugins
labels:
app: elasticsearch
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: local
resources:
requests:
storage: 200Mi
---
kind: Service
apiVersion: v1
metadata:
name: elasticsearch-hs
labels:
app: elasticsearch
spec:
selector:
app: elasticsearch
clusterIP: None
ports:
- port: 9300
targetPort: 9300
---
kind: Service
apiVersion: v1
metadata:
name: elasticsearch-cs
labels:
app: elasticsearch
spec:
selector:
app: elasticsearch
ports:
- port: 9200
targetPort: 9200
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: elasticsearch-ingress
spec:
rules:
- host: elasticsearch.gdcattsoft2.com
http:
paths:
- path: /
backend:
serviceName: elasticsearch-cs
servicePort: 9200
文章来源地址https://www.toymoban.com/news/detail-701800.html
到了这里,关于磐基2.0搭建es集群 k8s安装elasticsearch集群的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!