systemctl stop firewalld
systemctl disable firewalld
setenforce 0 临时关闭
vi /etc/sysconfig/selinux 永久关闭
改为SELINUX=disabled
2.设置系统参数设置允许路由转发,不对bridge的数据进行处理
创建文件
vi /etc/sysctl.d/k8s.conf
内容如下:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
执行文件
sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
3.kube-proxy开启ipvs的前置条件cat > /etc/sysconfig/modules/ipvs.modules < #!/bin/bash modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack_ipv4 EOF chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4 swapoff -a 临时关闭 vi /etc/fstab 永久关闭 注释掉以下字段 /dev/mapper/cl-swap swap swap defaults 0 0 yum clean all 设置yum安装源 cat < [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF 安装: yum install -y kubelet kubeadm kubectl kubeadm init --kubernetes-version=1.23.5 --apiserver-advertise-address=192.168.56.11 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16 kubeadm join 192.168.56.11:6443 --token kmdpq4.cak6l3nytd76vbao --discovery-token-ca-cert-hash sha256:71e0a6497b58e50049dcc54937a9b713b0ec596af5cfe771d950a41260ee2387 kubernetes初始化报错Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.的解决办法 k8s使用kubeadm初始化报如下错误: [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused. 原因: docker的cgroup驱动程序默认设置为system。默认情况下Kubernetes cgroup为systemd,我们需要更改Docker cgroup驱动, 解决办法: kubeadm reset vim /etc/docker/daemon.json { "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] } [root@master01 ~]# systemctl daemon-reload systemctl restart docker



