1.Helm的简介

Helm是Kubernetes的一个包管理工具,用来简化Kubernetes应用的部署和管理。可以把Helm比作CentOS的yum工具。 Helm有如下几个基本概念:
Chart: 是Helm管理的安装包,里面包含需要部署的安装包资源。可以把Chart比作CentOS yum使用的rpm文件。每个Chart包含下面两部分:
  1.包的基本描述文件Chart.yaml
  2.放在templates目录中的一个或多个Kubernetes manifest文件模板
Release:是chart的部署实例,一个chart在一个Kubernetes集群上可以有多个release,即这个chart可以被安装多次
Repository:chart的仓库,用于发布和存储chart
使用Helm可以完成以下事情:
  1.管理Kubernetes manifest files
  2.管理Helm安装包charts
  3.基于chart的Kubernetes应用分发

二、Helm的组成

Helm由两部分组成,客户端helm和服务端tiller。
  1.tiller运行在Kubernetes集群上,管理chart安装的release
  2.helm是一个命令行工具,可在本地运行,一般运行在CI/CD Server上。

三、安装helm和tiller

1.下载helm
[root@master- ~]# wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.1-linux-amd64.tar.gz  #如何无法科*学*上*网可以从我的网盘中下载 链接: (https://pan.baidu.com/s/1XmVnCMmNVOf1puRqgoqdXw 提取码: 44s1)
[root@master- ~]# tar xf helm-v2.12.1-linux-amd64.tar.gz
总用量
-rw-------. root root -- : anaconda-ks.cfg
-rw-r--r-- root root -- : helm-v2.12.1-linux-amd64.tar.gz
drwxr-xr-x root root -- : linux-amd64
[root@master- linux-amd64]# ll
总用量
-rwxr-xr-x root root -- : helm
-rw-r--r-- root root -- : LICENSE
-rw-r--r-- root root -- : README.md
-rwxr-xr-x root root -- : tiller
[root@master- linux-amd64]# cp helm /usr/bin/ #下载解压完成后,直接将helm执行文件放入PATH环境变量中就可以使用了
[root@master- linux-amd64]# helm -h
2.安装 tiller

由于tiller需要安装、删除等操作pod的权限,所以要为tiller设置相应的权限,权限可以分为集群级别或名称空间级别

配置文档:https://github.com/helm/helm/blob/master/docs/rbac.md

[root@master- ~]# mkdir manifests
[root@master- ~]# cd manifests/
[root@master- manifests]# ll
总用量
[root@master- manifests]# mkdir helm
[root@master- manifests]# cat tiller-rbac.yaml #创建tiller的rbac配置文件
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
[root@master- manifests]# kubectl apply -f tiller-rbac.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created
[root@master- manifests]# kubectl get sa -n kube-system |grep tiller #确认是否创建成功
tiller 57s
[root@master- manifests]# helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.12.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts #由于墙的原因,所以我们使用阿里的chart仓库,注意指定的tiller版本需要和helm版本一致
$HELM_HOME has been configured at /root/.helm.
Tiller (the Helm server-side component) has been upgraded to the current version.
Happy Helming!
[root@master- manifests]# kubectl get pod -n kube-system |grep tiller #查看tiller的pod是否创建成功
tiller-deploy-7d898b45c4-knp4b / Running 2m
[root@master- manifests]# helm version
Client: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}

可能遇到的报错:

E0224 ::16.077226     portforward.go:] an error occurred forwarding  -> : error forwarding port  to pod 76a7312e49220a229e443546a4b32d3e0406f09fd9b3646b3d30f6833e121375, uid : unable to do port forwarding: socat not found.
Error: cannot connect to Tiller

解决方法:

在所有节点和vip服务器上安装socat
yum -y install socat

如果只安装helm客户端,执行以下操作:

wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.1-linux-amd64.tar.gz  #下载安装包
helm init --client-only --stable-repo-url https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/ #使用--client-only 参数

四、常用命令

查看下载的包的信息

[root@master- manifests]# ll ~/.helm/cache/archive/   #helm下载的包路径
总用量
-rw-r--r-- root root -- : redis-1.1..tgz
[root@master- archive]# tar xf redis-1.1..tgz
tar: redis/Chart.yaml:不可信的旧时间戳 -- ::00 #时间戳告警可以忽略
.....
[root@master- archive]# tree redis
redis
├── Chart.yaml #描述当前chart有哪些属性信息
├── README.md #自述文件
├── templates #模板文件目录
│   ├── deployment.yaml #模板文件,之所以叫做模板文件是因为文件中大量使用了go语言模板
│   ├── _helpers.tpl
│   ├── networkpolicy.yaml
│   ├── NOTES.txt
│   ├── pvc.yaml
│   ├── secrets.yaml
│   └── svc.yaml
└── values.yaml #定义默认值 directory, files

其他:

