什么是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

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

Kubernetes Helm入门指南的更多相关文章

  1. Helm 入门指南

    Helm 为Kubernetes的软件包管理工具,Helm有两部分组成:Helm客户端.Tiller服务端,Helm三个主要部件:Chart.仓库.Release: Chart:为Kubernetes ...

  2. Kubernetes认证入门指南

    Kubernetes用来执行安全访问和权限的步骤有3个--认证(Authentication).授权(Authorization)和准入(Admission).在本文中,我们先开始了解认证(Authe ...

  3. Kubernetes快速入门

    二.Kubernetes快速入门 (1)Kubernetes集群的部署方法及部署要点 (2)部署Kubernetes分布式集群 (3)kubectl使用基础 1.简介 kubectl就是API ser ...

  4. Activiti 工作流入门指南

    概览 如我们的介绍部分所述,Activiti目前分为两大类: Activiti Core Activiti Cloud 如果你想上手Activiti的核心是否遵循了新的运行时API的入门指南:Acti ...

  5. Docker 入门指南

    Docker 入门指南 目录 基础概念 安装教程 基本操作 常用安装 构建操作 容器编排 壹.基础概念 什么是Docker? Docker是基于Go开发的应用容器引擎,属于 Linux 容器的一种封装 ...

  6. Web API 入门指南 - 闲话安全

    Web API入门指南有些朋友回复问了些安全方面的问题,安全方面可以写的东西实在太多了,这里尽量围绕着Web API的安全性来展开,介绍一些安全的基本概念,常见安全隐患.相关的防御技巧以及Web AP ...

  7. Vue.js 入门指南之“前传”(含sublime text 3 配置)

    题记:关注Vue.js 很久了,但就是没有动手写过一行代码,今天准备入手,却发现自己比菜鸟还菜,于是四方寻找大牛指点,才终于找到了入门的“入门”,就算是“入门指南”的“前传”吧.此文献给跟我一样“白痴 ...

  8. yii2实战教程之新手入门指南-简单博客管理系统

    作者:白狼 出处:http://www.manks.top/document/easy_blog_manage_system.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文 ...

  9. 【翻译】Fluent NHibernate介绍和入门指南

    英文原文地址:https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started 翻译原文地址:http://www.cnblogs ...

随机推荐

  1. php session_id() session_name()

    1.Session.use_cookies:默认值为"1",代表SessionID使用Cookie来传递,反之就是用Query_String来传递 2.Session.name:这 ...

  2. Oracle 常用函数大全

    Oracle 11g 常用函数(Functions)详解 目录 ABS. 3 ACOS. 3 ADD_MONTHS. 4 ASCII 4 ASCIISTR. 5 ASIN.. 5 ATAN.. 5 A ...

  3. Linux mysql中文乱码问题

    1.debian系统 (1)mysql 5.5版本之前 vim /etc/mysql/my.cnf 在  [client]  下面加入 default-character-set=utf8 在  [m ...

  4. linux 第八章 高级键盘

    1.clear:清屏 2.history:显示历史命令列表 3.Ctrl+A:移动光标到行首 4.Ctrl+E:移动光标到行尾 5.Ctrl+F:光标向前移动一个字符 6.Ctrl+B:光标向h后移动 ...

  5. c# 屏蔽快捷键

    前言 有时候开发会遇到这样一个需求,软件需要屏蔽用户的组合快捷键或某些按键,避免强制退出软件,防止勿操作等. 原理 1.要实现组合键,按键拦截,需要用到user32.dll中的SetWindowsHo ...

  6. OpenGL Loading

    什么是 OpenGL loading? OpenGL是一份API规范,并不是一个库.记住这点非常重要!它意味着每一个API背后的具体实现都依赖于你的GPU硬件.操作系统以及显卡驱动. OpenGL规范 ...

  7. TCP-Java--图谱

  8. js【jquery】-事件

    1.event对象 在IE.chrome中它是全局变量 与事件相关的信息会保存在event对象中,只有在事件发生的过程中,event才有信息 在其他浏览器中: 通过事件函数的第一个参数传入的 even ...

  9. WPF-MVVM学习心德(WinForm转WPF心德)

    接触MVVM接近一段时间了,有一点理解,写下来. 之前是做winform的,工作需要,学习wpf.优缺点就不用说类,网上一大堆.我自己理解的话,有下面几点: 1.首先是界面的xmal和界面分离:wpf ...

  10. Java ConcurrentHashMap的小测试

    今天正式开始自己的分布式学习,在第一章介绍多线程工作模式时,作者抛出了一段关于ConcurrentHashMap代码让我很是疑惑,代码如下: public class TestClass { priv ...