共计 4729 个字符,预计需要花费 12 分钟才能阅读完成。
本篇内容主要讲解“Kubernetes Helm 怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“Kubernetes Helm 怎么使用”吧!
什么是 Helm?这可不是暗黑破坏神里装备的名称:头盔,而是 Kubernetes 的一个包管理工具,用来简化 Kubernetes 应用的部署和管理。我们 Helm 和 Kubernetes 的关系,我们可以理解成 yum 和 CentOS,apt-get 和 Ubuntu 的关系。
Helm 由两部分组成,客户端 helm 和服务端 tiller。
其中 tiller 运行在 Kubernetes 集群上,管理 chart,而客户端 helm 就是一个命令行工具,可在本地运行,一般运行在持续集成 / 持续交付的服务器上。
下图是 helm 的架构图。
我们现在就来试用下 helm。
首先安装 helm 客户端。
下载 helm 执行文件的压缩包:
wget -O helm.tar.gz
https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-linux-amd64.tar.gz
tar -xzf helm.tar.gz
解压完毕后,将 helm 文件移到目录 /usr/local/bin/helm 下面:
mv linux-amd64/helm /usr/local/bin/helm
给这个文件加上执行权限:
chmod +x /usr/local/bin/helm
首先使用 -namespace 参数指定使用的 namespace,我例子里的命名空间是 part-0110:
helm init –tiller-namespace part-0110 –service-account access
helm init –tiller-namespace part-0110 –service-account access
Creating /home/vagrant/.helm
Creating /home/vagrant/.helm/repository
Creating /home/vagrant/.helm/repository/cache
Creating /home/vagrant/.helm/repository/local
Creating /home/vagrant/.helm/plugins
Creating /home/vagrant/.helm/starters
Creating /home/vagrant/.helm/cache/archive
Creating /home/vagrant/.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 /home/vagrant/.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.
For more information on securing your installation see:
https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
从 helm 的 init 命令输出,我们可以观察到,该命令生成了大量和 helm server 交互所必须的 repository。
现在可以使用 helm version 命令行参数查看 helm 客户端和服务器端的版本号:
helm version –tiller-connection-timeout=5 –tiller-namespace part-0110
vagrant@vagrant:~/.kube$ helm version –tiller-connection-timeout=5 –tiller-namespace part-0110
Client: version.Version{SemVer: v2.9.1 , GitCommit: 20adb27c7c5868466912eebdf6664e7390ebe710 , GitTreeState: clean}
Server: version.Version{SemVer: v2.9.1 , GitCommit: 20adb27c7c5868466912eebdf6664e7390ebe710 , GitTreeState: clean}
使用命令 helm repo list 查看 helm 仓库列表:
根据名称搜索 helm chart:
helm search chaoskube
使用下面的命令行安装 chart。命令行中的参数 jerry 可以根据需要改成你自己期望的名字。
helm install –name jerry stable/chaoskube –set namespaces=part-0110 –set rbac.serviceAccountName=access –tiller-namespace part-0110 –debug
下面是 helm install 命令的输出,供您参考:
vagrant@vagrant:~/.kube$ helm install –name jerry stable/chaoskube –set namespaces=part-0110 –set rbac.serviceAccountName=access –tiller-namespace part-0110 –debug
[debug] Created tunnel using local port: 36408
[debug] SERVER: 127.0.0.1:36408
[debug] Original chart version:
[debug] Fetched stable/chaoskube to /home/vagrant/.helm/cache/archive/chaoskube-0.10.0.tgz
[debug] CHART PATH: /home/vagrant/.helm/cache/archive/chaoskube-0.10.0.tgz
NAME: jerry
REVISION: 1
RELEASED: Thu Nov 15 16:37:19 2018
CHART: chaoskube-0.10.0
USER-SUPPLIED VALUES:
namespaces: part-0110
rbac:
serviceAccountName: access
COMPUTED VALUES:
affinity: {}
annotations: null
debug: false
dryRun: true
excludedDaysOfYear: null
excludedTimesOfDay: null
excludedWeekdays: null
image: quay.io/linki/chaoskube
imageTag: v0.10.0
interval: 10m
labels: null
minimumAge: 0s
name: chaoskube
namespaces: part-0110
nodeSelector: {}
priorityClassName:
rbac:
create: false
serviceAccountName: access
replicas: 1
resources: {}
timezone: UTC
tolerations: []
HOOKS:
MANIFEST:
Source: chaoskube/templates/deployment.yaml
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: jerry-chaoskube
labels:
app: chaoskube
heritage: Tiller
release: jerry
chart: chaoskube-0.10.0
spec:
replicas: 1
selector:
matchLabels:
app: chaoskube
release: jerry
template:
metadata:
labels:
app: chaoskube
heritage: Tiller
release: jerry
chart: chaoskube-0.10.0
spec:
containers:
name: chaoskube
image: quay.io/linki/chaoskube:v0.10.0
args:
–interval=10m
–labels=
–annotations=
–namespaces=part-0110
–excluded-weekdays=
–excluded-times-of-day=
–excluded-days-of-year=
–timezone=UTC
–minimum-age=0s
resources:
{}
serviceAccountName: access
LAST DEPLOYED: Thu Nov 15 16:37:19 2018
NAMESPACE: part-0110
STATUS: DEPLOYED
RESOURCES:
== v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
jerry-chaoskube 1 1 1 0 2s
== v1/Pod(related)
NAME READY STATUS RESTARTS AGE
jerry-chaoskube-6689695476-kchtn 0/1 ContainerCreating 0 1s
NOTES:
chaoskube is running and will kill arbitrary pods every 10m.
You can follow the logs to see what chaoskube does:
POD=$(kubectl -n part-0110 get pods -l= release=jerry-chaoskube –output=jsonpath= {.items[0].metadata.name} )
kubectl -n part-0110 logs -f $POD
You are running in dry-run mode. No pod is actually terminated.
使用 helm list 命令,现在就能查看到刚才安装的名为 jerry 的 chart 了。
helm list –tiller-namespace part-0110
使用 helm 命令查看这个 chart 的明细(类似 kubectl describe pod XXX )
helm status jerry –tiller-namespace part-0110
上图也显示了自动生成的 pod 名称为 jerry-chaoskube-6689695476-kchtn,可以用 kubectl log 命令查看其运行日志:
kubectl log jerry-chaoskube-6689695476-kchtn
到此,相信大家对“Kubernetes Helm 怎么使用”有了更深的了解,不妨来实际操作一番吧!这里是丸趣 TV 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!