
helm部署etcd集群
1.安装
集群参考:https://www.jianshu.com/p/a7738b016aaa 单机:https://www.jianshu.com/p/4ae90ff08d61
2.验证
笔记: etcd可通过集群内以下DNS名称上的端口2379访问: etcd.test-gxc.svc.cluster.local 要创建可用作etcd客户端的pod,请运行以下命令: kubectl run etcd-client --restart='Never' --image marketplace.azurecr.io/bitnami/etcd:3.5.0-debian-10-r0 --env ROOT_PASSWORD=$(kubectl get secret --namespace test-gxc etcd -o jsonpath="{.data.etcd-root-password}" | base64 --decode) --env ETCDCTL_ENDPOINTS="etcd.test-gxc.svc.cluster.local:2379" --namespace test-gxc --command -- sleep infinity 然后,您可以使用以下命令设置/获取密钥: kubectl exec -it etcd-client -- bash etcdctl --user root:$ROOT_PASSWORD put /message Hello etcdctl --user root:$ROOT_PASSWORD get /message 要从集群外部连接到etcd服务器,请执行以下命令: kubectl port-forward --namespace test-gxc svc/etcd 2379:2379 & echo "etcd URL: http://127.0.0.1:2379" *由于启用了rbac,您应该在etcdctl命令中添加标志“--user root:$ETCD\u root\u PASSWORD”。使用以下命令导出密码: export ETCD_ROOT_PASSWORD=$(kubectl get secret --namespace test-gxc etcd -o jsonpath="{.data.etcd-root-password}" | base64 --decode)NOTES: ** 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.test-gxc.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 marketplace.azurecr.io/bitnami/etcd:3.5.0-debian-10-r0 --env ROOT_PASSWORD=$(kubectl get secret --namespace test-gxc etcd -o jsonpath="{.data.etcd-root-password}" | base64 --decode) --env ETCDCTL_ENDPOINTS="etcd.test-gxc.svc.cluster.local:2379" --namespace test-gxc --command -- sleep infinity Then, you can set/get a key using the commands below: kubectl exec -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 test-gxc 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 test-gxc etcd -o jsonpath="{.data.etcd-root-password}" | base64 --decode)