开发者学堂课程【Kubernetes 极速入门:K8S 集群部署_集群软件安装及配置】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/658/detail/10883
K8S 集群部署_集群软件安装及配置
内容介绍
一、软件安装(要点)
二、软件安装需求
一、软件安装(要点)
1.所有 K8s 集群节点均需安装,
2.默认 YUM 源是谷歌,也可以使用阿里云 YUM
二、软件安装需求
Kubeadm 初始化集群、管理集群等,版本为:1.17.2
Kubelet 用于接收 apl-server 指令,对 pod 生命周期进行管理,版本:1.17.2
Kubectl 主要是集群命令行管理工具,版本:1.17.2
Docker-ce 值为18.06.3
谷歌 YUM 源
[kubernetes]
namemKubernetes
baseur1=http3://-e17-x86_64
enabled=1
gpgcheckm1
repo_gpgcheck-1
gpgkey=https://packages.cloud.google.com/yum/doc /yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key- gpg
阿里云 YUM 源
1[kubernetes]
2name=Kubernetes
3baseur1mhttps://mirrors.aliyun.com/kubernetes/yum/repos/kubern etes-e17-x86_64/
4enabled-i
5gpgcheck-m1
6 repo_gpgcheck=i
7apgkeymhttps://mirrors.aliyun.com/kubernetes/yum/doc /yum-key. gpg https://mirrors.a1iyun.com/kubernetes/yum/doc/rpm-package-key. gpg
复制阿里云 YUM 源,粘贴到 YUM 中,在主机中完成安装即可
在主机添加完成后,在etc中输入 yum.repos.d,然后创建一个k8s.repo文件,然后打开这个的文件,将之前复制的内容粘贴。
[ kubernetes]
name-Kubernetes
baseurl-https://mirrors.al1yun.com/Kuberneies/yum/r'eps/nben" -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
完成之后在验证一下 YUM 是否可用,显示为
[root@master1 -]#vim /etc/yum.repos.d/k8s , repo
[ root@master1 -]# yum list 1 grep kubeadm
e Importing GPG key OxA7317BOF:
Userid : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>"Fingerprint: d0bc 747f d8ca f711 7500 d6fa 3746 c208 a731 7b0f
From :: https ://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
kubeadm.x86_64
1.17.2-0 kubernetes
E[ root@master1 -]#Ⅲ
如果存在 grep kubeadm 说明安装好了
将YUM复制到剩下的两个节点当中去例如;
第一个节点
[rootemasterl -]# scp /etc/yom,repos.d/k8s . repo workerl: /etc/yum.repos.d/
The authenticity of host 'worker1 (192.168.216.101)' can 't be established.ECDSAkeyfingerprintis SHA256:grCW1Im50kf13CPMi6ASBcGVZq5Fhp3CaIlhNjsBpsI.ECDSA keyfingerprintis MD5:1c:32:46:35:f9:c2:93:cc:.48:5f:c4:96:c1:2a:4d:1f.Are you sure you want to continue connecting (yes/no)? yes
warning: Permanently added 'worker1,192.168.216.101'(ECDSA) to the list of known hosts.
rootil@worker1's password:
k8s.repo 100% 283235. 2KB/s 00:00
[root6imaster1 ~]# scp /etc/yum.repos.d/k8s . repo worker1:/etc/yum.regos.d/
第二个节点
[root@master1 ~]# scp /etc/yum.repos.d/k8s.repo worker2:/etc/yum.repos.d/The authenticity of host 'worker2 (192.168.216.102) ' can't be established.ECDSA key fingerprint is SHA256:zuky/Yv7woznCDGLBLdPnU6p15260sVpP8shEH3ROIH.ECDSA key fingerprint is MD5:fe:9a:12:c5:ac:ff: a8:54;4a: ae:f4 :ba:40:d1:37:2c.Are you sure you want to continue connecting (yes/no)? yes
Warnina:Permanently addad 'worker2,192.168.216.102' (ECDSA) to the list of known.hosts.
root0worker2'spassword:M
·安装指定版本 kubeadm kubelet kubectl
1[rootexox-]# yum list kubeadm.x86_64 --showduplicates | sort
3[rootexo0x -J]# yum -y insta11 --setopt-obsoletesmO kubeadm-
1.17.2-0 kubeTet-1.17.2-0 kubect1-1.17.2-0
软件设置
1为了实现 docker 使用的 cgroupdrfver 与 kubelet 使用的 cgroup 的一致性,建议修改如下文件内容。
2[rootoxo0K-]#vim jetc/sysconfig/kubelet
3 KuBELET-EXTRA_ARGSm"--cgroup-dr1vermsystemd"-
pomershe11
1.设置为开机自启动即可,由于没有生成配置文件,集群初始化后自动启动
2.[rootexoo-# systemct1 enable kubelet