|NO.Z.00026|——————————|^^ 部署 ^^|——|KuberNetes&二進位制部署.V04|5臺Server|---------------------------------------|基礎元件|
阿新 • • 發佈:2022-03-29
[CloudNative:KuberNetes&二進位制部署.V04] [Applications.KuberNetes] [|DevOps|k8s|**5節點**|二進位制1.20|基本元件安裝|——|docker-ce|etcd|kubernetes|git切換分支|]
一、基本元件安裝
### --- docker-ce安裝:Docker安裝 ~~~ # 所有節點安裝Docker-ce 19.03 [root@k8s-master01 ~]# yum install docker-ce-19.03.* -y
### --- 更改docker的啟動引數為systemd
~~~ # 溫馨提示:由於新版kubelet建議使用systemd,所以可以把docker的CgroupDriver改成systemd
[root@k8s-master01 ~]# mkdir /etc/docker
[root@k8s-master01 ~]# cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
~~~ # 所有節點設定開機自啟動Docker: [root@k8s-master01 ~]# systemctl daemon-reload && systemctl enable --now docker
二、基本元件安裝:k8s及etcd
### --- kubernetes版本包下載說明:
~~~ 注意目前版本是1.20.0學員安裝時需要下載最新的1.20.x版本
~~~ https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.20.md
~~~ 開啟頁面後點擊:
### --- 下載k8s及etcd版本包 ~~~ # 下載kubernetes版本包 [[root@k8s-master01 ~]# wget https://dl.k8s.io/v1.20.0/kubernetes-server-linux-amd64.tar.gz
~~~ # 下載etcd版本包
~~~ 以下操作都在master01執行
~~~ 注意目前版本是1.20.0學員安裝時需要下載最新的1.20.x版本:
~~~ https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.20.md
~~~ 開啟頁面後點擊:CHANGELOG——>找到對應版本——>CHANGELOG-1.20.md——>檢視版本
~~~ ——>選擇:Server binaries——>選擇:kubernetes-server-linux-amd64.tar.gz——>END
[root@k8s-master01 ~]# wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
### --- 解壓kubernetes及etcd版本包
~~~ # 解壓kubernetes版本包
[root@k8s-master01 ~]# tar -xf kubernetes-server-linux-amd64.tar.gz --strip-components=3 -C /usr/local/bin kubernetes/server/bin/kube{let,ctl,-apiserver,-controller-manager,-scheduler,-proxy}
~~~ # 解壓etcd版本包
[root@k8s-master01 ~]# tar -zxvf etcd-v3.4.13-linux-amd64.tar.gz --strip-components=1 -C /usr/local/bin etcd-v3.4.13-linux-amd64/etcd{,ctl}
etcd-v3.4.13-linux-amd64/etcdctl
etcd-v3.4.13-linux-amd64/etcd
### --- 版本檢視
~~~ # 檢視kubernetes版本包
[root@k8s-master01 ~]# kubelet --version
Kubernetes v1.20.0
~~~ # 檢視etcd版本包
[root@k8s-master01 ~]# etcdctl version
etcdctl version: 3.4.13
API version: 3.4
### --- 將元件傳送到其它部署節點
~~~ # 定義變數
[root@k8s-master01 ~]# MasterNodes='k8s-master02 k8s-master03'
[root@k8s-master01 ~]# WorkNodes='k8s-node01 k8s-node02'
~~~ # 將元件傳送到其它節點
[root@k8s-master01 ~]# for NODE in $MasterNodes; do echo $NODE; scp /usr/local/bin/kube{let,ctl,-apiserver,-controller-manager,-scheduler,-proxy} $NODE:/usr/local/bin/; scp /usr/local/bin/etcd* $NODE:/usr/local/bin/; done
k8s-node01
kubelet 100% 109MB 66.0MB/s 00:01
kubectl 100% 38MB 48.8MB/s 00:00
kube-apiserver 100% 113MB 48.8MB/s 00:02
kube-controller-manager 100% 108MB 54.1MB/s 00:01
kube-scheduler 100% 42MB 46.3MB/s 00:00
kube-proxy 100% 38MB 29.8MB/s 00:01
etcd 100% 23MB 57.1MB/s 00:00
etcdctl 100% 17MB 43.2MB/s 00:00
k8s-node02
kubelet 100% 109MB 8.4MB/s 00:13
kubectl 100% 38MB 4.8MB/s 00:08
kube-apiserver 100% 113MB 3.9MB/s 00:29
kube-controller-manager 100% 108MB 4.1MB/s 00:26
kube-scheduler 100% 42MB 3.5MB/s 00:12
kube-proxy 100% 38MB 6.3MB/s 00:06
etcd 100% 23MB 4.5MB/s 00:05
etcdctl
~~~ # 將元件傳送到其它節點
[root@k8s-master01 ~]# for NODE in $WorkNodes;do scp /usr/local/bin/kube{let,-proxy} $NODE:/usr/local/bin/; done
kubelet 100% 109MB 54.4MB/s 00:02
kube-proxy 100% 38MB 54.3MB/s 00:00
kubelet 100% 109MB 1.6MB/s 01:06
kube-proxy
三、k8s資源包下載及部署配置
### --- k8s資源包官方地址k8s github : https://github.com/kubernetes/kubernetes/
~~~ 所有節點建立/opt/cni/bin目錄
[root@k8s-master01 ~]# mkdir -p /opt/cni/bin
### --- k8s-master01下下載kubernetes版本包
~~~ 下載版本包
[root@k8s-master01 ~]# cd /root/ ; git clone https://github.com/dotbalo/k8s-ha-install.git
Cloning into 'k8s-ha-install'...
remote: Enumerating objects: 649, done.
remote: Counting objects: 100% (217/217), done.
remote: Compressing objects: 100% (138/138), done.
remote: Total 649 (delta 107), reused 142 (delta 62), pack-reused 432
Receiving objects: 100% (649/649), 19.60 MiB | 6.68 MiB/s, done.
Resolving deltas: 100% (254/254), done.
### --- 切換分支切換到1.20.x分支(其他版本可以切換到其他分支)
~~~ 切換到對應版本包地址下
[root@k8s-master01 ~]# cd k8s-ha-install && git checkout manual-installation-v1.20.x
Already on 'manual-installation-v1.20.x'
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)