
目标
本文介绍一下k8s 的裸机安装(Bare Metal),操作环境为 VMware® Workstation 下的虚拟机 Debain 11 系统
目标是在三台Debain 11 服务器上安装一个最小化的Kubernetes 集群
主机名 |
作用 |
IP |
|
|
k8s-cm-master-01 |
master节点 |
192.168.227.180 |
|
|
k8s-cm-worker-01 |
工作节点1 |
192.168.227.183 |
|
|
k8s-cm-worker-02 |
工作节点2 |
192.168.227.184 |
|
|
准备工作
服务器通用配置
修改主机名
1 2 3 4 5 6 7 8 9 10
| hostnamectl set-hostname k8s-cm-master-01
hostnamectl set-hostname k8s-cm-worker-01
hostnamectl set-hostname k8s-cm-worker-02
hostname
|
设置静态IP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| nano /etc/network/interfaces
iface ens33 inet static
address 192.168.227.180
netmask 255.255.255.0
gateway 192.168.227.2
|
修改hosts 文件
1 2 3 4 5
| nano /etc/hosts
192.168.227.180 k8s-cm-master-01 192.168.227.183 k8s-cm-worker-01 192.168.227.184 k8s-cm-worker-02
|
禁用交换分区
1 2 3 4
| swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| 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 ———————————————— 版权声明:本文为CSDN博主「大能嘚吧嘚」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_30818545/article/details/127036230
kubeadm join 192.168.227.180:6443 --token j2nn1t.t6708xt4gwhrw80s \ --discovery-token-ca-cert-hash sha256:513e71d412614fb56c351993abaafc747fc7279d0e3903ebf0a9649bd5f26c2dysctl.d/k8s.conf net.bridge.bridge-nf-call-iptables=1 net.bridge.bridge-nf-call-ip6tables=1 net.ipv4.ip_forward=1 EOF
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
sudo kubeadm init \ --kubernetes-version v1.26.0 \ --image-repository registry.aliyuncs.com/google_containers \ --apiserver-advertise-address 192.168.227.180 \ --service-cidr 10.245.0.0/12 \ --pod-network-cidr 10.244.0.0/16
kubeadm join 192.168.227.180:6443 --token j2nn1t.t6708xt4gwhrw80s \ --discovery-token-ca-cert-hash sha256:513e71d412614fb56c351993abaafc747fc7279d0e3903ebf0a9649bd5f26c2d
|