k8s-安裝helm3

helm簡(jiǎn)介

  • helm類似linux下面的包管理器apt-get/yum,能夠快速的把yaml文件安裝進(jìn)k8s

helm安裝:

[root@web-test-01 ~]
wget https://get.helm.sh/helm-v3.1.2-linux-amd64.tar.gz
tar zxvf helm-v3.1.2-linux-amd64.tar.gz
cd linux-amd64
cp helm /usr/bin/helm
helm version
version.BuildInfo{Version:"v3.1.2", GitCommit:"d878d4d45863e42fd5cff6743294a11d28a9abce", GitTreeState:"clean", GoVersion:"go1.13.8"}
[root@192 demo]# helm help
The Kubernetes package manager

Common actions for Helm:

- helm search:    search for charts
- helm pull:      download a chart to your local directory to view
- helm install:   upload the chart to Kubernetes
- helm list:      list releases of charts

helm3不在需要tiller,可以設(shè)置環(huán)境變量KUBECONFIG來指定存有ApiServre的地址與token的配置文件地址,默認(rèn)為~/.kube/config

查看helm配置信息:

[root@192 templates]# helm env
HELM_BIN="helm"
HELM_DEBUG="false"
HELM_KUBECONTEXT=""
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"

添加共有的倉庫:

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

指定k8s集群的位置:

這一步非常關(guān)鍵,它是helm與k8s通訊的保證,這一步就是把k8s環(huán)境變量KUBECONFIG進(jìn)行配置
export KUBECONFIG=/root/.kube/config #可以寫到/etc/profile里

簡(jiǎn)單測(cè)試;

# 生成chart文件
[root@192 ~]# helm create one
Creating one

# 打包
[root@192 ~]# helm package one
Successfully packaged chart and saved it to: /root/one-0.1.0.tgz
[root@192 ~]# 

# 安裝
[root@192 ~]# helm install one  one-0.1.0.tgz 
NAME: one
LAST DEPLOYED: Mon Jun 22 12:06:40 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=one,app.kubernetes.io/instance=one" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl --namespace default port-forward $POD_NAME 8080:80

[root@192 ~]# helm  ls
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
one     default         1               2020-06-22 12:06:40.103299546 +0800 CST deployed        one-0.1.0       1.16.0     
[root@192 ~]# kubectl  get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP   23d
one          ClusterIP   10.97.179.118   <none>        80/TCP    117s
[root@192 ~]# kubectl  get deploy
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
one    1/1     1            1           2m4s
[root@192 ~]# kubectl  get pods 
NAME                     READY   STATUS    RESTARTS   AGE
one-656864586b-ldsw2     1/1     Running   0          2m8s
tomcat-daemonset-t6tcq   1/1     Running   1          15h
#刪除剛才安裝的release
[root@192 ~]# helm delete one
release "one" uninstalled
[root@192 ~]# kubectl  get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   23d
[root@192 ~]# kubectl  get deploy
No resources found in default namespace.
[root@192 ~]# kubectl  get pods
NAME                     READY   STATUS    RESTARTS   AGE
tomcat-daemonset-t6tcq   1/1     Running   1          16h
[root@192 ~]# 

repo的操作:

# 添加倉庫
$helm repo add {倉庫名字} {倉庫地址}
"{倉庫名字}" has been added to your repositories

# 查詢倉庫列表
$helm repo list
NAME        URL                                                            
{倉庫名字}  {倉庫地址}

# 查詢chart包
$helm search repo

# 刪除倉庫
$helm repo remove {倉庫名字}
"{倉庫名字}" has been removed from your repositories

查詢一個(gè)chart

[root@192 ~]# 
[root@192 ~]# helm search hub ceph
URL                                                     CHART VERSION   APP VERSION     DESCRIPTION                                       
https://hub.helm.sh/charts/ceph-csi/ceph-csi-ce...      2.1.2           v2.1.2          Container Storage Interface (CSI) driver, provi...
https://hub.helm.sh/charts/ceph-csi/ceph-csi-rbd        2.1.2           v2.1.2          Container Storage Interface (CSI) driver, provi...
[root@192 ~]# 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容