[root@master- ~]# helm -h
[root@k8s-master templates]# helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator #添加一个repo仓库,名称为incubator
[root@k8s-master templates]# helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
[root@k8s-master templates]# helm repo remove stable #删除一个仓库,名称为stable
[root@k8s-master templates]# helm repo list #显示所有的仓库列表
[root@k8s-master templates]# helm repo update
[root@k8s-master templates]# helm search elasticsearch #搜索一个chart
[root@k8s-master templates]# helm fetch incubator/elasticsearch #下载一个chart并解压到本地
[root@k8s-master archive]# cd /root/.helm/cache/archive
[root@k8s-master archive]# ll

查看详细命令帮助: https://docs.helm.sh/helm/#helm

项目地址:https://github.com/helm/helm

下载地址:https://github.com/helm/helm/releases/

官方文档地址:https://docs.helm.sh/

helm官方网址:https://helm.sh/

helm chart官方网址:https://hub.kubeapps.com/  

kubernetes学习笔记之十四:helm入门的更多相关文章

  1. VSTO学习笔记(十四)Excel数据透视表与PowerPivot

    原文:VSTO学习笔记(十四)Excel数据透视表与PowerPivot 近期公司内部在做一种通用查询报表,方便人力资源分析.统计数据.由于之前公司系统中有一个类似的查询使用Excel数据透视表完成的 ...

  2. Python学习笔记(十四)

    Python学习笔记(十四): Json and Pickle模块 shelve模块 1. Json and Pickle模块 之前我们学习过用eval内置方法可以将一个字符串转成python对象,不 ...

  3. python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法

    python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法window安装redis,下载Redis的压缩包https://git ...

  4. 如鹏网学习笔记(十四)ASP.NET

    Asp.net笔记 一.Socket类 进行网络编程的类,可以在两台计算机之间进行网络通讯 过程: 向服务器发送指令: GET /index.html HTTP/1.1 Host:127.0.0.1: ...

  5. 《机器学习实战》学习笔记第十四章 —— 利用SVD简化数据

    相关博客: 吴恩达机器学习笔记(八) —— 降维与主成分分析法(PCA) <机器学习实战>学习笔记第十三章 —— 利用PCA来简化数据 奇异值分解(SVD)原理与在降维中的应用 机器学习( ...

  6. Android学习笔记(十四)——自定义广播

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 我们除了可以通过广播接收器来接收系统广播, 还可以在应用程序中发送自定义的广播.下面我们来分别试一试发送自定义 ...

  7. Dynamic CRM 2013学习笔记(十四)复制/克隆记录

    经常有这样的需求,一个单据上有太多要填写的内容,有时还关联多个子单据,客户不想一个一个地填写,他们想从已有的单据上复制数据,克隆成一条新的记录.本文将介绍如何克隆一条记录,包括它的子单据以生成一条新的 ...

  8. JavaScript学习笔记(十四)——对象

    在学习廖雪峰前辈的JavaScript教程中,遇到了一些需要注意的点,因此作为学习笔记列出来,提醒自己注意! 如果大家有需要,欢迎访问前辈的博客https://www.liaoxuefeng.com/ ...

  9. Java框架spring 学习笔记(十四):注解aop操作

    回见Java框架spring Boot学习笔记(十三):aop实例操作,这里介绍注解aop操作 首先编写一个切入点HelloWorld.java package com.example.spring; ...

随机推荐

  1. Python mysql-python及pycurl使用一例

    #环境:CentOS Linux release 7.5.1804 (Core) mini安装,使用python2.7 #使用pucurl对输入的url地址进行测试,将结果存放到mysql中,代码来之 ...

  2. org.springframework.orm.hibernate3.HibernateSystemException:

    org.springframework.orm.hibernate3.HibernateSystemException: The database returned no natively gener ...

  3. echarts立体效果地图-自定义区域及文字

    setgeomap: function (_id, _fn) { // 全城拥堵占比 GLOBAL.myMapChart = echarts.init(document.getElementById( ...

  4. Java基础知识学习思维导图

  5. 我的代码-statistic analysis

    # coding: utf-8 # In[1]: # numpy and pandas for data manipulationimport numpy as npimport pandas as ...

  6. MySQL_DML语言

    #MySQL--DML语言##SQL组成DDL:数据库模式定义语言,关键字:create DML:数据操纵语言,关键字:insert,delete,update DCL:数据库控制语言,关键字:gra ...

  7. jenkins中shell脚本编写的两个注意点

    在jenkins的build中,如果用shell脚本的话,要记住有两个地方要注意 1.由于默认jenkins是使用/bin/bash -xe xxx.sh来调用脚本的,所以不同于日常写的脚本,任何一行 ...

  8. python 2.7 pip导入django,将python部署到sublime上

    1.安装python 2.7,并且导入第三方库django 下载python 2.7,然后把python2.7的python.exe的路径和pip的路径添加到系统环境变量的path路径下. win+R ...

  9. [R] Lexical & Dynamic Scoping / Execution & Calling environments / Closures

    Lexical Scoping :有Java繼承中呼叫子類時先生成父類的概念,呼叫函數後,系統會轉至其定義處,將其 environment 中所具有的東西(有些可能定義在外層)形成 Closure [ ...

  10. PythonStudy——枚举 enumerate

    # 给可迭代器对象及迭代器对象添加迭代索引 s = 'abc' for v in enumerate(s): print(v) # (0 'a') | (1 'b') | (2 'c')