本文介绍在Kubernetes Cluster环境中安装Helm 3和使用Helm 3的方法。Helm 3没有像Helm 2那样的服务器/客户端体系结构,没有分server服务器组件。因此,该安装仅适用于通过kubectl配置文件和默认的Kubernetes RBAC与Kubernetes交互的helm命令行组件。关于Helm 2的安装和使用请参考:在Kubernetes集群上安装和使用Helm 2的方法。
一、安装Helm 3 在客户端计算机中安装Helm 3: curl -L https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash 这是示例安装输出: Helm v3.0.2 is available. Changing from version v3.0.1. Downloading https://get.helm.sh/helm-v3.0.2-linux-amd64.tar.gz Preparing to install helm into /usr/local/bin helm installed into /usr/local/bin/helm 确认安装Helm 3: $ helm version version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
二、添加Helm Chart存储库 安装Helm后,添加图表存储库,我们将添加官方的Helm稳定图表: $ helm repo add stable https://kubernetes-charts.storage.googleapis.com/ "stable" has been added to your repositories 然后,将能够列出可以安装的图表: $ helm search repo stable
三、在Helm Chart上安装应用程序 首先列出可用的contexts,以确认你的Kubernetes CLI使用的群集context正确: $ kubectl config get-contexts
切换到所需的context: $ kubectl config use-context k3s Switched to context "k3s". 我们将确认是否可以使用Helm 3在Kubernetes cluster上安装应用程序,在此设置中,我将安装Nginx入口控制器,NGINX Ingress控制器可以从官方Helm chart stable/nginx-ingress存储库中轻松安装: $ helm repo update Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "stable" chart repository Update Complete. Happy Helming! 获取图表功能: $ helm show chart stable/nginx-ingress apiVersion: v1 appVersion: 0.26.1 description: An nginx Ingress controller that uses ConfigMap to store the nginx configuration. home: https://github.com/kubernetes/ingress-nginx icon: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Nginx_logo.svg/500px-Nginx_logo.svg.png keywords: - ingress - nginx kubeVersion: '>=1.10.0-0' maintainers: - name: ChiefAlexander - email: Trevor.G.Wood@gmail.com name: taharah name: nginx-ingress sources: - https://github.com/kubernetes/ingress-nginx version: 1.26.2 使用helm install命令安装图表: $ helm install nginx-ingress stable/nginx-ingress 也可以让安装程序生成图表发行版的名称(忽略NAME参数),安装后,会收到如下消息:
确认安装: $ helm ls
要卸载发行版,请使用helm uninstall命令: $ helm uninstall nginx-ingress release "nginx-ingress" uninstalled $ helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION 下面的示例用于使用Helm在Kubernetes中安装DokuWiki(参考:使用Nginx与Letsencrypt在Ubuntu 18.04上安装DokuWiki的方法): $ helm install dokuwiki stable/dokuwiki NAME: dokuwiki LAST DEPLOYED: Mon Dec 23 13:32:52 2019 NAMESPACE: kube-system STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: ** Please be patient while the chart is being deployed ** 1. Get the DokuWiki URL by running: ** Please ensure an external IP is associated to the dokuwiki service before proceeding ** ** Watch the status using: kubectl get svc --namespace kube-system -w dokuwiki ** export SERVICE_IP=$(kubectl get svc --namespace kube-system dokuwiki --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}") echo "URL: http://$SERVICE_IP/" 2. Login with the following credentials echo Username: user echo Password: $(kubectl get secret --namespace kube-system dokuwiki -o jsonpath="{.data.dokuwiki-password}" | base64 --decode)
相关主题 |