[原]CentOS7安装Rancher2.1并部署kubernetes (二)---部署kubernetes
################## Rancher v2.1.7 + Kubernetes 1.13.4 ################
####################### 以下为声明 #####################
此文档是在两台机上进行的实践,kubernetes处于不断开发阶段
不能保证每个步骤都能准确到同步开发进度,所以如果安装部署过程中有问题请尽量google
按照下面步骤能得到什么?
1.两台主机之一会作为Rancher的server,另外一台作为Rancher Server的node节点添加进Rancher Server,得到安装好的Rancher,并以Rancher UI进行呈现
2.作为node节点的主机会被安装kubernetes,并以kubernetes dashboard的方式呈现
3.将建立一个登陆账号登陆kubernetes dashboard 并解决kubernetes dashboard token超时的问题
4.部署测试pod 和 container,(以nginx为例)
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
出处:http://www.cnblogs.com/horizonli/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
支付宝(alipay) 二维码打赏 |
微信(wechat) 二维码打赏 JUST LI(**波) |
微信公众号: 木子李的菜田 |