基本环境配置(全部节点)

192.168.0.1 k8s1 #ip的话写自己公网的地址,名字随意,k8s1作为master节点,其余worker节点

192.168.0.2 k8s2

192.168.0.3 k8s3

hostnamectl set-hostname k8s1 #改主机名
hostnamectl set-hostname k8s2
hostnamectl set-hostname k8s3

tee /etc/hosts <<-EOF     #host 映射
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.1 k8s1
192.168.0.2 k8s2
192.168.0.3 k8s3
EOF

ssh-keygen #免密登录,一直回车
ssh-copy-id k8s1
ssh-copy-id k8s2
ssh-copy-id k8s3

swapoff -a #关闭交换分区swap,临时
sed -ri 's/.*swap.*/#&/' /etc/fstab #永久

 万用命令

systemctl disable firewalld #防火墙

setenforce 0 #selinux 临时
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config #永久

timedatectl set-timezone Asia/Shanghai #时区

yum makecache fast   #时间同步
yum -y install chrony
systemctl enable chronyd

yum -y install epel-release #下载常用软件

sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
    -e 's!http://mirrors!https://mirrors!g' \
    -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

yum -y install net-tools nmap-ncat sysstat git ipset ipvsadm bash-completion wget unzip lrzsz lsof vim

************网络映射************

cat > /etc/sysconfig/network-scripts/ifcfg-eth0:1 <<EOF#虚拟网卡
BOOTPROTO=static
DEVICE=eth0:1
IPADDR=192.168.0.1  #公网地址
PREFIX=32
TYPE=Ethernet
USERCTL=no
ONBOOT=yes
EOF

systemctl restart network#重启网卡
ip addr

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