Helm部署
helm官方下载地址:https://github.com/helm/helm/releases
官方可用的chart列表:https://hub.kubeapps.com
所有的软件及配置文件都保存在前面文章提到的百度网盘里 :百度共享链接在此文章里
helm简介
Helm是一种简化Kubernetes应用程序安装和管理的工具。可以把它想象成apt/yum/homebrew。
- Helm有两部分:client(helm)和server(tiller)
,Tiller在您的Kubernetes集群内部运行,并管理chart的发布(安装)。 - Helm可在您的笔记本电脑,或在任何位置运行。
- chart是包含至少两件事的Helm包:
- 包的描述(Chart.yaml)
- 一个或多个模板,包含Kubernetes清单文件
- chart可以存储在磁盘上,也可以从远程chart存储库(如Debian或RedHat包)中获取.
核心术语
- Chart:一个helm程序包;
- Repository:Charts仓库,https/http服务器;
- Release:特定的Chart部署于目标集群上的一个实例;
程序架构
- helm:客户端,管理本地的Chart仓库,管理Chart, 与Tiller服务器交互,发送Chart,实例安装、查询、卸载等 操作;
- Tiller:服务端,接收helm发来的Charts与Config,合并生成relase;
helm部署
- helm可以部署在任何机器上,不一定要在kubernetes的服务器上,但是需要安装kubectl,也就是说用户家目录下要有kube的配置文件,因为helm需要和apiServer通信。
[[email protected] ~]# ll .kube/ total 12 drwxr-xr-x 3 root root 23 Dec 25 11:28 cache -rw------- 1 root root 6264 Dec 25 16:15 config drwxr-xr-x 3 root root 4096 Jan 2 15:09 http-cache
- 开始部署
[[email protected] k8s]# wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.1-linux-amd64.tar.gz [[email protected] k8s]# tar zxf helm-v2.12.1-linux-amd64.tar.gz [[email protected] k8s]# cd linux-amd64/ [[email protected] linux-amd64]# mv helm /usr/bin/
因某些原因我们无法直接从google下载tiller镜像,所以需要下载我网盘共享的镜像tiller-image-v2.12.1.tar.gz
,然后在每个node节点加载镜像
[[email protected] ~]# docker load < tiller-image-v2.12.1.tar.gz
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
[[email protected] helm]# kubectl create -f rbac-config.yaml
[[email protected] helm]# helm init --service-account tiller
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.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 /root/.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.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
[[email protected] helm]# kubectl -n kube-system get pod|grep tiller
tiller-deploy-85744d9bfb-cm5jz 1/1 Running 0 11m
[[email protected] helm]# helm version
Client: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}
helm常用命令:
- release管理:
- install
- delete
- upgrade/rollback
- list
- history:release的历史信息;
- status:获取release状态信息;
- chart管理:
- create
- fetch
- get
- inspect
- package
- verify
至此helm就已经部署完了,下面会通过helm安装k8s的管理平台,也顺便演示helm的使用。
Rancher部署
rancher简介
- Rancher是一个企业级多集群Kubernetes管理平台;
- 用户可以在Rancher上配置和管理公有云(如GKE、EKS、AKS、阿里云、华为云等)上托管的Kubernetes服务,亦可向Rancher中导入已有集群。
- 对于所有Kubernetes集群与服务,用户均可以在Rancher上进行集中身份认证(包括GitHub、AD/LDAP、SAML等)。
添加chart仓库
helm官方仓库没有rancher的chart包,所以我们需要添加rancher官方chart仓库。
[[email protected] helm]# helm repo add rancher-stable https://releases.rancher.com/server-charts/stable "rancher-stable" has been added to your repositories [[email protected] helm]# helm search rancher-stable/rancher NAME CHART VERSION APP VERSION DESCRIPTION rancher-stable/rancher 2018.12.4 v2.1.4 Install Rancher Server to manage Kubernetes clusters acro...
安装cert-manager
- 安装成功后会详细显示安装的所有资源
[[email protected] helm]# helm install stable/cert-manager --name cert-manager --namespace kube-system
NAME: cert-manager
LAST DEPLOYED: Thu Jan 3 15:35:22 2019
NAMESPACE: kube-system
STATUS: DEPLOYED
RESOURCES:
==> v1/ServiceAccount
NAME SECRETS AGE
cert-manager 1 1s
==> v1beta1/ClusterRole
NAME AGE
cert-manager 1s
==> v1beta1/ClusterRoleBinding
NAME AGE
cert-manager 1s
==> v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
cert-manager 1 1 1 0 1s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
cert-manager-7d4bfc44ff-5flvg 0/1 ContainerCreating 0 0s
NOTES:
cert-manager has been deployed successfully!
In order to begin issuing certificates, you will need to set up a ClusterIssuer
or Issuer resource (for example, by creating a ‘letsencrypt-staging‘ issuer).
More information on the different types of issuers and how to configure them
can be found in our documentation:
https://cert-manager.readthedocs.io/en/latest/reference/issuers.html
For information on how to configure cert-manager to automatically provision
Certificates for Ingress resources, take a look at the `ingress-shim`
documentation:
https://cert-manager.readthedocs.io/en/latest/reference/ingress-shim.html
[[email protected] helm]#
安装rancher server
[[email protected] helm]# helm install rancher-stable/rancher --name rancher --namespace cattle-system --set hostname=rancher.cnlinux.club
默认情况下,Rancher会自动生成CA根证书并使用cert-manager颁发证书,因此,这里设置了 hostname=rancher.cnlinux.club,后续只能通过域名访问UI
为Agent Pod添加主机别名(可选)
如果你没有内部DNS服务器而是通过添加/etc/hosts主机别名的方式指定的Rancher server域名,那么不管通过哪种方式(自定义、导入、Host驱动等)创建K8S集群,K8S集群运行起来之后,因为cattle-cluster-agent Pod和cattle-node-agent无法通过DNS记录找到Rancher server,最终导致无法通信。
可以通过给cattle-cluster-agent Pod和cattle-node-agent添加主机别名(/etc/hosts),让其可以正常通信(前提是IP地址可以互通)。
注意:替换以下命令中的域名和IP
cattle-cluster-agent pod
[[email protected] helm]# kubectl -n cattle-system patch deployments cattle-cluster-agent --patch ‘{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"rancher.cnlinux.club"
],
"ip": "10.31.90.200"
}
]
}
}
}
}‘
cattle-node-agent pod
[[email protected] helm]# kubectl -n cattle-system patch daemonsets cattle-node-agent --patch ‘{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"rancher.cnlinux.club"
],
"ip": "10.31.90.200"
}
]
}
}
}
}‘
访问rancher
- 通过浏览器访问https://rancher.cnlinux.club/,出现如下页面,然后设置密码
- 然后就可以出现如下界面,就证明已经正常运行了
3.至此就可以通过rancher来管理pod、ingress、service等资源了。
- rancher也创建新的k8s集群,如果管理其他现有的k8s集群,可以选择如下图的导入
后续会陆续更新所有的k8s相关文档,如果你觉得我写的不错,希望大家多多关注点赞,非常感谢!
原文地址:http://blog.51cto.com/billy98/2338415