Table of contents
Virtual network environment preparation
Physical machine NIC static IP setting
Virtual machine NIC configuration
foreword
Through this series of tutorials, Baiyu will teach you to install k8s-1.24.3 based on containerd. This series of tutorials is zero-based. As long as you have a computer, you can build your own k8s environment for testing and learning. It also aims to learn k8s through experiments and practice, first have a perceptual cognition, have an experimental environment, and then further understand the various knowledge points in k8s.
environment
Physical machine configuration: CPU-six-core, 32G memory
Operating system: win10
Virtual machine tools: Hyper-V
Virtual machine operating system: centos7
Virtual machine configuration: CPU-two cores, memory 2G (this configuration is the most basic configuration as a k8s node)
Machine IP allocation
- Physical machine win10: 192.168.137.99
- k8s-master-1_24_3:192.168.137.200
- k8s-node1-1_24_3:192.168.137.201
- k8s-node2-1_24_3:192.168.137.202
Virtual network environment preparation
hypter-y static IP
Create a new virtual switch for internal network use.
Add one more network card to the three virtual machines, and select the newly created static for the virtual switch of the network card
Physical machine NIC static IP setting
Virtual machine NIC configuration
Enter k8s-master-1_24_3
the server command and execute nmtui
the command to configure the network card
After configuring the static IP of the new network card, enter the enable option.
If you enter the option, as shown in the figure, it proves that the network card has been enabled. If it shows Activate , it means that the network card has not been enabled.
k8s-node1-1_24_3
Configure static IP to 192.168.137.201
k8s-node2-1_24_3
Configure static IP as 192.168.137.202
The steps are the same as above.
Test environment network
Use the ping command to determine whether the network between the physical machine and the other three machines are all connected
Test whether the network between the virtual machines is connected.
Initialize server state
To install k8s, we need to initialize the newly installed centos7 environment to facilitate the subsequent installation of k8s.
For some initial configuration, refer to the official website container runtime
I have organized all the configurations to be used into the following scripts, you can just copy them and execute them.
#!/bin/bash
# 关闭防火墙
systemctl stop firewalld && \
systemctl disable firewalld && \
# 关闭 selinux
# 永久关闭(重启生效)
sed -i 's/enforcing/disabled/' /etc/selinux/config && \
# 临时关闭(即刻生效)
setenforce 0 && \
# 关闭swap(k8s禁止虚拟内存以提高性能)
# 永久关闭(重启生效)
sed -ri 's/.*swap.*/#&/' /etc/fstab && \
# 临时关闭(即刻生效)
swapoff -a && \
# 在master添加hosts
cat >> /etc/hosts << EOF
192.168.137.200 k8s-master
192.168.137.201 k8s-node1
192.168.137.202 k8s-node2
EOF
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
# 网桥生效
sysctl --system && \
# 时间同步
yum install ntpdate -y && \
ntpdate time.windows.com
All three virtual machines must execute the above script.
Summarize
This article introduces the configuration of k8s initial experimental environment in detail. The next article will introduce how to install containerd.
written in the back
If you find it useful, please support Siege Lion Baiyu with one button and three consecutive links , and share this article with more friends. Your simple support, my infinite creative power