• helm 使用方法


    harbor管理helm-chart
    harbor安装的时候默认没有helm charts的仓库,启用 harbor 的 chart repository 服务
    
    docker-compose stop
    ./install.sh  --with-chartmuseum
    
    

    配置国内chart仓库 

    微软仓库( http://mirror.azure.cn/kubernetes/charts/)

    官方仓库(https://hub.kubeapps.com/charts/incubator )

    阿里云仓库(https://kubernetes.oss-cn-hangzhou.aliyuncs.com.charts)

    添加仓库

    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  stable
    添加仓库
    helm repo add   --username admin --password Senyint.rh13579 harbor  http://192.168.15.198/chartrepo/superman
    
    
    安装Chart
     helm install    --username=admin --password=Senyint.rh13579  --version 0.1.1  harboprepo/mychart --generate-name
     
     
     创建chart
     helm   create  fengjian
     
     打包
    [root@master1 helm3]#  helm  package  fengjian
    Successfully packaged chart and saved it to: /tmp/helm3/fengjian-0.1.0.tgz
    
    
    
    helm  repo add  aliyuncs    https://apphub.aliyuncs.com              
    helm  repo add  bitnami     https://charts.bitnami.com/bitnami       
    helm  repo add  stable      http://mirror.azure.cn/kubernetes/charts/
    
    列出所有chart所有的包
    helm  search repo 
    
    列出 stablechart所有的包
    helm  search repo  stable
    
    列出所有chart mysql包
    helm search repo  mysql
    
    #列出stable mysql包
    helm search repo stable/mysql
    
    
    列出stable chart中 mysql包
    helm search repo  stable  | grep mysql
    
    helm  show
    
    Available Commands:
      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
    
    
    查看 stable/mariadb 详细信息
    helm show all stable/mariadb
    
    helm show chart stable/mariadb
    
    安装
    helm install  stable/mysql  #默认生成一个名字 例如mysql-12345
    指定名字
    helm install mariadb  stable/mysql 
    
    [root@harbor mysql]# helm ls
    NAME                NAMESPACE    REVISION
    mariadb             default      1   
    
    更新
    helm  upgrade  mariadb   stable/mysql
    
    
    指定values.yaml 值
    [root@harbor mysql]# helm install tidb -f 1.yaml stable/mysql
    
    [root@harbor mysql]# cat 1.yaml 
    mysqlUser: feng
    mysqlDatabase: feng
    service:
      type: NodePort
    
    
    直接指定值进行更新:
    
    helm install tidb stable/mysql --set persistence.enabled=false
    
    查询 mariadb 历史记录
    [root@harbor mysql]# helm history mariadb
    
    回滚操作
    [root@harbor mysql]# helm rollback mariadb 1
    
    删除
    [root@harbor mysql]# helm history mariadb
    
    
    [root@harbor templates]# helm ls
    NAME       NAMESPACE    REVISION    
    mariadb    default      1           
    nginx      default      3           
    
    查看看渲染过后的形式
    helm get manifest nginx
    
    测试执行
    helm install --dry-run test ./fengjian/  --debug
    
    
    helm 模板控制流程
    if/else 条件块
    with  指定范围
    range 循环块
    
    声明和使用命名模版段的操作
    define 在模版中声明一个新的命名模版
    template 导入一个命名模版
    block 声明了一种特殊的可填写的模版区域
    
    apiVersion: v1
    kink: ConfigMap
    metadata:
      name: {{ .Release.Name }}-configmap
    data:
      nacosserver: {{ .Values.nacosserver | default 1.1.1.1 | quote }} #quote 变成加引号
      k8s: {{ .Values.source.k8s }}
      python: {{ .Values.source.python | repeat 5 | upper }} #repeat重复5次, upper变成大写
      {{- if eq .Values.source.python "django" }}  # -号删除空行,假如 .Values.source.python 等于python
      webport: 80
      {{- end }}
      
     helm install --dry-run test ./fengjian/  --debug --set source.python=AI  不会出现webport:80
     
      
    .Values  表示作用域
    apiVersion: v1
    kink: ConfigMap
    metadata:
      name: {{ .Release.Name }}-configmap
    data:
      {{ with .Values }}
      nacosserver: {{ .nacosserver | default 1.1.1.1 | quote }} #quote 变成加引号
      k8s: {{ .source.k8s }}
      python: {{ .source.python | repeat 5 | upper }} #repeat重复5次, upper变成大写
      {{- if eq .source.python "django" }}  # -号删除空行,假如 .Values.source.python 等于python
      webport: 80
      {{- end }}
      {{- end }}   
    
    range 循环
    data:
      toppings: |-
        {{- range .Values.pizzaToppings }}
        - {{ . | title | quote }}
        {{- end }}
    
    变量
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: {{ .Release.Name }}-configmap
    data:
      myvalue: "Hello World"
      {{- $relname := .Release.Name -}}
      {{- with .Values.favorite }}
      drink: {{ .drink | default "tea" | quote }}
      food: {{ .food | upper | quote }}
      release: {{ $relname }}
      {{- end }}
    
    
    子chart 包
    我们只用了一个chart, 但是chart 也可以有子chart的依赖关系, 他们也有自己的值和模版,
    1. 子chart 是独立的, 所以子chart不萌明确依赖与其父chart
    2. 子chart无法访问其父chart的值
    3. 父chart可以覆盖子chart的值
    4. helm中有全局值概念, 可以被所有的chart访问。
    
    
    
    创建子chart
     
  • 相关阅读:
    单片机八位时钟
    共阴数码管断码与位码
    PCB自己做一个原理图模版
    Mongodb在Linux下的安装和启动和配置
    linux下用phpize给PHP动态添加扩展
    微信支付JS各种调试问题
    秒速插入百万测试数据MYSQL,提供你玩玩大数据!
    金子的PHP之禅(函数篇四)
    linux下面查找某个字符或者文件
    金子的PHP之禅(PHP运算符三)
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/15936115.html
Copyright © 2020-2023  润新知