|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

 

 

posted on 2022-03-31 13:33  yanqi_vip  阅读(20)  评论(0)    收藏  举报

导航