真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

K8S單master部署三:APIserver+Contro

以下所有操作均在master端進(jìn)行

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供大寧網(wǎng)站建設(shè)、大寧做網(wǎng)站、大寧網(wǎng)站設(shè)計(jì)、大寧網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、大寧企業(yè)網(wǎng)站模板建站服務(wù),10多年大寧做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。


服務(wù)器角色分配

角色地址安裝組件
master 192.168.142.220 kube-apiserver kube-controller-manager kube-scheduler etcd
node1 192.168.142.136 kubelet kube-proxy docker flannel etcd
node2 192.168.142.132 kubelet kube-proxy docker flannel etcd

一、APIserver服務(wù)部署

建立apiserver安裝站點(diǎn)

[root@master k8s]# pwd
/k8s
[root@master k8s]# mkdir apiserver
[root@master k8s]# cd apiserver/

建立ca證書(注意路徑問(wèn)題?。。?/h4>
//定義ca證書,生成ca證書配置文件
[root@master apiserver]# cat > ca-config.json < ca-csr.json << EOF
{
    "CN": "kubernetes",
    "key": {
         "algo": "rsa",
         "size": 2048
    },
    "names": [
       {
              "C": "CN",
              "L": "Beijing",
              "ST": "Beijing",
              "O": "k8s",
              "OU": "System"
       }
    ]
}
EOF

//證書簽名(生成ca.pem ca-key.pem)
[root@master apiserver]# cfssl gencert -initca ca-csr.json | cfssljson -bare ca -

建立apiserver通信證書

//定義apiserver證書,生成apiserver證書配置文件
[root@master apiserver]# cat > server-csr.json <負(fù)載均衡(master)
      "192.168.142.140",  //lb (backup)
      "kubernetes",
      "kubernetes.default",
      "kubernetes.default.svc",
      "kubernetes.default.svc.cluster",
      "kubernetes.default.svc.cluster.local"
    ],
    "key": {
        "algo": "rsa",
        "size": 2048
    },
    "names": [
        {
            "C": "CN",
            "L": "BeiJing",
            "ST": "BeiJing",
            "O": "k8s",
            "OU": "System"
        }
    ]
}
EOF

//證書簽名(生成server.pem server-key.pem)
[root@master apiserver]# cfssl gencert -ca=ca.pem \
-ca-key=ca-key.pem \
-config=ca-config.json \
-profile=kubernetes server-csr.json | cfssljson -bare server

建立admin證書

[root@master apiserver]# cat > admin-csr.json <

建立kube-proxy證書

[root@master apiserver]# cat > kube-proxy-csr.json <

總共應(yīng)該生成8個(gè)證書

[root@master apiserver]# ls *.pem
admin-key.pem  ca-key.pem  kube-proxy-key.pem  server-key.pem
admin.pem      ca.pem      kube-proxy.pem      server.pem

復(fù)制啟動(dòng)命令

//建立存放站點(diǎn)
[root@master apiserver]# mkdir -p /opt/kubernetes/{bin,ssl,cfg}
[root@master apiserver]# cp -p *.pem /opt/kubernetes/ssl/

//復(fù)制啟動(dòng)腳本
[root@master k8s]# tar zxvf kubernetes-server-linux-amd64.tar.gz
[root@master k8s]# cd kubernetes/server/bin/
[root@master bin]# cp -p kube-apiserver kubectl /opt/kubernetes/bin/

創(chuàng)建token文件

[root@master bin]# cd /opt/kubernetes/cfg

//生成隨機(jī)的令牌
[root@master cfg]# export BOOTSTRAP_TOKEN=$(head -c 16 /dev/urandom | od -An -t x | tr -d ' ')
[root@master cfg]# cat > token.csv << EOF
${BOOTSTRAP_TOKEN},kubelet-bootstrap,10001,"system:kubelet-bootstrap"
EOF

創(chuàng)建apiserver啟動(dòng)腳本

[root@master cfg]# vim /usr/lib/systemd/system/kube-apiserver.service
//手動(dòng)進(jìn)行編寫
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes

[Service]
EnvironmentFile=/opt/kubernetes/cfg/kube-apiserver
ExecStart=/opt/kubernetes/bin/kube-apiserver $KUBE_APISERVER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target

//提權(quán)方便識(shí)別
[root@master cfg]# chmod +x /usr/lib/systemd/system/kube-apiserver.service

創(chuàng)建apiserver配置文件

[root@master ssl]# vim /opt/kubernetes/cfg/kube-apiserver
//進(jìn)行手工編寫,注意IP地址的變更
KUBE_APISERVER_OPTS="--logtostderr=true \
--v=4 \
--etcd-servers=https://192.168.142.220:2379,https://192.168.142.136:2379,https://192.168.142.132:2379 \
--bind-address=192.168.142.220 \
--secure-port=6443 \
--advertise-address=192.168.142.220 \
--allow-privileged=true \
--service-cluster-ip-range=10.0.0.0/24 \
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,NodeRestriction \
--authorization-mode=RBAC,Node \
--kubelet-https=true \
--enable-bootstrap-token-auth \
--token-auth-file=/opt/kubernetes/cfg/token.csv \
--service-node-port-range=30000-50000 \
--tls-cert-file=/opt/kubernetes/ssl/server.pem  \
--tls-private-key-file=/opt/kubernetes/ssl/server-key.pem \
--client-ca-file=/opt/kubernetes/ssl/ca.pem \
--service-account-key-file=/opt/kubernetes/ssl/ca-key.pem \
--etcd-cafile=/opt/etcd/ssl/ca.pem \
--etcd-certfile=/opt/etcd/ssl/server.pem \
--etcd-keyfile=/opt/etcd/ssl/server-key.pem"

