################## Rancher v2.1.7 + Kubernetes 1.13.4 ################html
####################### 如下爲聲明 #####################node
此文檔是在兩臺機上進行的實踐,kubernetes處於不斷開發階段nginx
不能保證每一個步驟都能準確到同步開發進度,因此若是安裝部署過程當中有問題請儘可能googlegit
按照下面步驟能獲得什麼?github
1.兩臺主機之一會做爲Rancher的server,另一臺做爲Rancher Server的node節點添加進Rancher Server,獲得安裝好的Rancher,並以Rancher UI進行呈現json
2.做爲node節點的主機會被安裝kubernetes,並以kubernetes dashboard的方式呈現api
3.將創建一個登錄帳號登錄kubernetes dashboard 並解決kubernetes dashboard token超時的問題bash
4.部署測試pod 和 container,(以nginx爲例)app
5,認識Rancher和kubernetes,知道其長什麼樣子能作什麼工做。學習
6.此文不作生產環境使用,若是使用到生產環境,責任自負。只做爲學習Rancher和kubernetes使用,因爲時間關係,文中有錯誤的地方歡迎指正交流。
7.此文分爲三部分:
CentOS7安裝Rancher2.0並部署kubernetes (一)---部署Rancher
CentOS7安裝Rancher2.0並部署kubernetes (二)---部署kubernetes
CentOS7安裝Rancher2.0並部署kubernetes (三)---解決登陸kubernets超時和部署測試Pod和Containter[nginx爲例]
############################## 下面爲文檔正文 #####################################
cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF
yum install -y kubectl
kubectl get svc/kubernetes-dashboard -n kube-system -o yaml
--- apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kube-system node01主機上運行此文件: kubectl create -f dashboard.yml node01主機上獲取token以便於登陸註冊: kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}') [root@node01 ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | aw Name: admin-user-token-mnln7 Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name: admin-user kubernetes.io/service-account.uid: c7d5c3c6-4bcc-11e9-b693-000c29198029 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1017 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZuYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2Nvdjb3VudC51aWQiOiJjN2Q1YzNjNi00YmNjLTExZTktYjY5My0wMDBjMjkxOTgwMjkiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zelciJ9.KXSf7k7HFY-CcVUtByW-m1jib-JGq6FH7tihODW_TVr3F0JznBGkRDFixn1_XCNQ0Ee-GCXB_-_ra2ZTYgYqm1VHjbEsb8QKR_zkx1_klDXsIhlaT4yvEcn-kkpwsWNYQLJIUftXezDuEr07wtF00zHPXEZxv-QZ1NJ-vgUWXQHKeMocp3ahp41N8CJf8yslBKKvFQ2N4JdqJRYUu_3JIg-VhaUuJpGiVh96Ith5KLuNUBulteQNYB0omCE3cHZHBEaJKwkp-Vy6JSKBXhIPGf9PbiLlh9qTYgbPR4vYSayn7QryGQ
[root@node01 ~]# kubectl edit deployment kubernetes-dashboard -n kube-system
[root@node01 ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}') Name: admin-user-token-mnln7 Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name: admin-user kubernetes.io/service-account.uid: c7d5c3c6-4bcc-11e9-b693-000c29198029 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1017 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLW1ubG43Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJjN2Q1YzNjNi00YmNjLTExZTktYjY5My0wMDBjMjkxOTgwMjkiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.KXSf7k7HFY-CcVUtByW-m1jib-JGq6FH7tihODW_TVr3F0JznBGkRDFixn1_XCNQ0Ee-GCXB_-_ra2ZTYgYqm1VHjbEsb8QKR_zkx1_klDXsRtnN0-4NOOwreTQhxzIhlaT4yvEcn-kkpwsWNYQLJIUftXezDuEr07wtF00zHPXEZxv-QZ1NJ-vgUWXQHKeMocp3ahp41N8CJf8yslBKKvFQ2N4JdqJRYUu_3JIg-VhaUuJpOv_bBTK1DbQEJ0GHIuGiVh96Ith5KLuNUBulteQNYB0omCE3cHZHBEaJKwkp-Vy6JSKBXhIPGf9PbiLlh9qTYgbPR4vYSayn7QryGQ