helm一键安装etcd集群
·
1、导入集群的KUBE_CONFIG
export KUBECONFIG=/root/.kube/config.yaml
# 1️⃣ 添加 Bitnami 仓库(如果没添加过)
helm repo add bitnami https://charts.bitnami.com/bitnami
# 2️⃣ 更新仓库索引
helm repo update
# 3️⃣ 拉取 etcd Chart(不安装)
helm pull bitnami/etcd --untar
helm install etcd-cluster bitnami/etcd -n etcd --set persistence.enabled=true --set persistence.size=20Gi --set persistence.storageClass=alicloud-disk-essd --set image.registry=registry-intl.cn-hongkong.aliyuncs.com --set image.repository=bitnami/etcd --set image.tag=latest --set global.security.allowInsecureImages=true
Error: INSTALLATION FAILED: execution error at (etcd/templates/NOTES.txt:124:4):
⚠ ERROR: Original containers have been substituted for unrecognized ones. Deploying this chart with non-standard containers is likely to cause degraded security and performance, broken chart features, and missing environment variables.
Unrecognized images:
- registry-intl.cn-hongkong.aliyuncs.com/bitnami/etcd:latest
If you are sure you want to proceed with non-standard containers, you can skip container image verification by setting the global parameter 'global.security.allowInsecureImages' to true.
Further information can be obtained at https://github.com/bitnami/charts/issues/30850
helm install etcd-cluster bitnami/etcd -n etcd 、
--set persistence.enabled=true \
--set persistence.size=20Gi \
--set persistence.storageClass=alicloud-disk-essd \
--set image.registry=registry-intl.cn-hongkong.aliyuncs.com \
--set image.repository=bitnami/etcd --set image.tag=latest \
--set global.security.allowInsecureImages=true
I1021 18:13:51.634148 1409393 warnings.go:110] "Warning: spec.SessionAffinity is ignored for headless services"
NAME: etcd-cluster
LAST DEPLOYED: Tue Oct 21 18:13:41 2025
NAMESPACE: etcd
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: etcd
CHART VERSION: 12.0.18
APP VERSION: 3.6.4
⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
Subscribe to Bitnami Secure Images to receive continued support and security updates.
More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267
** Please be patient while the chart is being deployed **
etcd can be accessed via port 2379 on the following DNS name from within your cluster:
etcd-cluster.etcd.svc.cluster.local
To create a pod that you can use as a etcd client run the following command:
kubectl run etcd-cluster-client --restart='Never' --image registry-intl-vpc.cn-hongkong.aliyuncs.com/bkpre/etcd:latest --env ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d) --env ETCDCTL_ENDPOINTS="etcd-cluster.etcd.svc.cluster.local:2379" --namespace etcd --command -- sleep infinity
Then, you can set/get a key using the commands below:
kubectl exec --namespace etcd -it etcd-cluster-client -- bash
etcdctl --user root:$ROOT_PASSWORD put /message Hello
etcdctl --user root:$ROOT_PASSWORD get /message
To connect to your etcd server from outside the cluster execute the following commands:
kubectl port-forward --namespace etcd svc/etcd-cluster 2379:2379 &
echo "etcd URL: http://127.0.0.1:2379"
* As rbac is enabled you should add the flag `--user root:$ETCD_ROOT_PASSWORD` to the etcdctl commands. Use the command below to export the password:
export ETCD_ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d)
WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
- resources
- preUpgradeJob.resources
- disasterRecovery.cronjob.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
⚠ SECURITY WARNING: Original containers have been substituted. This Helm chart was designed, tested, and validated on multiple platforms using a specific set of Bitnami and Tanzu Application Catalog containers. Substituting other containers is likely to cause degraded security and performance, broken chart features, and missing environment variables.
Substituted images detected:
- registry-intl-vpc.cn-hongkong.aliyuncs.com/bkpre/etcd:latest
⚠ SECURITY WARNING: Verifying original container images was skipped. Please note this Helm chart was designed, tested, and validated on multiple platforms using a specific set of Bitnami and Bitnami Secure Images containers. Substituting other containers is likely to cause degraded security and performance, broken chart features, and missing environment variables.
2、加载helm仓库
不持久化存储方式
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm install etcd-cluster bitnami/etcd -n middleware --create-namespace --set persistence.enabled=false
持久化
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
3、部署集群
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm install etcd-cluster bitnami/etcd -n middleware --create-namespace
I1021 16:05:45.170434 1361117 warnings.go:110] "Warning: spec.SessionAffinity is ignored for headless services"
NAME: etcd-cluster
LAST DEPLOYED: Tue Oct 21 16:05:37 2025
NAMESPACE: middleware
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: etcd
CHART VERSION: 12.0.18
APP VERSION: 3.6.4
⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
Subscribe to Bitnami Secure Images to receive continued support and security updates.
More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267
** Please be patient while the chart is being deployed **
etcd can be accessed via port 2379 on the following DNS name from within your cluster:
etcd-cluster.middleware.svc.cluster.local
To create a pod that you can use as a etcd client run the following command:
kubectl run etcd-cluster-client --restart='Never' --image docker.io/bitnami/etcd:3.6.4-debian-12-r3 --env ROOT_PASSWORD=$(kubectl get secret --namespace middleware etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d) --env ETCDCTL_ENDPOINTS="etcd-cluster.middleware.svc.cluster.local:2379" --namespace middleware --command -- sleep infinity
Then, you can set/get a key using the commands below:
kubectl exec --namespace middleware -it etcd-cluster-client -- bash
etcdctl --user root:$ROOT_PASSWORD put /message Hello
etcdctl --user root:$ROOT_PASSWORD get /message
To connect to your etcd server from outside the cluster execute the following commands:
kubectl port-forward --namespace middleware svc/etcd-cluster 2379:2379 &
echo "etcd URL: http://127.0.0.1:2379"
* As rbac is enabled you should add the flag `--user root:$ETCD_ROOT_PASSWORD` to the etcdctl commands. Use the command below to export the password:
export ETCD_ROOT_PASSWORD=$(kubectl get secret --namespace middleware etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d)
WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
- resources
- preUpgradeJob.resources
- disasterRecovery.cronjob.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
创建阿里云的ebs存储卷
[root@iZj6c38wprvmf777rslz4vZ ~]# kubectl get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
alicloud-disk-efficiency diskplugin.csi.alibabacloud.com Delete Immediate true 6h28m
alicloud-disk-essd diskplugin.csi.alibabacloud.com Delete Immediate true 6h28m
alicloud-disk-ssd diskplugin.csi.alibabacloud.com Delete Immediate true 6h28m
alicloud-disk-topology-alltype diskplugin.csi.alibabacloud.com Delete WaitForFirstConsumer true 6h28m
| 环境类型 | 推荐 StorageClass | 说明 |
|---|---|---|
| 开发 / 测试 | alicloud-disk-efficiency | 成本低,性能足够 |
| 生产(普通负载) | alicloud-disk-ssd | 性价比高 |
| 生产(高性能) | alicloud-disk-essd | 高 IOPS / 低延迟 |
| 跨可用区集群 | alicloud-disk-topology-alltype | 自动根据调度选择磁盘类型 |
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm install etcd bitnami/etcd \
> -n etcd --create-namespace \
> --set persistence.enabled=true \
> --set persistence.storageClass=alicloud-disk-topology-alltype \
> --set persistence.size=20Gi
I1021 17:34:27.174687 1394365 warnings.go:110] "Warning: spec.SessionAffinity is ignored for headless services"
NAME: etcd
LAST DEPLOYED: Tue Oct 21 17:34:22 2025
NAMESPACE: etcd
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: etcd
CHART VERSION: 12.0.18
APP VERSION: 3.6.4
⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
Subscribe to Bitnami Secure Images to receive continued support and security updates.
More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267
** Please be patient while the chart is being deployed **
etcd can be accessed via port 2379 on the following DNS name from within your cluster:
etcd.etcd.svc.cluster.local
To create a pod that you can use as a etcd client run the following command:
kubectl run etcd-client --restart='Never' --image docker.io/bitnami/etcd:3.6.4-debian-12-r3 --env ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd -o jsonpath="{.data.etcd-root-password}" | base64 -d) --env ETCDCTL_ENDPOINTS="etcd.etcd.svc.cluster.local:2379" --namespace etcd --command -- sleep infinity
Then, you can set/get a key using the commands below:
kubectl exec --namespace etcd -it etcd-client -- bash
etcdctl --user root:$ROOT_PASSWORD put /message Hello
etcdctl --user root:$ROOT_PASSWORD get /message
To connect to your etcd server from outside the cluster execute the following commands:
kubectl port-forward --namespace etcd svc/etcd 2379:2379 &
echo "etcd URL: http://127.0.0.1:2379"
* As rbac is enabled you should add the flag `--user root:$ETCD_ROOT_PASSWORD` to the etcdctl commands. Use the command below to export the password:
export ETCD_ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd -o jsonpath="{.data.etcd-root-password}" | base64 -d)
WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
- resources
- preUpgradeJob.resources
- disasterRecovery.cronjob.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
也可以写到values.yaml中
persistence:
enabled: true
storageClass: alicloud-disk-essd # 选择阿里云 ESSD 云盘
accessModes:
- ReadWriteOnce
size: 20Gi
helm install etcd bitnami/etcd -f values.yaml -n etcd --create-namespace
4、查询部署的集群
[root@iZj6c38wprvmf777rslz4vZ ~]# kubectl get pods -n etcd
NAME READY STATUS RESTARTS AGE
etcd-0 1/1 Running 0 2m50s
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm list -n middleware
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
etcd-cluster middleware 1 2025-10-21 16:05:37.232334639 +0800 CST deployed etcd-12.0.18 3.6.4
单节点
helm install etcd bitnami/etcd -n etcd \
--set persistence.enabled=true \
--set persistence.size=20Gi \
--set persistence.storageClass=alicloud-disk-essd \
--set image.repository=registry.cn-hangzhou.aliyuncs.com/bitnami/etcd \
--set image.tag=latest
集群
helm install etcd bitnami/etcd -n etcd-cluster \
--set persistence.enabled=true \
--set persistence.size=20Gi \
--set persistence.storageClass=alicloud-disk-essd \
--set image.repository=registry.cn-hangzhou.aliyuncs.com/bitnami/etcd \
--set image.tag=latest
root@iZj6c6780ikh136bm70qpoZ:~/linux-amd64# helm install etcd-cluster bitnami/etcd -n etcd --set persistence.enabled=true --set persistence.size=20Gi --set persistence.storageClass=alicloud-disk-essd
I1021 18:01:17.832535 1404602 warnings.go:110] "Warning: spec.SessionAffinity is ignored for headless services"
NAME: etcd-cluster
LAST DEPLOYED: Tue Oct 21 18:01:12 2025
NAMESPACE: etcd
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: etcd
CHART VERSION: 12.0.18
APP VERSION: 3.6.4
⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
Subscribe to Bitnami Secure Images to receive continued support and security updates.
More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267
** Please be patient while the chart is being deployed **
etcd can be accessed via port 2379 on the following DNS name from within your cluster:
etcd-cluster.etcd.svc.cluster.local
To create a pod that you can use as a etcd client run the following command:
kubectl run etcd-cluster-client --restart='Never' --image docker.io/bitnami/etcd:3.6.4-debian-12-r3 --env ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d) --env ETCDCTL_ENDPOINTS="etcd-cluster.etcd.svc.cluster.local:2379" --namespace etcd --command -- sleep infinity
Then, you can set/get a key using the commands below:
kubectl exec --namespace etcd -it etcd-cluster-client -- bash
etcdctl --user root:$ROOT_PASSWORD put /message Hello
etcdctl --user root:$ROOT_PASSWORD get /message
To connect to your etcd server from outside the cluster execute the following commands:
kubectl port-forward --namespace etcd svc/etcd-cluster 2379:2379 &
echo "etcd URL: http://127.0.0.1:2379"
* As rbac is enabled you should add the flag `--user root:$ETCD_ROOT_PASSWORD` to the etcdctl commands. Use the command below to export the password:
export ETCD_ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd-cluster -o jsonpath="{.data.etcd-root-password}" | base64 -d)
WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
- resources
- preUpgradeJob.resources
- disasterRecovery.cronjob.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
更多推荐
所有评论(0)