[root@master ssl]# mkdir -p /var/log/kubernetes/apiserver

apiserver服務(wù)啟動(dòng)

[root@master cfg]# systemctl daemon-reload
[root@master cfg]# systemctl start kube-apiserver
[root@master cfg]# systemctl status kube-apiserver
[root@master cfg]# systemctl enable kube-apiserver

檢查服務(wù)啟動(dòng)情況

[root@master bin]# netstat -atnp | egrep "(6443|8080)"      
//6443為http使用端口;8080位https使用端口
tcp        0      0 192.168.142.220:6443    0.0.0.0:*               LISTEN      12898/kube-apiserve
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      12898/kube-apiserve
tcp        0      0 192.168.142.220:6443    192.168.142.220:60052   ESTABLISHED 12898/kube-apiserve
tcp        0      0 192.168.142.220:60052   192.168.142.220:6443    ESTABLISHED 12898/kube-apiserve

K8S單master部署三:APIserver+Contro


二、Controller-Manager服務(wù)部署

移動(dòng)控制命令

[root@master bin]# pwd
/k8s/kubernetes/server/bin
//移動(dòng)腳本
[root@master bin]# cp -p kube-controller-manager /opt/kubernetes/bin/

編寫kube-controller-manager配置文件

[root@master bin]# cat </opt/kubernetes/cfg/kube-controller-manager
KUBE_CONTROLLER_MANAGER_OPTS="--logtostderr=true \
--v=4 \
--master=127.0.0.1:8080 \
--leader-elect=true \
--address=127.0.0.1 \
--service-cluster-ip-range=10.0.0.0/24 \
--cluster-name=kubernetes \
--cluster-signing-cert-file=/opt/kubernetes/ssl/ca.pem \
--cluster-signing-key-file=/opt/kubernetes/ssl/ca-key.pem  \
--root-ca-file=/opt/kubernetes/ssl/ca.pem \
--service-account-private-key-file=/opt/kubernetes/ssl/ca-key.pem"

EOF

編寫kube-controller-manager啟動(dòng)腳本

[root@master bin]# cat </usr/lib/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/kubernetes/kubernetes

[Service]
EnvironmentFile=/opt/kubernetes/cfg/kube-controller-manager
ExecStart=/opt/kubernetes/bin/kube-controller-manager \$KUBE_CONTROLLER_MANAGER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

啟動(dòng)服務(wù)

//提權(quán)并啟動(dòng)
[root@master cfg]# chmod +x /usr/lib/systemd/system/kube-controller-manager.service
[root@master cfg]# systemctl start kube-controller-manager
[root@master cfg]# systemctl status kube-controller-manager
[root@master cfg]# systemctl enable kube-controller-manager

查看服務(wù)啟動(dòng)情況

[root@master bin]# netstat -atnp | grep kube-controll
tcp        0      0 127.0.0.1:10252         0.0.0.0:*               LISTEN      12964/kube-controll
tcp6       0      0 :::10257                :::*                    LISTEN      12964/kube-controll

K8S單master部署三:APIserver+Contro


三、Scheruler服務(wù)部署

移動(dòng)控制命令

[root@master bin]# pwd
/k8s/kubernetes/server/bin
//移動(dòng)腳本
[root@master bin]# cp -p kube-scheduler /opt/kubernetes/bin/

編寫配置文件

[root@master bin]# cat </opt/kubernetes/cfg/kube-scheduler
KUBE_SCHEDULER_OPTS="--logtostderr=true \
--v=4 \
--master=127.0.0.1:8080 \
--leader-elect"
EOF

編寫啟動(dòng)腳本

[root@master bin]# cat </usr/lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kube-scheduler
ExecStart=/opt/kubernetes/bin/kube-scheduler \$KUBE_SCHEDULER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

開(kāi)啟服務(wù)

[root@master bin]# chmod +x /usr/lib/systemd/system/kube-scheduler.service
[root@master bin]# systemctl daemon-reload
[root@master bin]# systemctl start kube-scheduler
[root@master bin]# systemctl status kube-scheduler
[root@master bin]# systemctl enable kube-scheduler

查看服務(wù)啟動(dòng)情況

[root@master bin]# netstat -atnp | grep schedule
tcp6       0      0 :::10251                :::*                    LISTEN

K8S單master部署三:APIserver+Contro


以上,就是master節(jié)點(diǎn)上需要部署的所有服務(wù)的全部部署過(guò)程。

//查看master節(jié)點(diǎn)狀態(tài)
[root@master bin]# /opt/kubernetes/bin/kubectl get cs
//如果成功則應(yīng)該全部為healthy
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health":"true"}
etcd-1               Healthy   {"health":"true"}
etcd-2               Healthy   {"health":"true"}

未完待續(xù)~~~


新聞標(biāo)題:K8S單master部署三:APIserver+Contro
網(wǎng)頁(yè)URL:http://weahome.cn/article/pghjsi.html

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部