YAZONG 我的开源

Kubernetes(五)kubernetes-the-hard-way方式(5.1)基础环境准备

  , , ,
0 评论0 浏览

1、基础环境准备

2、系统设置(所有节点)

上述内容同4-1章节。

科学上网不再叙述。

K8S软件包准备

#方式一:现成打包好的直接用
#这里只在node-1执行的
[root@node-1 ~]# tar -zxf kubernetes-v1.20.2.tar.gz 
[root@node-1 ~]# cd kubernetes-v1.20.2
[root@node-1 kubernetes-v1.20.2]# ll
total 473048
-rw-r--r-- 1 root root  17370166 Jul 17  2020 etcd-v3.4.10-linux-amd64.tar.gz
-rwxr-xr-x 1 root root 118132736 Jan 14  2021 kube-apiserver
-rwxr-xr-x 1 root root 112316416 Jan 14  2021 kube-controller-manager
-rwxr-xr-x 1 root root  40230912 Jan 14  2021 kubectl
-rwxr-xr-x 1 root root 114015176 Jan 14  2021 kubelet
-rwxr-xr-x 1 root root  39485440 Jan 14  2021 kube-proxy
-rwxr-xr-x 1 root root  42848256 Jan 14  2021 kube-scheduler
[root@node-1 kubernetes-v1.20.2]# tar -zxf etcd-v3.4.10-linux-amd64.tar.gz 
[root@node-1 kubernetes-v1.20.2]# ll etcd-v3.4.10-linux-amd64
total 40564
drwxr-xr-x 14 630384594 600260513     4096 Jul 17  2020 Documentation
-rwxr-xr-x  1 630384594 600260513 23843808 Jul 17  2020 etcd
-rwxr-xr-x  1 630384594 600260513 17620576 Jul 17  2020 etcdctl
-rw-r--r--  1 630384594 600260513    43094 Jul 17  2020 README-etcdctl.md
-rw-r--r--  1 630384594 600260513     8431 Jul 17  2020 README.md
-rw-r--r--  1 630384594 600260513     7855 Jul 17  2020 READMEv2-etcdctl.md
[root@node-1 kubernetes-v1.20.2]# chmod +x kube*
[root@node-1 kubernetes-v1.20.2]# chmod +x etcd-v3.4.10-linux-amd64/etcd*
[root@node-1 kubernetes-v1.20.2]# ll
[root@node-1 kubernetes-v1.20.2]# ll etcd-v3.4.10-linux-amd64/etcd*
#方式二:google自己下载
# 设定版本号
$ export VERSION=v1.20.2

# 下载master节点组件
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kube-apiserver
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kube-controller-manager
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kube-scheduler
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kubectl

# 下载worker节点组件
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kube-proxy
$ wget https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/linux/amd64/kubelet

# 下载etcd组件
$ wget https://github.com/etcd-io/etcd/releases/download/v3.4.10/etcd-v3.4.10-linux-amd64.tar.gz
$ tar -xvf etcd-v3.4.10-linux-amd64.tar.gz
$ mv etcd-v3.4.10-linux-amd64/etcd* .
$ rm -fr etcd-v3.4.10-linux-amd64*

# 统一修改文件权限为可执行
$ chmod +x kube*

K8S软件包分发

#master节点组件:kube-apiserver、kube-controller-manager、kube-scheduler、kubectl

#worker节点组件:kubelet、kube-proxy

#所有节点:etcd、etcdctl

image.png

# 把master相关组件分发到master节点
[root@node-1 kubernetes-v1.20.2]# MASTERS=(node-1 node-2)
for instance in ${MASTERS[@]}; do
  scp kube-apiserver kube-controller-manager kube-scheduler kubectl root@${instance}:/usr/local/bin/
done
#检查节点分发情况
[root@node-1 kubernetes-v1.20.2]# ll /usr/local/bin/kube*
-rwxr-xr-x 1 root root 118132736 Nov  3 14:28 /usr/local/bin/kube-apiserver
-rwxr-xr-x 1 root root 112316416 Nov  3 14:28 /usr/local/bin/kube-controller-manager
-rwxr-xr-x 1 root root  40230912 Nov  3 14:28 /usr/local/bin/kubectl
-rwxr-xr-x 1 root root  42848256 Nov  3 14:28 /usr/local/bin/kube-scheduler
[root@node-2 ~]# ll /usr/local/bin/kube*
-rwxr-xr-x 1 root root 118132736 Nov  3 14:28 /usr/local/bin/kube-apiserver
-rwxr-xr-x 1 root root 112316416 Nov  3 14:28 /usr/local/bin/kube-controller-manager
-rwxr-xr-x 1 root root  40230912 Nov  3 14:28 /usr/local/bin/kubectl
-rwxr-xr-x 1 root root  42848256 Nov  3 14:28 /usr/local/bin/kube-scheduler
# 把worker先关组件分发到worker节点
[root@node-1 kubernetes-v1.20.2]# WORKERS=(node-2 node-3)
for instance in ${WORKERS[@]}; do
  scp kubelet kube-proxy root@${instance}:/usr/local/bin/
done
#检查节点分发情况
[root@node-2 ~]# ll /usr/local/bin/kube*
-rwxr-xr-x 1 root root 118132736 Nov  3 14:28 /usr/local/bin/kube-apiserver
-rwxr-xr-x 1 root root 112316416 Nov  3 14:28 /usr/local/bin/kube-controller-manager
-rwxr-xr-x 1 root root  40230912 Nov  3 14:28 /usr/local/bin/kubectl
-rwxr-xr-x 1 root root 114015176 Nov  3 14:29 /usr/local/bin/kubelet
-rwxr-xr-x 1 root root  39485440 Nov  3 14:29 /usr/local/bin/kube-proxy
-rwxr-xr-x 1 root root  42848256 Nov  3 14:28 /usr/local/bin/kube-scheduler
[root@node-3 ~]# ll /usr/local/bin/kube*
-rwxr-xr-x 1 root root 114015176 Nov  3 14:29 /usr/local/bin/kubelet
-rwxr-xr-x 1 root root  39485440 Nov  3 14:29 /usr/local/bin/kube-proxy
# 把etcd组件分发到etcd节点
$ ETCDS=(node-1 node-2 node-3)
for instance in ${ETCDS[@]}; do
  scp etcd-v3.4.10-linux-amd64/etcd etcd-v3.4.10-linux-amd64/etcdctl root@${instance}:/usr/local/bin/
done
#检查节点分发情况
[root@node-1 kubernetes-v1.20.2]# ll /usr/local/bin/etcd*
-rwxr-xr-x 1 root root 23843808 Nov  3 14:30 /usr/local/bin/etcd
-rwxr-xr-x 1 root root 17620576 Nov  3 14:30 /usr/local/bin/etcdctl
[root@node-2 ~]# ll /usr/local/bin/etcd*
-rwxr-xr-x 1 root root 23843808 Nov  3 14:30 /usr/local/bin/etcd
-rwxr-xr-x 1 root root 17620576 Nov  3 14:30 /usr/local/bin/etcdctl
[root@node-3 ~]# ll /usr/local/bin/etcd*
-rwxr-xr-x 1 root root 23843808 Nov  3 14:30 /usr/local/bin/etcd
-rwxr-xr-x 1 root root 17620576 Nov  3 14:30 /usr/local/bin/etcdctl

标题:Kubernetes(五)kubernetes-the-hard-way方式(5.1)基础环境准备
作者:yazong
地址:https://blog.llyweb.com/articles/2022/11/03/1667464205165.html