Helm 可以理解为 Kubernetes 的包管理工具,可以方便地发现、共享和使用为Kubernetes构建的应用,它包含几个基本概念
Helm 采用客户端/服务器架构,有如下组件组成:
安装步骤
1、 下载helm安装包
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.10.0-rc.3-linux-amd64.tar.gz
2、创建tiller的serviceaccount
和clusterrolebinding
kubectl create serviceaccount --namespace kube-system tiller kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
3. 安装helm服务端tiller
[root@master1 gateway]# helm init -i 192.168.200.10/source/kubernetes-helm/tiller:v2.10.0-rc.3 --service-account tiller --skip-refresh Creating /root/.helm Creating /root/.helm/repository Creating /root/.helm/repository/cache Creating /root/.helm/repository/local Creating /root/.helm/plugins Creating /root/.helm/starters Creating /root/.helm/cache/archive Creating /root/.helm/repository/repositories.yaml Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com Adding local repo with URL: http://127.0.0.1:8879/charts $HELM_HOME has been configured at /root/.helm. Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster. Please note: by default, Tiller is deployed with an insecure ‘allow unauthenticated users‘ policy. To prevent this, run `helm init` with the --tiller-tls-verify flag. For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation Happy Helming!
4、 查看是否安装
[root@master1 gateway]# kubectl -n kube-system get pods|grep tiller tiller-deploy-849c444cff-h9zw2 1/1 Running 0 46s
5、创建chart
helm create gateway
6. 测试修改是否正确
[root@master1 helm]# ls gateway helm-v2.10.0-rc.3-linux-amd64.tar.gz linux-amd64 [root@master1 helm]# helm install --dry-run --debug ./gateway [debug] Created tunnel using local port: ‘46252‘ [debug] SERVER: "127.0.0.1:46252" [debug] Original chart version: "" [debug] CHART PATH: /root/helm/gateway NAME: imprecise-sabertooth REVISION: 1 RELEASED: Tue Aug 14 14:42:14 2018 CHART: gateway-0.1.0 USER-SUPPLIED VALUES: {} COMPUTED VALUES: affinity: {} image: pullPolicy: IfNotPresent repository: 192.168.200.10/source/nginx tag: latest ingress: {} nodeSelector: {} replicaCount: 1 resources: limits: cpu: 100m memory: 128Mi requests: cpu: 100m memory: 128Mi service: port: 80 type: ClusterIP tolerations: [] HOOKS: MANIFEST: --- # Source: gateway/templates/service.yaml apiVersion: v1 kind: Service metadata: name: imprecise-sabertooth-gateway labels: app: gateway chart: gateway-0.1.0 release: imprecise-sabertooth heritage: Tiller spec: type: ClusterIP ports: - port: 80 targetPort: http protocol: TCP name: http selector: app: gateway release: imprecise-sabertooth --- # Source: gateway/templates/deployment.yaml apiVersion: apps/v1beta2 kind: Deployment metadata: name: imprecise-sabertooth-gateway labels: app: gateway chart: gateway-0.1.0 release: imprecise-sabertooth heritage: Tiller spec: replicas: 1 selector: matchLabels: app: gateway release: imprecise-sabertooth template: metadata: labels: app: gateway release: imprecise-sabertooth spec: containers: - name: gateway image: "192.168.200.10/source/nginx:latest" imagePullPolicy: IfNotPresent ports: - name: http containerPort: 80 protocol: TCP livenessProbe: httpGet: path: / port: http readinessProbe: httpGet: path: / port: http resources: limits: cpu: 100m memory: 128Mi requests: cpu: 100m memory: 128Mi
[root@master1 gateway]# helm install . NAME: riotous-crab LAST DEPLOYED: Tue Aug 14 14:43:21 2018 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE riotous-crab-gateway ClusterIP 10.254.26.20 <none> 80/TCP 0s ==> v1beta2/Deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE riotous-crab-gateway 1 1 1 0 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE riotous-crab-gateway-fd7465cc8-frcmd 0/1 ContainerCreating 0 0s NOTES: 1. Get the application URL by running these commands: export POD_NAME=$(kubectl get pods --namespace default -l "app=gateway,release=riotous-crab" -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
查看部署的relaese
helm list
删除relaese
helm delete gateway
打包分享
[root@master1 gateway]# helm package . Successfully packaged chart and saved it to: /root/helm/gateway/gateway-0.1.0.tgz
chart通过HTTP server方式提供
helm serve #默认是 127.0.0.1:8879 可以添加参数 helm serve --address 192.168.20.171:80
原文:https://www.cnblogs.com/fengjian2016/p/9475974.html