helm 安装
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
在/root/.bashrc添加source <(helm completion bash)用来自动补全
常用命令
# 增加源 helm repo add stable http://mirror.azure.cn/kubernetes/charts helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts helm repo add jetstack https://charts.jetstack.io # 更新源 helm repo update # 查找chart helm search repo nginx # 查下详细信息 helm inspect chart stable/nginx-ingress # all show all information of the chart # chart show the chart's definition # crds show the chart's CRDs # readme show the chart's README # values show the chart's values # 安装chart ,name 加chart名,可以指定namespace helm install nginx-ingress stable/nginx-ingress --namespace=dev helm install {name} {本地chart压缩包名} helm install {name} {chart目录} helm install {name} chart压缩包完整url
helm template <CHART>命令以生成 helm 清单
helm install {name} {chart目录} --dry-run --debug 不安装 调试运行 # name是 helm list的名字,也是你部署的deployment,pod,svc,clusterrole等名字,后面是chart #卸载直接 helm uninstall {name} #自定义chart helm install stable stable/nginx-ingree -f yaml文件 #可以多个文件,重复value最后1个文件生效 #也可以 --set 建议不用 # 可以helm fetch traefik/traefik 下载chart压缩包,修改重新安装
# helm package traefik 将traefik目录重新打包成压缩包 通常是value.yaml结合templates 生成最终配置文件,修改value的等文件使之变更 # 升级和回滚 helm upgrade -f {配置} {name} {chart} helm upgrade -f traefik-update.yaml traefik traefik/traefik
helm upgrade hello-world2 . -n test helm history traefik #查看部署版本历史
helm 模板常用语法
# templates/_文件 这些文件不会渲染为Kubernetes对象定义,但在其他chart模板中都可用,比如可以定义模板 ,_helpers.tpl默认有 {{- define "traefik.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} 引用name: {{ template "traefik.fullname" . }} with 与range引用 Values.yaml env: - name: KUBERNETES_SERVICE_HOST value: "172.25.32.231" - name: KUBERNETES_SERVICE_PORT value: "6443" podEnv: server: name: KUBERNETES_SERVICE_HOST value: "172.25.32.231" port: name: KUBERNETES_SERVICE_PORT value: "6443" 引用 {{- with .Values.env }} env: {{- toYaml . | nindent 8 }} {{- end }} envs: {{- range $e, $config := .Values.podEnv }} {{- if $config }} - name: {{ $config.name }} value: {{ $config.value| quote }} {{- end }} {{- end }}
坚持到无能为力,拼搏到感动自己
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY