Kubernetes教程-Helm


 

安裝helm3:

wget https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
tar -zxvf helm-v3.2.4-linux-amd64.tar.gz
cd linux-amd64
ll

cp -a helm /usr/local/bin/helm
chmod a+x /usr/local/bin/helm

或者直接從腳本上安裝:

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
helm env

添加公用的倉庫

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

 

指定對應的k8s集群

這一步非常關鍵,它是helm與k8s通訊的保證,這一步就是把k8s環境變量KUBECONFIG進行配置

注:v3版本不再需要Tiller,而是通過ApiServer與k8s交互,可以設置環境變量KUBECONFIG來指定存有ApiServre的地址與token的配置文件地址,默認為~/.kube/config

export KUBECONFIG=/root/.kube/config #可以寫到/etc/profile里

部署dashboard:

cd /usr/local/install-k8s/plugin
mkdir dashboard
cd dashboard
helm fetch stable/kubernetes-dashboard
tar -zxvf kubernetes-dashboard-1.11.1.tgz
cd kubernetes-dashboard

 

helm install kubernetes-dashboard/kubernetes-dashboard --generate-name  #生成名稱
helm install my-release kubernetes-dashboard/kubernetes-dashboard #指定名稱
helm list
kubectl get pods -n default -l "app.kubernetes.io/name=kubernetes-dashboard,app.kubernetes.io/instance=kubernetes-dashboard-1595829663" -o jsonpath="{.items[0].metadata.name}"
kubectl get pod -o wide

kubectl get svc -n default
kubectl edit svc kubernetes-dashboard-1595829663 -n default

 

 改成NodePort

 

kubectl -n default get secret | grep kubernetes
kubectl describe secret -n default 

 

#vim rbac.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system


#kubectl create -f rbac.yaml

#helm init --service-account tiller --skip-refresh

#kubectl get pod -n kube-system

 

ImagePullBackOff:表示失敗

#kubectl describe pod tiller-deploy-d98957755-z9xlt -n kube-system  #查看為啥tiller-deploy的pod沒有成功,發現是tiller的image沒有
#docker pull gcr.io/kubernetes-helm/tiller:v2.16.9

搜索helm的倉庫源都有哪些?

 

創建自定義模版:

Chart.yaml文件也是固定不能變的。

創建templates目錄名,並且不能修改。

 

 

 安裝寫好的Chart.yaml文件的命令是

#helm install .   #安裝deployment和service,名稱為隨機字符串
#helm install --name nobby-eel . #安裝時可以指定名稱為:nobby-eel

 
#helm list    #查看正在運行的helm。CHART是hello-world-1.0.0

#helm upgrade nobby-eel .   #更新名為nobby-eel的helm

 

#helm history nobby-eel  #查看名為nobby-eel的helm的歷史記錄

 

#helm status nobby-eel   #查看名為nobby-eel的helm的狀態

 

curl http://192.168.4.86:32671  #通過ip地址+port的方式訪問

 values.yaml和Chart.yaml文件在同一個目錄

 

 修改templates目錄里面的yaml文件,使用values.yaml文件里面定義的變量值

 

運行安裝的時候指定變量的值

 

#helm upgrade nobby-eel .   #更新升級

 

刪除、回滾、徹底刪除

#helm delete nobby-eel      #刪除(其實沒有被真正刪掉)
#helm ls --deleted             #看到已經被刪除helm
#helm rollbak nobby-eel 6   #回滾指定名稱和版本的helm
#helm delete --purge nobby-eel   #真正刪除掉某一個helm

 

#helm install --dry-run . --debug --set image.tag=latest  #不是真正執行,而是打印清單內容

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM