当前位置:网站首页>helm部署etcd集群
helm部署etcd集群
2022-07-06 10:52:00 【开发运维玄德公】
文章目录
1. chart和镜像准备
1.1 官方下载chart
- 下载地址
https://artifacthub.io/ - 搜索etcd,选择bitnami 的版本
1.2 下载
找一台可以上公网的服务器,参照官方文下载chart包
- 添加helm仓库
# 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拷贝到要目标服务器上即可。
1.3 下载镜像
1.3.1 下载镜像
离线安装需要提前准备如下镜像:
- etcd镜像(必要)
docker.io/bitnami/etcd:3.4.15-debian-10-r33
- 许可证相关(非必要)
下边这个镜像是写许可证用的,如果没有启用许可证可以不下载docker.io/bitnami/bitnami-shell:10-debian-10-r134
1.3.2 上传私有镜像仓库
私有镜像镜像名如下:harbocto.xxx.com.cn/bitnami/etcd:3.4.15-debian-10-r33
harbocto.xxx.com.cn/bitnami/bitnami-shell:10-debian-10-r134
2. 修改配置文件
进入解压缩后生成的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
- 修改为 NodePort(非必要)
我实际并没有打开,所以后边的service可以看到我依然使用的ClusterIP
注释ClusterIP
后添加如下内容:
service:
type: NodePort
#type: ClusterIP
......
nodePorts:
clientPort: "31015"
peerPort: "31016"
3 启动服务
- 创建namespace,进入chart的etcd目录启动服务
[[email protected] etcd]# kubectl create namespace etcd
[[email protected] etcd]# helm install etcd -n etcd ./
- 查看pod
[[email protected] 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
- 查看service
[[email protected] 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
4. 测试
- 输出
刚才创建的时候可见数据如下:
[[email protected] 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)
- 进入etcd的pod
[[email protected] etcd]# kubectl exec -it -n etcd etcd-0 bash
- 写入数据
I have no [email protected]:/opt/bitnami/etcd$ etcdctl --user root:Bxx888888 put /message Hello
OK
- 读刚才写入的数据
I have no [email protected]:/opt/bitnami/etcd$ etcdctl --user root:Bxx888888 get /message
/message
Hello
FAQ
1)helm3.0.3报错
helm 3.0.3 报错如下:
[[email protected] etcd]# helm version
version.BuildInfo{
Version:"v3.0.3", GitCommit:"ac925eb7279f4a6955df663a0128044a8a6b7593", GitTreeState:"clean", GoVersion:"go1.13.6"}
[[email protected] 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 解决了
边栏推荐
- Test 123
- 【中山大学】考研初试复试资料分享
- Some recruitment markets in Shanghai refuse to recruit patients with covid-19 positive
- Interpreting cloud native technology
- Cocos2d Lua smaller and smaller sample memory game
- Self supervised heterogeneous graph neural network with CO comparative learning
- Excellent open source fonts for programmers
- Shangsilicon Valley JUC high concurrency programming learning notes (3) multi thread lock
- epoll()无论涉及wait队列分析
- 涂鸦智能在香港双重主板上市:市值112亿港元 年营收3亿美元
猜你喜欢
MySQL查询请求的执行过程——底层原理
【LeetCode第 300 场周赛】
Why does wechat use SQLite to save chat records?
[the 300th weekly match of leetcode]
Numerical analysis: least squares and ridge regression (pytoch Implementation)
On AAE
徐翔妻子应莹回应“股评”:自己写的!
Implementation of AVL tree
【中山大学】考研初试复试资料分享
SQL injection - access injection, access offset injection
随机推荐
win10系统下插入U盘有声音提示却不显示盘符
None of the strongest kings in the monitoring industry!
Epoll () whether it involves wait queue analysis
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
Penetration test information collection - site architecture and construction
【中山大学】考研初试复试资料分享
Optical blood pressure estimation based on PPG and FFT neural network [translation]
Self supervised heterogeneous graph neural network with CO comparative learning
随着MapReduce job实现去加重,多种输出文件夹
图之广度优先遍历
首先看K一个难看的数字
Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
Solve DoS attack production cases
287. 寻找重复数
Describe the process of key exchange
【LeetCode第 300 场周赛】
Method of accessing mobile phone storage location permission under non root condition
一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
echart简单组件封装
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed