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 }}
复制代码

 

posted @   林夕之风  阅读(290)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示