在 Kubernetes 中,如何为 Elasticsearch Cluster 分配专用的 Node 节点?

在 Kubernetes 中,如何为 Elasticsearch Cluster 分配专用的 Node 节点?

1. 对应的Node打上相应的污点和标签:

1
2
3
4
5
6
7
kubectl taint node node03 baas.yonghui.cn/elasticsearch-cluster=true:NoSchedule
kubectl taint node node04 baas.yonghui.cn/elasticsearch-cluster=true:NoSchedule
kubectl taint node node05 baas.yonghui.cn/elasticsearch-cluster=true:NoSchedule

kubectl label node node03 baas.yonghui.cn/elasticsearch-cluster=true
kubectl label node node04 baas.yonghui.cn/elasticsearch-cluster=true
kubectl label node node05 baas.yonghui.cn/elasticsearch-cluster=true

2. 部署 Elasticsearch Cluster 到 Kubernetes 中的专用节点上:

1
2
3
4
5
6
7
cd backend/elasticsearch/deploy/kubernetes-elasticsearch-cluster/stateful/
kubectl create -f ../es-discovery-svc.yaml
kubectl create -f ../es-svc.yaml
kubectl create -f ../es-master.yaml
kubectl create -f ../es-ingest-svc.yaml
kubectl create -f ../es-ingest.yaml
kubectl create -f es-data-stateful.yaml


重要提示:


(1) Elasticsearch Pod 需要 init-container 以特权模式运行,因此它可以设置一些VM选项。为此,应该使用 args –allow-privileged运行kubelet,否则 init-container 将无法运行。


(2) 默认情况下,ES_JAVA_OPTS设置为-Xms256m -Xmx256m。这是一个非常低的价值,但许多用户,即minikube用户,由于主机内存不足而导致pod被杀的问题。可以在此存储库中可用的部署描述符中更改此设置。


(3) 目前,Kubernetes pod描述符使用emptyDir在每个数据节点容器中存储数据。这是为了简单起见,应根据一个人的存储需求进行调整。


(4) 有状态目录包含一个将数据窗体部署为StatefulSet的示例。这些使用volumeClaimTemplates为每个pod配置持久存储。


(5) 默认情况下,PROCESSORS 设置为1.对于某些部署,这可能是不够的,尤其是在启动时。如果需要,相应地调整 resources.limits.cpu 或 livenessProbe。请注意,resources.limits.cpu 必须是整数。

3. 从 Kubernetes 中的专用节点上清理 Elasticsearch Cluster :

1
2
3
4
5
6
7
cd backend/elasticsearch/deploy/kubernetes-elasticsearch-cluster/stateful/
kubectl delete -f ../es-discovery-svc.yaml
kubectl delete -f ../es-svc.yaml
kubectl delete -f ../es-master.yaml
kubectl delete -f ../es-ingest-svc.yaml
kubectl delete -f ../es-ingest.yaml
kubectl delete -f es-data-stateful.yaml

4. 对应的Node去掉相应的污点和标签:

1
2
3
4
5
6
7
kubectl taint node node03 baas.yonghui.cn/elasticsearch-cluster-
kubectl taint node node04 baas.yonghui.cn/elasticsearch-cluster-
kubectl taint node node05 baas.yonghui.cn/elasticsearch-cluster-

kubectl label node node03 baas.yonghui.cn/elasticsearch-cluster-
kubectl label node node04 baas.yonghui.cn/elasticsearch-cluster-
kubectl label node node05 baas.yonghui.cn/elasticsearch-cluster-

参考资料


https://cloud.tencent.com/info/21f27eb131873f979d6275f085dfabdc.html