找一台可以上公网的服务器,参照官方文下载chart包
# helm repo add bitnami-aks https://marketplace.azurecr.io/helm/v1/repo
# helm pull bitnami-aks/etcd --version 6.2.9
可见chart包已经下载到当前目录
# ll
-rw-r--r-- 1 root root 34334 7月 19 14:34 etcd-6.2.10.tgzgz
将chart拷贝到要目标服务器上即可。
离线安装需要提前准备如下镜像:
docker.io/bitnami/etcd:3.4.15-debian-10-r33
docker.io/bitnami/bitnami-shell:10-debian-10-r134
私有镜像镜像名如下:
harbocto.xxx.com.cn/bitnami/etcd:3.4.15-debian-10-r33
harbocto.xxx.com.cn/bitnami/bitnami-shell:10-debian-10-r134
进入解压缩后生成的etcd目录
image:
registry: harbocto.xxx.com.cn
repository: bitnami/etcd
tag: 3.5.0-debian-10-r24
下边许可证没有启用,所以其实不修改也可以
volumePermissions:
enabled: false
image:
registry: harbocto.xxx.com.cn
repository: bitnami/bitnami-shell
tag: 10-debian-10-r134
pullPolicy: Always
auth:
rbac:
……
rootPassword: "Boe888888"
replicaCount: 3
默认开启了持久化存储:persistence.enabled=true
所以我们只需要改pvc的大小即可
persistence:
......
size: 50Gi
我实际并没有打开,所以后边的service可以看到我依然使用的ClusterIP
注释ClusterIP
后添加如下内容:
service:
type: NodePort
#type: ClusterIP
......
nodePorts:
clientPort: "31015"
peerPort: "31016"
[root@IoT-M01 etcd]# kubectl create namespace etcd
[root@IoT-M01 etcd]# helm install etcd -n etcd ./
[root@IoT-M01 etcd]# kubectl get pod -n etcd
NAME READY STATUS RESTARTS AGE
etcd-0 1/1 Running 0 25m
etcd-1 1/1 Running 0 25m
etcd-2 1/1 Running 0 25m
[root@IoT-M01 etcd]# kubectl get service -n etcd
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
etcd ClusterIP 10.1.231.186 <none> 2379/TCP,2380/TCP 25m
etcd-headless ClusterIP None <none> 2379/TCP,2380/TCP 25m
[root@IoT-M01 etcd]# helm install etcd -n etcd ./
NAME: etcd
LAST DEPLOYED: Mon Jul 19 15:56:47 2021
NAMESPACE: etcd
STATUS: deployed
REVISION: 1
TEST SUITE: None
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.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 harbocto.boe.com.cn/bitnami/etcd:3.5.0-debian-10-r24 --env ROOT_PASSWORD=$(kubectl get secret --namespace etcd etcd -o jsonpath="{.data.etcd-root-password}" | base64 --decode) --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 -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 --decode)
[root@IoT-M01 etcd]# kubectl exec -it -n etcd etcd-0 bash
I have no name!@etcd-0:/opt/bitnami/etcd$ etcdctl --user root:Bxx888888 put /message Hello
OK
I have no name!@etcd-0:/opt/bitnami/etcd$ etcdctl --user root:Bxx888888 get /message
/message
Hello
helm 3.0.3 报错如下:
[root@master-01 etcd]# helm version
version.BuildInfo{Version:"v3.0.3", GitCommit:"ac925eb7279f4a6955df663a0128044a8a6b7593", GitTreeState:"clean", GoVersion:"go1.13.6"}
[root@master-01 etcd]# helm install etcd -n etcd-ha ./
Error: parse error at (etcd/charts/common/templates/_secrets.tpl:84): function "lookup" not defined
【解决】
我是直接升级到3.5.4 解决了