k8s-安装helm3

helm简介

  • helm类似linux下面的包管理器apt-get/yum,能够快速的把yaml文件安装进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,可以设置环境变量KUBECONFIG来指定存有ApiServre的地址与token的配置文件地址,默认为~/.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集群的位置:

这一步非常关键,它是helm与k8s通讯的保证,这一步就是把k8s环境变量KUBECONFIG进行配置
export KUBECONFIG=/root/.kube/config #可以写到/etc/profile里

简单测试;

# 生成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

查询一个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 ~]# 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。