赞
踩
什么是Helm
kubenetes包管理器,是查找,分享和使用软件构件 kubernetes的最佳方式;
可以做什么
三个重要概念
安装Helm
其他常用命令
- # 列出,增加,更新,删除chart仓库
- helm repo
- # 使用关键字搜索chart
- helm search
- # 拉去远程仓库中的chart到本地
- helm pull
- # 在本地创建新的chart
- helm create
- # 管理chart依赖
- helm dependency
- # 安装chart
- helm install
- # 列出所有的release
- helm list
- # 查看chart配置信息是否有错
- helm lint
- # 打包本地chart
- helm package
- # 回滚release 到历史版本
- helm rollback
- # 卸载
- helm uninstall/delete
- # 升级release
- helm upgrade
chart详解
修改默认源
- # 查看默认仓库
- helm repo list
-
- # 添加仓库
- helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
- helm repo add aliyun https://apphub.aliyuncs.com/
- helm repo add bitnami https://charts.bitnami.com/bitnami/
- helm repo add azure https://mirror.azure.cn/kubernetes/charts/
Redis Chart实战
- # 搜索
- helm search repo redis
-
- # 结果
- azure/prometheus-redis-exporter 3.5.1 1.3.4 DEPRECATED Prometheus exporter for Redis metrics
- azure/redis 10.5.7 5.0.7 DEPRECATED Open source, advanced key-value stor...
- azure/redis-ha 4.4.6 5.0.6 DEPRECATED - Highly available Kubernetes implem...
- bitnami/redis 19.3.3 7.2.4 Redis(R) is an open source, advanced key-value ...
- bitnami/redis-cluster 10.0.4 7.2.4 Redis(R) is an open source, scalable, distribut...
- stable/redis 1.1.15 4.0.8 Open source, advanced key-value store. It is of...
- stable/redis-ha 2.0.1 Highly available Redis cluster with multiple se...
- azure/sensu 0.2.5 0.28 DEPRECATED Sensu monitoring framework backed by...
- stable/sensu 0.2.0 Sensu monitoring framework backed by the Redis ...
-
- # 查看安装说明
- helm show readme bitnami/redis
-
- # 结果,内容过多,不做展示
- ...
-
- # 拉去镜像
- helm pull bitnami/redis
- # 解压
- tar -xvf redis-19.3.3.tgz
-
- # 进入 redis目录,修改一下内容
-
- # 修改storageClass 为 managed-nfs-storage
- # 修改redis密码 ggbhack
- # 修改 architecture 改为集群或者单列
- # 修改实例存储大小 persistence.size 1Gi 根据情况而定
-
- # 新增命名空间
- kubectl create namespace redis
-
- # 回到上一级目录进行安装 redis是别名 后面的redis是命名空间
- helm install redis ./redis/ -n redis
-
- # 安装完成会打印相关信息
- ...
-
-
- # 查看所有redis相关的
- kubectl get all -n redis
-
- # 删除
- helm delete redis -n redis
-
-
- # 出现错误后续的解决方案 看下文
-
- # 如果redis报错,镜像拉去失败,还是因为arm64的原因 更values.yaml改镜像为
-
- image:
- registry: docker.io
- repository: arm64v8/redis
- # tag: 7.2.4-debian-12-r16
- tag: latest
- digest: ""
-
- # 继续往下操作
- # 查看pvc 情况
- kubectl get pvc -n redid
-
- #结果
- NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
- redis-data-redis-master-0 Bound pvc-7561bad7-27f0-4de7-9496-e490bc496204 1Gi RWO managed-nfs-storage 36m
- redis-data-redis-replicas-0 Bound pvc-2ade690e-67bd-44b7-80f8-9569c466251e 1Gi RWO managed-nfs-storage 36m
- redis-data-redis-replicas-1 Bound pvc-a8cf13d5-5147-4a36-be26-cfeb714689f5 1Gi RWO managed-nfs-storage 6m34s
- redis-data-redis-replicas-2 Bound pvc-237f9e5b-5b9b-48ac-8580-071e16e3c47f 1Gi RWO managed-nfs-storage 6m5s
-
-
- # 都运行了的结果
- kubectl get all -n redis
-
-
- NAME READY STATUS RESTARTS AGE
- pod/redis-master-0 1/1 Running 0 8m55s
- pod/redis-replicas-0 1/1 Running 0 100s
- pod/redis-replicas-1 1/1 Running 0 7m37s
- pod/redis-replicas-2 1/1 Running 0 75s
-
- NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
- service/redis-headless ClusterIP None <none> 6379/TCP 8m59s
- service/redis-master ClusterIP 10.108.214.27 <none> 6379/TCP 8m58s
- service/redis-replicas ClusterIP 10.101.47.243 <none> 6379/TCP 8m57s
-
- NAME READY AGE
- statefulset.apps/redis-master 1/1 8m57s
- statefulset.apps/redis-replicas 3/3 8m57s
-
- # 进入master容器
- kubectl exec -it redis-master-0 -n redis -- bash
- # 操作
- I have no name!@redis-master-0:/data$ redis-cli
- 127.0.0.1:6379> auth ggbhack
- OK
- 127.0.0.1:6379> get name
- (nil)
- 127.0.0.1:6379> set name ggb
- OK
- 127.0.0.1:6379> get name
- "ggb"
- 127.0.0.1:6379>
-
- # 进入replicas
- kubectl exec -it redis-replicas-0 -n redis -- bash
-
- # 操作
- I have no name!@redis-replicas-0:/data$ redis-cli
- 127.0.0.1:6379> auth ggbhack
- OK
- 127.0.0.1:6379> get name
- "ggb"
- 127.0.0.1:6379> set name 123
- (error) READONLY You can't write against a read only replica.
- 127.0.0.1:6379>
- 说明我们的安装是成功了的
- # 更新
- # 修改密码为ggbhack123
- redis:
- password: "ggbhack123"
- helm upgrade [RELEASE][CHART][FLAG]
- helm upgrade redis ./redis/ -n redis
- # 进入容器,测试如上
- [root@k8s-master ~]# kubectl exec -it redis-replicas-0 -n redis -- bash
- I have no name!@redis-replicas-0:/data$ redis-cli
- 127.0.0.1:6379> auth ggbhack
- (error) WRONGPASS invalid username-password pair or user is disabled.
- 127.0.0.1:6379> auth ggbhack123
- OK
- 127.0.0.1:6379> get name
- "ggb"
- 127.0.0.1:6379>
- 到此完结
注意事项:
由于需要提前创建storageClass manage-nfc-storage,在前面的章节中总共有三个文件
nfc-storage-class.yaml
nfs-provisioner-deployment.yaml
nfs-provisioner-rbac.yaml
需要的文件在 这里
nfs-subdir-external-provisioner 下的nfc文件夹里
如果是在 arm64下的话,使用 registry.cn-beijing.aliyuncs.com/pylixm/nfs-subdir-external-provisioner:v4.0.0 这个镜像会报错 exec / nfs-subdir-external-provisioner format error 简单来说就是平台不匹配,解决方案就是自己构建一个匹配的镜像包
- # 下载git项目
- git clone https://github.com/ishow520/nfs-subdir-external-provisioner.git
-
- # 构建所属平台的镜像
- docker buildx build --platform linux/arm64 -t 你的hub用户名/nfs-provisioner-arm:v1.0.0 -f Dockerfile.multiarch --push .
-
- 也可以使用我构建的 ggbhack/nfs-provisioner-arm:v1.0.0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。