Kubernetes部署(一):架構(gòu)及功能說明
Kubernetes部署(二):系統(tǒng)環(huán)境初始化
Kubernetes部署(三):CA證書制作
Kubernetes部署(四):ETCD集群部署
Kubernetes部署(五):Haproxy、Keppalived部署
Kubernetes部署(六):Master節(jié)點(diǎn)部署
Kubernetes部署(七):Node節(jié)點(diǎn)部署
Kubernetes部署(八):Flannel網(wǎng)絡(luò)部署
Kubernetes部署(九):CoreDNS、Dashboard、Ingress部署
Kubernetes部署(十):儲(chǔ)存之glusterfs和heketi部署
Kubernetes部署(十一):管理之Helm和Rancher部署
Kubernetes部署(十二):helm部署harbor企業(yè)級(jí)鏡像倉庫
創(chuàng)新互聯(lián)主要業(yè)務(wù)有網(wǎng)站營(yíng)銷策劃、成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開發(fā)、重慶小程序開發(fā)、H5場(chǎng)景定制、程序開發(fā)等業(yè)務(wù)。一次合作終身朋友,是我們奉行的宗旨;我們不僅僅把客戶當(dāng)客戶,還把客戶視為我們的合作伙伴,在開展業(yè)務(wù)的過程中,公司還積累了豐富的行業(yè)經(jīng)驗(yàn)、營(yíng)銷型網(wǎng)站建設(shè)資源和合作伙伴關(guān)系資源,并逐漸建立起規(guī)范的客戶服務(wù)和保障體系。
helm官方下載地址:https://github.com/helm/helm/releases
官方可用的chart列表:https://hub.kubeapps.com
所有的軟件及配置文件都保存在前面文章提到的百度網(wǎng)盤里 :百度共享鏈接在此文章里
Helm是一種簡(jiǎn)化Kubernetes應(yīng)用程序安裝和管理的工具。可以把它想象成apt/yum/homebrew。
Helm可在您的筆記本電腦,或在任何位置運(yùn)行。
[root@node-01 ~]# 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
[root@node-01 k8s]# wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.1-linux-amd64.tar.gz
[root@node-01 k8s]# tar zxf helm-v2.12.1-linux-amd64.tar.gz
[root@node-01 k8s]# cd linux-amd64/
[root@node-01 linux-amd64]# mv helm /usr/bin/
因某些原因我們無法直接從google下載tiller鏡像,所以需要下載我網(wǎng)盤共享的鏡像tiller-image-v2.12.1.tar.gz
,然后在每個(gè)node節(jié)點(diǎn)加載鏡像
[root@node-04 ~]# 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
[root@node-01 helm]# kubectl create -f rbac-config.yaml
[root@node-01 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!
[root@node-01 helm]# kubectl -n kube-system get pod|grep tiller
tiller-deploy-85744d9bfb-cm5jz 1/1 Running 0 11m
[root@node-01 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"}
release管理:
至此helm就已經(jīng)部署完了,下面會(huì)通過helm安裝k8s的管理平臺(tái),也順便演示helm的使用。
helm官方倉庫沒有rancher的chart包,所以我們需要添加rancher官方chart倉庫。
[root@node-01 helm]# helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
"rancher-stable" has been added to your repositories
[root@node-01 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...
[root@node-01 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
[root@node-01 helm]#
[root@node-01 helm]# helm install rancher-stable/rancher --name rancher --namespace cattle-system --set hostname=rancher.cnlinux.club
默認(rèn)情況下,Rancher會(huì)自動(dòng)生成CA根證書并使用cert-manager頒發(fā)證書,因此,這里設(shè)置了 hostname=rancher.cnlinux.club,后續(xù)只能通過域名訪問UI
如果你沒有內(nèi)部DNS服務(wù)器而是通過添加/etc/hosts主機(jī)別名的方式指定的Rancher server域名,那么不管通過哪種方式(自定義、導(dǎo)入、Host驅(qū)動(dòng)等)創(chuàng)建K8S集群,K8S集群運(yùn)行起來之后,因?yàn)閏attle-cluster-agent Pod和cattle-node-agent無法通過DNS記錄找到Rancher server,最終導(dǎo)致無法通信。
可以通過給cattle-cluster-agent Pod和cattle-node-agent添加主機(jī)別名(/etc/hosts),讓其可以正常通信(前提是IP地址可以互通)。
注意:替換以下命令中的域名和IP
[root@node-01 helm]# kubectl -n cattle-system patch deployments cattle-cluster-agent --patch '{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"rancher.cnlinux.club"
],
"ip": "10.31.90.200"
}
]
}
}
}
}'
[root@node-01 helm]# kubectl -n cattle-system patch daemonsets cattle-node-agent --patch '{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"rancher.cnlinux.club"
],
"ip": "10.31.90.200"
}
]
}
}
}
}'
3.至此就可以通過rancher來管理pod、ingress、service等資源了。
后續(xù)會(huì)陸續(xù)更新所有的k8s相關(guān)文檔,如果你覺得我寫的不錯(cuò),希望大家多多關(guān)注點(diǎn)贊,非常感謝!