-
如何管理,編輯和更新這些這些分散的Kubernetes應用配置檔案?
-
如何把一套的相關配置檔案作為一個應用進行管理?
-
如何分發和重用Kubernetes的應用配置?
-
下載 Helm https://github.com/kubernetes/helm/releases
-
解壓 tar -zxvf helm-v2.0.0-linux-amd64.tgz
-
複製到bin目錄 mv linux-amd64/helm /usr/local/bin/helm
Helm init
git clone https://github.com/zhaohuabing/testapi.git;
cd testapi
helm create testapi-chart
testapi-chart
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── NOTES.txt
│ └── service.yaml
└── values.yaml
-
Chart.yaml用於描述這個Chart,包括名字、描述資訊以及版本。
-
values.yaml 用於儲存templates目錄中模板檔案中用到的變數。 模板檔案一般是Go模板。如果你需要瞭解更多關於Go模板的相關資訊,可以檢視Hugo[1]的一個關於Go模板的介紹[2]。
-
NOTES.txt用於向部署該Chart的用於介紹Chart部署後的一些資訊。例如介紹如何使用這個Chart,列出預設的設定等。
apiVersion: v1
description: A simple api for testing and debugging
name: testapi-chart
version: 0.0.1
replicaCount: 2
image:
repository: daemonza/testapi
tag: latest
pullPolicy: IfNotPresent
service:
name: testapi
type: ClusterIP
externalPort: 80
internalPort: 80
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
helm lint
==> Linting .
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, no failures
helm package testapi-chart --debug
Saved /Users/daemonza/testapi/testapi-chart/testapi-chart-0.0.1.tgz to current directory
Saved /Users/daemonza/testapi/testapi-chart/testapi-chart-0.0.1.tgz to /Users/daemonza/.helm/repository/local
helm search testapi
No results found
helm repo list
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
helm serve&
Now serving you on 127.0.0.1:8879
helm repo add local http://127.0.0.1:8879
"local" has been added to your repositories
helm search testapi
NAME CHART VERSION APP VERSION DESCRIPTION
local/testapi-chart 0.0.1 A Helm chart for Kubernetes
helm install local/testapi-chart --name testapi
NAME: testapi
LAST DEPLOYED: Mon Apr 16 10:21:44 2018
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
testapi-testapi-chart ClusterIP 10.43.121.84 80/TCP 0s
==> v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
testapi-testapi-chart 1 1 1 0 0s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
testapi-testapi-chart-9897d9f8c-nn6wd 0/1 Pending 0 0s
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app=testapi-testapi-chart" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
helm ls
NAME REVISION UPDATED STATUS CHART NAMESPACE
testapi 1 Mon Apr 16 10:21:44 2018 DEPLOYED testapi-chart-0.0.1 default
helm search testapi -l
NAME CHART VERSION APP VERSION DESCRIPTION
local/testapi-chart 0.0.1 A Helm chart for Kubernetes
local/testapi-chart 1.0.0 A Helm chart for Kubernetes
helm upgrade testapi local/testapi-chart
helm list
NAME REVISION UPDATED STATUS CHART NAMESPACE
testapi 2 Mon Apr 16 10:43:10 2018 DEPLOYED testapi-chart-1.0.0 default
helm history testapi
REVISION UPDATED STATUS CHART DESCRIPTION
1 Mon Apr 16 10:21:44 2018 SUPERSEDED testapi-chart-0.0.1 Install complete
2 Mon Apr 16 10:43:10 2018 DEPLOYED testapi-chart-1.0.0 Upgrade complete
helm rollback testapi 1
helm list
NAME REVISION UPDATED STATUS CHART NAMESPACE
testapi 3 Mon Apr 16 10:48:20 2018 DEPLOYED testapi-chart-0.0.1 default
dependencies:
- name: apache
version: 1.2.3
repository: http://example.com/charts
- name: mysql
version: 3.2.1
repository: http://another.example.com/charts
-
https://gohugo.io
-
https://gohugo.io/templates/go-templates/