K8s Fedora单机版

文章目录

禁用防火墙

shell 复制代码
systemctl stop firewalld.service & systemctl disable firewalld.service

禁用交换分区

shell 复制代码
sysctl vm.swappiness=0 & sysctl -p
systemctl stop swap-create@zram0
yum remove -y zram-generator-defaults

禁用 SELinux

shell 复制代码
sudo setenforce 0 & sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

安装 iptables

shell 复制代码
yum install -y iptables iproute-tc

允许 iptables 检查桥接流量

shell 复制代码
cat <<EOF | tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

cat <<EOF | tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

sysctl --system

添加镜像源

shell 复制代码
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.31/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF

安装 crio kubelet kubeadm kubectl

建议用crio作为容器运行时,containerd网络问题太麻烦

shell 复制代码
yum install -y crio kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable --now crio & systemctl enable --now kubelet & yum clean all

重载沙箱(pause)镜像

shell 复制代码
sed -i "s/# pause_image = .*/pause_image = \"registry.aliyuncs.com\/google_containers\/pause:3.10\"/g" /etc/crio/crio.conf

配置国内镜像地址

shell 复制代码
vi /etc/containers/registries.conf
conf 复制代码
unqualified-search-registries = ["docker.m.daocloud.io", "docker.io", "k8s.gcr.io", "registry.k8s.io", "registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org"]

[[registry]]
prefix = "docker.io"
location = "docker.m.daocloud.io"

[[registry]]
prefix = "*registry.k8s.io"
location = "registry.aliyuncs.com/google_containers"

[[registry]]
prefix = "*.gcr.io"
location = "docker.m.daocloud.io"

[[registry]]
prefix = "registry.centos.org"
location = "docker.m.daocloud.io"

初始化集群

shell 复制代码
kubeadm init --pod-network-cidr=192.168.56.101/24 --apiserver-advertise-address=192.168.56.101 --apiserver-cert-extra-sans=192.168.56.101 --cri-socket=unix:///var/run/crio/crio.sock --image-repository=registry.aliyuncs.com/google_containers

复制配置文件使kubectl可用

非root用户

shell 复制代码
mkdir -p $HOME/.kube & sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config & sudo chown $(id -u):$(id -g) $HOME/.kube/config

root用户

shell 复制代码
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile & source ~/.bash_profile

查看节点状态

shell 复制代码
kubectl describe node

设置节点可以调度

单节点master默认不可被调度

shell 复制代码
kubectl taint nodes <node-name> node-role.kubernetes.io/control-plane:NoSchedule-
相关推荐
drebander5 小时前
Docker 安全基础:权限、用户、隔离机制
安全·docker·容器
Marcel1116 小时前
WSL2使用Kind创建K8S集群时出现IPV6网络创建失败
云原生·kubernetes·kind
柳鲲鹏8 小时前
docker push镜像到阿里云
阿里云·docker·容器
猪萌萌10 小时前
关于如何利用群晖Docker搭建Project Zomboid(僵尸毁灭工程)私人服务器-保姆级教程
服务器·docker·容器·僵尸世界大战·游戏服务器搭建
剩下了什么10 小时前
统信服务器操作系统V20 1070A 安装docker新版本26.1.4
运维·docker·容器
呱牛do it11 小时前
【系列专栏】银行IT的云原生架构-云单元架构 12
云原生·金融·架构
zxzy_org11 小时前
轻松上手:2025年微服务教程
算法·微服务·云原生·架构
格桑阿sir13 小时前
Kubernetes控制平面组件:etcd(二)
kubernetes·etcd·raft·mvcc·boltdb·watch机制·treeindex
安全检测中14 小时前
关于docker及容器的了解学习记录
学习·docker·容器
power-辰南14 小时前
微服务线上发布稳定性解决方案
微服务·云原生·架构·无损上线·无损下线