kubernetes helm

Posted by Sunday on 2019-10-11

安装helm

https://github.com/helm/helm/releases
下载对应版本的二进制程序

1
2
3
4
cd /usr/local/src/
wget https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz
tar xf helm-v2.14.3-linux-amd64.tar.gz
cp linux-amd64/helm /usr/local/bin

1
2
3
4
5
6
7
8
9
10
11
12
13
kubectl -n kube-system create serviceaccount tiller

kubectl create clusterrolebinding tiller \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:tiller

# helm init --service-account tiller
# Users in China: You will need to specify a specific tiller-image in order to initialize tiller.
# The list of tiller image tags are available here: https://dev.aliyun.com/detail.html?spm=5176.1972343.2.18.ErFNgC&repoId=62085.
# When initializing tiller, you'll need to pass in --tiller-image

helm init --service-account tiller \
--tiller-image registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.3

https://rancher.com/docs/rancher/v2.x/en/installation/ha/helm-init/

#镜像

1
2
gcr.azk8s.cn/kubernetes-helm/tiller:<tag>
http://mirror.azure.cn/kubernetes/charts

1
2
# kubectl get pods -n kube-system | grep tiller
tiller-deploy-75f5747884-zhpwl 1/1 Running 0 69s

https://www.qikqiak.com/k8s-book/docs/42.Helm%E5%AE%89%E8%A3%85.html

1
2
3
4
5
6
7
8
9
10
11
# helm repo list
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts

helm repo remove stable
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

helm repo update # 更新charts列表
helm search # 搜索可用charts
helm search mysql

使用

1
2
3
4
5
6
helm create hello-helm

vim hello-helm/values.yaml
service:
type: NodePort
port: 80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# helm install ./hello-helm
NAME: kindled-numbat
LAST DEPLOYED: Sat Oct 12 06:11:51 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
kindled-numbat-hello-helm 0/1 0 0 1s

==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
kindled-numbat-hello-helm-6566985869-lmh2l 0/1 ContainerCreating 0 0s

==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kindled-numbat-hello-helm NodePort 10.103.185.205 <none> 80:30062/TCP 2s


NOTES:
1. Get the application URL by running these commands:
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services kindled-numbat-hello-helm)
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT

# kubectl get pod -l app.kubernetes.io/name=hello-helm
NAME READY STATUS RESTARTS AGE
kindled-numbat-hello-helm-6566985869-lmh2l 1/1 Running 0 4m3s

# kubectl get svc -l app.kubernetes.io/name=hello-helm
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kindled-numbat-hello-helm NodePort 10.103.185.205 <none> 80:30062/TCP 5m4s

#访问
curl 192.168.10.80:30062

# helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
kindled-numbat 1 Sat Oct 12 06:11:51 2019 DEPLOYED hello-helm-0.1.0 1.0 default
# helm package hello-helm
Successfully packaged chart and saved it to: /root/hello-helm-0.1.0.tgz

# helm delete kindled-numbat
release "kindled-numbat" deleted

# kubectl get pod -l app.kubernetes.io/name=hello-helm
No resources found.

安装jenkins

1
helm install --set master.serviceType=NodePort,persistence.enabled=false stable/jenkins