helm create hello-world
Chart.yaml 用於描述這個Chart的相關信息,包括名字、描述信息以及版本等。
僅僅是一些簡單的文本描述node
values.yaml 用於存儲 templates 目錄中模板文件中用到變量的值。nginx
NOTES.txt 用於介紹 Chart 部署後的一些信息,例如:如何使用這個 Chart、列出缺省的設置等。api
Templates 目錄下是 YAML 文件的模板,該模板文件遵循 Go template 語法。app
Templates 目錄下 YAML 文件模板的值默認都是在 values.yaml 裏定義的,好比在 deployment.yaml 中定義的容器鏡像。
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
其中的 .Values.image.repository 的值就是在 values.yaml 裏定義的 nginx,.Values.image.tag 的值就是 stable。
以上兩個變量值是在 create chart 的時候就自動生成的默認值,你能夠根據實際狀況進行修改。實際上都是靜態文本,只在是執行的時候才被解析.curl
打開 Chart.yaml,能夠看到內容以下,配置名稱和版本wordpress
apiVersion: v1 appVersion: "1.0" description: A Helm chart for Kubernetes name: mychart version: 0.1.0
編輯 values.yaml,它默認會在 Kubernetes 部署一個 Nginx。下面是 mychart 應用的 values.yaml 文件的內容:this
$ cat mychart/values.yaml # Default values for mychart. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: repository: nginx tag: stable pullPolicy: IfNotPresent service: type: ClusterIP port: 80 ingress: enabled: false annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" path: / hosts: - chart-example.local tls: [] # - secretName: chart-example-tls # hosts: # - chart-example.local resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following # lines, adjust them as necessary, and remove the curly braces after 'resources:'. # limits: # cpu: 100m # memory: 128Mi # requests: # cpu: 100m # memory: 128Mi nodeSelector: {} tolerations: [] affinity: {}
$ helm lint hello-world/
helm package hello-world helm package mychart --debug #顯示詳細信息
helm serve --repo-path /data/helm/repository/ --url http://172.17.0.22:8879/charts/ &
$ helm repo update $ helm search mychart NAME CHART VERSION APP VERSION DESCRIPTION local/hello-world 0.1.0 1.0 A Helm chart for Kubernetes
Chart 被髮布到倉儲後,就能夠經過 helm install 命令部署該 Chart。url
helm install hello local/hello-world
helm status wordpress
helm upgrade wordpress stable/wordpress helm upgrade --install --force hello-world ./hello.tgz --namespace test # 也能夠指定命名空間和它的taz包
helm rollback hello-world 1 # 向上歸滾一個版本