|NO.Z.00272|——————————|CloudNative|——|KuberNetes&中间件容器化及helm.V19|——|中间件.v03|helm.v3.5.4|目录层级|语法|
一、helm的目录层级
### --- 使用helm创建一个charts
[root@k8s-master01 harbor]# helm create helm-test
Creating helm-test
### --- helm创建的charts的层级
[root@k8s-master01 harbor]# tree helm-test
├── charts # 依赖文件
├── Chart.yaml # 这个chart的版本信息
├── templates # 模板
│ ├── deployment.yaml
│ ├── _helpers.tpl # 自定义的模板或者函数
│ ├── ingress.yaml
│ ├── NOTES.txt # 这个chart的信息
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml # 配置全局变量或者一些参数
### --- charts目录层级解释
[root@k8s-master01 helm-test]# cat values.yaml
replicaCount: 1 # 副本数
image: # 镜像
repository: nginx
pullPolicy: IfNotPresent
~~~ # 查看deployment
~~~ 注:配置的都是一些变量参数
[root@k8s-master01 helm-test]# cat templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-test.fullname" . }}
~~~ # 版本信息
[root@k8s-master01 helm-test]# cat Chart.yaml
apiVersion: v2
name: helm-test
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0
二、helm的语法
### --- 查看helm的语法
[root@k8s-master01 harbor]# cat helm-test/values.yaml
replicaCount: 1 // 定义了一个变量replicaCount值为1
image: // image定义了2个
repository: nginx // 镜像名称
pullPolicy: IfNotPresent // 下载策略
~~~ values是固定写法,autoscaling.enabled是values来取的值
[root@k8s-master01 harbor]# cat helm-test/templates/deployment.yaml
spec:
{{- if not .Values.autoscaling.enabled }}
********衔接上文***********
tag: ""
### --- 常用函数地址
~~~ http://masterminds.github.io/sprig/strings.html
### --- helm常用语法
helm install test --dry-run .
include: // 引入的函数或者模板,_helpers.tpl
define: // 定义一个模板,
trunc: // 只取前多少位字符,负号代表从后往前取
trimSuffix: // 字符串末尾去掉指定的字符,Prefix
$name := xxx // 定义一个变量
default: // 定义的变量的默认值
contains: // 判断字符串是否包含某个字符串
replace: // 替换字符串
helm install helm-test2 --set fullnameOverride=aaaaaaa --dry-run .
--set // 修改values里面的值
helm install rabbitmq-cluster --namespace public-service --set replicaCount=2 .
### --- 删除helm
uninstall rabbitmq-cluster -n public-service # helm v3 --keep-history
helm delete/del NAME --purge
### --- 升级helm
upgrade rabbitmq-cluster -n public-service .
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了