溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Kubernetes集群node節(jié)點(diǎn)的部署

發(fā)布時(shí)間:2020-05-30 13:08:29 來源:億速云 閱讀:433 作者:鴿子 欄目:云計(jì)算

部署環(huán)境

負(fù)載均衡
Nginx1:192.168.13.128/24
Nginx2:192.168.13.129/24
Master節(jié)點(diǎn)
master1:192.168.13.131/24 kube-apiserver kube-controller-manager kube-scheduler etcd
master2:192.168.13.130/24 kube-apiserver kube-controller-manager kube-scheduler etcd
Node節(jié)點(diǎn)
node1:192.168.13.132/24 kubelet kube-proxy docker flannel etcd
node2:192.168.13.133/24 kubelet kube-proxy docker flannel etcd

1,在master01上創(chuàng)建dashboard

[root@master01 ~]# cd k8s/
[root@master01 k8s]# mkdir dashboard  ##創(chuàng)建工作目錄
[root@master01 k8s]# cd dashboard/
[root@master01 dashboard]# rz -E  ##上傳dashboard的yaml文件
[root@master01 dashboard]# ls
dashboard-configmap.yaml   ##配置應(yīng)用
dashboard-rbac.yaml         ##授權(quán)訪問api
dashboard-service.yaml    ##發(fā)布應(yīng)用
dashboard-controller.yaml  ##控制器
dashboard-secret.yaml       ##安全加密
k8s-admin.yaml     ##生成令牌
[root@master01 dashboard]# kubectl create -f dashboard-rbac.yaml  ##創(chuàng)建api授權(quán)
[root@master01 dashboard]# kubectl create -f dashboard-secret.yaml   ##創(chuàng)建安全加密
[root@master01 dashboard]# kubectl create -f dashboard-configmap.yaml  ##創(chuàng)建配置
[root@master01 dashboard]# kubectl create -f dashboard-controller.yaml   ##創(chuàng)建應(yīng)用
[root@master01 dashboard]# kubectl create -f dashboard-service.yaml   ##創(chuàng)建發(fā)布
[root@master01 dashboard]# kubectl get pods -n kube-system  
##查看創(chuàng)建在指定的kube-system命名空間
NAME                                    READY   STATUS    RESTARTS   AGE
kubernetes-dashboard-65f974f565-xwhcb   1/1     Running   0          2m31s
[root@master01 dashboard]# kubectl get pods,svc -n kube-system  ##查看如何訪問
NAME                                        READY   STATUS    RESTARTS   AGE
pod/kubernetes-dashboard-65f974f565-xwhcb   1/1     Running   0          4m55s

NAME                           TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
service/kubernetes-dashboard   NodePort   10.0.0.119   <none>        443:30001/TCP   4m51s

2,用瀏覽器訪問node節(jié)點(diǎn)ip(Google瀏覽器無法訪問的問題)

##更多工具——開發(fā)者工具——security

Kubernetes集群node節(jié)點(diǎn)的部署

3,進(jìn)行自簽證書

[root@master01 dashboard]# vim dashboard-cert.sh   ##創(chuàng)建證書腳本文件
cat > dashboard-csr.json <<EOF
{
     "CN": "Dashboard",
     "hosts": [],
     "key": {
             "algo": "rsa",
             "size": 2048
     },
     "names": [
             {
                     "C": "CN",
                     "L": "BeiJing",
                     "ST": "BeiJing"
             }
     ]
}
EOF

K8S_CA=$1
cfssl gencert -ca=$K8S_CA/ca.pem -ca-key=$K8S_CA/ca-key.pem -config=$K8S_CA/ca-config.json -profile=kubernetes dashboard-csr.json | cfssljson -bare dashboard
kubectl delete secret kubernetes-dashboard-certs -n kube-system
kubectl create secret generic kubernetes-dashboard-certs --from-file=./ -n kube-system
[root@master01 dashboard]# bash dashboard-cert.sh /root/k8s/k8s-cert/  
##執(zhí)行證書腳本,指定證書的應(yīng)用
[root@master01 dashboard]# ls   ##查看生成的證書
dashboard-cert.sh          dashboard-csr.json   dashboard-secret.yaml
dashboard-configmap.yaml   dashboard-key.pem    dashboard-service.yaml
dashboard-controller.yaml  dashboard.pem        k8s-admin.yaml
dashboard.csr              dashboard-rbac.yaml
[root@master01 dashboard]# vim dashboard-controller.yaml  ##修改應(yīng)用配置文件
 45         args:
 46           # PLATFORM-SPECIFIC ARGS HERE
 47           - --auto-generate-certificates
 48           - --tls-key-file=dashboard-key.pem  ##添加證書文件
 49           - --tls-cert-file=dashboard.pem        ##添加證書文件
 [root@master01 dashboard]# kubectl apply -f dashboard-controller.yaml  ##重新部署

4,重新用瀏覽器訪問node1節(jié)點(diǎn)地址

Kubernetes集群node節(jié)點(diǎn)的部署

5,生成令牌,進(jìn)行使用UI界面


 vim k8s-admin.yaml  ##證書生成的yaml配置文件
 apiVersion: v1
kind: ServiceAccount
metadata:
    name: dashboard-admin
    namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
    name: dashboard-admin
subjects:
    - kind: ServiceAccount
        name: dashboard-admin
        namespace: kube-system
roleRef:
    kind: ClusterRole
    name: cluster-admin
    apiGroup: rbac.authorization.k8s.io

[root@master01 dashboard]# kubectl create -f k8s-admin.yaml  ##生成令牌
[root@master01 dashboard]# kubectl get secret -n kube-system  ##保存令牌
NAME                               TYPE                                  DATA   AGE
dashboard-admin-token-489x2        kubernetes.io/service-account-token   3      2m2s
[root@master01 dashboard]# kubectl describe secret dashboard-admin-token-489x2 -n kube-system
##查看令牌

token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tNDg5eDIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiY2Q2NzQ4NGYtNGJjZi0xMWVhLThkZTAtMDAwYzI5ZjNiNTNiIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.lXmRZS2TSk5HHmXzrjvp8ISj4fna_anekJDCZW5NV7vB45s-IZTq7VLG1qd8MfMP0MCOQgKdE-1ulg9b6ql3a6zbUJe848mk99yVOIwKbZTN2M-SG848ljSAjCt66rUkilbcTqByK719rTLbwTtmibgI7jy1NXeZXp_Q_8QE8aXAfJz1EnxI3kbz7Qr1FetZ1O1hTnzc-hEwCgUOMhMZsheBBry9SahXj-3fYNRyK1MpuhkDleNyjQnuNfdsSmgrJI1HvVNczw_tYNQb1QqpppegAdLNvIArMmIDA15q_vL9Wg7h9nb8Ay3KSss7IgHkqN1YxTNdWZyeMpEt9pPQOw

6,利用令牌進(jìn)行登錄

Kubernetes集群node節(jié)點(diǎn)的部署
##成功訪問到UI界面
Kubernetes集群node節(jié)點(diǎn)的部署


k8s部署全部完成,謝謝閱讀?。?!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI