基于centos7安装k8s集群之环境配置
程序员文章站
2022-03-07 11:30:24
...
[[email protected] yum.repos.d]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] yum.repos.d]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[[email protected] yum.repos.d]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Nov 1 10:38:05 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=f3e48a9a-ccba-47f6-95eb-060064c3efcc /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
[[email protected] ~]# timedatectl set-timezone Asia/Shanghai
[[email protected] ~]# chronyc -a makestep
200 OK
[[email protected] ~]# cat /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
[[email protected] ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
[[email protected] ~]# cat > /etc/yum.repos.d/kubernetes.repo << EOF
> [kubernetes]
> name=Kubernetes
> baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
> 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
> EOF
[[email protected] ~]# yum -y install ipvsadm ipset sysstat conntrack libseccomp
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
kubernetes/signature | 844 B 00:00:00
从 https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg 检索**
导入 GPG key 0x307EA071:
用户ID : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2021-03-01-08_01_09.pub)"
指纹 : 7f92 e05b 3109 3bef 5a3c 2d38 feea 9169 307e a071
来自 : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
从 https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg 检索**
kubernetes/signature | 1.4 kB 00:00:00 !!!
kubernetes/primary | 99 kB 00:00:00
kubernetes 727/727
软件包 ipset-7.1-1.el7.x86_64 已安装并且是最新版本
软件包 libseccomp-2.3.1-4.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 conntrack-tools.x86_64.0.1.4.4-7.el7 将被 安装
--> 正在处理依赖关系 libnetfilter_cttimeout.so.1(LIBNETFILTER_CTTIMEOUT_1.1)(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
--> 正在处理依赖关系 libnetfilter_cttimeout.so.1(LIBNETFILTER_CTTIMEOUT_1.0)(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
--> 正在处理依赖关系 libnetfilter_cthelper.so.0(LIBNETFILTER_CTHELPER_1.0)(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
--> 正在处理依赖关系 libnetfilter_queue.so.1()(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
--> 正在处理依赖关系 libnetfilter_cttimeout.so.1()(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
--> 正在处理依赖关系 libnetfilter_cthelper.so.0()(64bit),它被软件包 conntrack-tools-1.4.4-7.el7.x86_64 需要
---> 软件包 ipvsadm.x86_64.0.1.27-8.el7 将被 安装
---> 软件包 sysstat.x86_64.0.10.1.5-19.el7 将被 安装
--> 正在处理依赖关系 libsensors.so.4()(64bit),它被软件包 sysstat-10.1.5-19.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libnetfilter_cthelper.x86_64.0.1.0.0-11.el7 将被 安装
---> 软件包 libnetfilter_cttimeout.x86_64.0.1.0.0-7.el7 将被 安装
---> 软件包 libnetfilter_queue.x86_64.0.1.0.2-2.el7_2 将被 安装
---> 软件包 lm_sensors-libs.x86_64.0.3.4.0-8.20160601gitf9185e5.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================================================
正在安装:
conntrack-tools x86_64 1.4.4-7.el7 base 187 k
ipvsadm x86_64 1.27-8.el7 base 45 k
sysstat x86_64 10.1.5-19.el7 base 315 k
为依赖而安装:
libnetfilter_cthelper x86_64 1.0.0-11.el7 base 18 k
libnetfilter_cttimeout x86_64 1.0.0-7.el7 base 18 k
libnetfilter_queue x86_64 1.0.2-2.el7_2 base 23 k
lm_sensors-libs x86_64 3.4.0-8.20160601gitf9185e5.el7 base 42 k
事务概要
=================================================================================================================================================================================================
安装 3 软件包 (+4 依赖软件包)
总下载量:647 k
安装大小:1.9 M
Downloading packages:
(1/7): ipvsadm-1.27-8.el7.x86_64.rpm | 45 kB 00:00:00
(2/7): conntrack-tools-1.4.4-7.el7.x86_64.rpm | 187 kB 00:00:00
(3/7): libnetfilter_cthelper-1.0.0-11.el7.x86_64.rpm | 18 kB 00:00:00
(4/7): libnetfilter_cttimeout-1.0.0-7.el7.x86_64.rpm | 18 kB 00:00:00
(5/7): lm_sensors-libs-3.4.0-8.20160601gitf9185e5.el7.x86_64.rpm | 42 kB 00:00:00
(6/7): libnetfilter_queue-1.0.2-2.el7_2.x86_64.rpm | 23 kB 00:00:00
(7/7): sysstat-10.1.5-19.el7.x86_64.rpm | 315 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 847 kB/s | 647 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libnetfilter_cthelper-1.0.0-11.el7.x86_64 1/7
正在安装 : lm_sensors-libs-3.4.0-8.20160601gitf9185e5.el7.x86_64 2/7
正在安装 : libnetfilter_cttimeout-1.0.0-7.el7.x86_64 3/7
正在安装 : libnetfilter_queue-1.0.2-2.el7_2.x86_64 4/7
正在安装 : conntrack-tools-1.4.4-7.el7.x86_64 5/7
正在安装 : sysstat-10.1.5-19.el7.x86_64 6/7
正在安装 : ipvsadm-1.27-8.el7.x86_64 7/7
验证中 : sysstat-10.1.5-19.el7.x86_64 1/7
验证中 : conntrack-tools-1.4.4-7.el7.x86_64 2/7
验证中 : libnetfilter_queue-1.0.2-2.el7_2.x86_64 3/7
验证中 : ipvsadm-1.27-8.el7.x86_64 4/7
验证中 : libnetfilter_cttimeout-1.0.0-7.el7.x86_64 5/7
验证中 : lm_sensors-libs-3.4.0-8.20160601gitf9185e5.el7.x86_64 6/7
验证中 : libnetfilter_cthelper-1.0.0-11.el7.x86_64 7/7
已安装:
conntrack-tools.x86_64 0:1.4.4-7.el7 ipvsadm.x86_64 0:1.27-8.el7 sysstat.x86_64 0:10.1.5-19.el7
作为依赖被安装:
libnetfilter_cthelper.x86_64 0:1.0.0-11.el7 libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7 libnetfilter_queue.x86_64 0:1.0.2-2.el7_2 lm_sensors-libs.x86_64 0:3.4.0-8.20160601gitf9185e5.el7
完毕!
[[email protected] ~]# cat > /etc/sysconfig/modules/ipvs.modules <<EOF
> #!/bin/sh
> modprobe -- ip_vs
> modprobe -- ip_vs_rr
> modprobe -- ip_vs_wrr
> modprobe -- ip_vs_sh
> modprobe -- nf_conntrack_ipv4
> EOF
[[email protected] ~]# chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
nf_conntrack_ipv4 15053 0
nf_defrag_ipv4 12729 1 nf_conntrack_ipv4
ip_vs_sh 12688 0
ip_vs_wrr 12697 0
ip_vs_rr 12600 0
ip_vs 145458 6 ip_vs_rr,ip_vs_sh,ip_vs_wrr
nf_conntrack 139264 2 ip_vs,nf_conntrack_ipv4
libcrc32c 12644 3 xfs,ip_vs,nf_conntrack