Helm 是管理 Kubernetes 的应用管理工具
相当于centos的yum,python中pip,node中的npm.
几个概念
#根据操作系统去获取最新二进制安装包https://github.com/helm/helm/releases
wget https://get.helm.sh/helm-v3.3.1-linux-amd64.tar.gz
#由于helm包在国外,我通过ss拉到了腾讯云cos,国内可通过以下地址访问:https://download.osichina.net/tools/k8s/helm/helm-v3.3.1-linux-amd64.tar.gz
tar -zxvf helm-v3.3.1-linux-amd64.tar.gz
cp linux-amd64/helm /usr/local/bin/
helm其他安装可参考官方网站: https://helm.sh/docs/intro/install/
注意: helm 客户端需要下载到安装了 kubectl 并且能执行能正常通过 kubectl 操作 kubernetes 的服务器上, 否则 helm 将不可用
helm repo add elastic https://helm.elastic.co
helm repo add gitlab https://charts.gitlab.io
helm repo add harbor https://helm.goharbor.io
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
helm repo add stable https://kubernetes-charts.storage.googleapis.com
#添加国内仓库
helm repo add stable http://mirror.azure.cn/kubernetes/charts
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo update
helm repo list
关键解释
#搜索
helm search repo nginx
#安装
helm install nginx bitnami/nginx -n nginx
nginx/
├── charts #依赖其他包的charts文件
├── Chart.yaml # 该chart的描述文件,包括ico地址,版本信息等
├── templates #存放k8s模板文件目录
│ ├── deployment.yaml #创建k8s资源的yaml 模板
│ ├── _helpers.tpl #下划线开头的文件,可以被其他模板引用.
│ ├── hpa.yaml # 配置服务资源CPU 内存
│ ├── ingress.yaml # ingress 配合service域名访问的配置
│ ├── NOTES.txt #说明文件,helm install之后展示给用户看的内容
│ ├── service.yaml #kubernetes Serivce yaml 模板
└── values.yaml #给模板文件使用的变量
关键解释
#查询已安装
helm list -A
#搜索
helm search repo nginx
#拉取到本地
helm pull bitnami/nginx --untar
#根据values.yml配置本地安装
helm install nginx . -f values.yaml -n nginx
#根据values.yml配置本地升级
helm upgrade nginx . -f values.yaml -n nginx
#卸载
helm uninstall nginx -n nginx
关键解释
#使用set更新
helm upgrade tomcat bitnami/tomcat --set service.type=NodePort --set persistence.enabled=false
helm list
#查看状态
helm status tomcat
#使用values.yaml更新
helm upgrade -f values.yaml tomcat .
#查看更新历史
helm history tomcat
#回滚
helm rollback tomcat 2
yum -y install epel-release
yum -y install nfs-utils rpcbind
systemctl enable rpcbind nfs-server nfs-lock nfs-idmap
systemctl start rpcbind nfs-server nfs-lock nfs-idmap
#172.18.4.*的IP都能访问nfs
echo "/data 172.18.4.*(rw,sync,no_root_squash)" > /etc/exports
exportfs -a
helm pull stable/nfs-client-provisioner --untar
cd nfs-client-provisioner/
vim values.yaml
helm install nfs -f values.yaml .
values.yaml
...
nfs:
server: 172.18.4.202
path: /data/nfs
mountOptions:
...
由于GFW的原因,镜像下载失败,我这边是从本地下载好导入.
关键点
helm search repo ingress
helm pull stable/nginx-ingress --untar
helm install ingress -f values.yaml . -n ingress
vim nginx-ingress/values.yaml
helm upgrade -f values.yaml ingress . -n ingress
helm repo list
#添加私有仓库,包括账号、密码
helm repo add myhabor https://harbor.osichina.net/chartrepo/charts --username $username --password $password
helm repo list
tree -L 2 cerebro
#安装helm-push插件,该插件支持使用 helm push 指令推送 helm chart 至指定 repo,同时支持上传目录及压缩包
helm plugin install https://github.com/chartmuseum/helm-push
#推送到私有仓库
helm push cerebro myhabor
#查询
helm search repo cerebro
#更细缓存,如果查询不到刚刚上传的chart,需要进行此步骤
helm repo update
helm search repo cerebro
#下载私有habor中chart
helm fetch myhabor/cerebro --untar
引用文章: https://www.pvcreate.com/index.php/archives/205/
全部评论