RKE部署k8s

移除docker(非必要)

bash 复制代码
rm -rf /etc/docker
rm -rf /run/docker
rm -rf /var/lib/dockershim
rm -rf /var/lib/docker
yum list installed | grep docker
yum remove ***

rke部署k8s集群

bash 复制代码
cat > /etc/sysctl.conf << EFO
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EFO
modprobe br_netfilter
sysctl -p
yum-config-manager  --add-repo  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-20.10.9-3.el7
useradd rke && usermod -aG docker rke
./rke_linux-amd64 config --name cluster.yml
./rke_linux-amd64 up

如果需要增加node节点或者etcd节点,只需要更改cluster.yml后rke up --update-only即可

安装kubectl

bash 复制代码
cat > /etc/yum.repos.d/kubenetes.repo <<EOF

[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1 
EOF

安装成功之后会在当前目录生成kube_config_cluster.yml文件,此为k8s的kube_config文件,需要配置kubectl默认读取文件才可执行kubectl命令进行查询

bash 复制代码
kubectl --kubeconfig kube_config_cluster.yml get node
bash 复制代码
yum install -y kubectl
kubectl get node

安装helm

bash 复制代码
wget https://get.helm.sh/helm-v3.11.3-linux-amd64.tar.gz
cd linux-amd64
cp helm /usr/bin/

新增节点

复制代码
更改文件并只更新即可
./rke_linux-amd64 up --update-only

安装rancher

bash 复制代码
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest

kubectl create namespace cattle-system

kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.crds.yaml

helm repo add jetstack https://charts.jetstack.io

helm repo update

helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.11.0
bash 复制代码
helm install rancher rancher-latest/rancher \
  --namespace cattle-system \
  --set hostname=<IP_OF_LINUX_NODE>.sslip.io \
  --set replicas=1 \
  --set bootstrapPassword=<PASSWORD_FOR_RANCHER_ADMIN>

此处密码最少12个字符

FAQ

如果出现错误Error: INSTALLATION FAILED: execution error at (rancher/templates/validate-psp-install.yaml:4:5): The target cluster does not have the PodSecurityPolicy API resource. Please disable PSPs in this chart before proceeding.

则在install的时候加上--set global.cattle.psp.enabled=false选项

FATA[0001] Cluster must have at least one etcd plane host: failed to connect to the following etcd host(s) []

复制代码
yum update openssh -y
vim /etc/ssh/sshd_config
	AllowTcpForwarding yes
相关推荐
tonngw6 小时前
【Mac 从 0 到 1 保姆级配置教程 16】- Docker 快速安装配置、常用命令以及实际项目演示
macos·docker·容器·开源·github·docker desktop·orbstack
Chan169 小时前
【 SpringCloud | 微服务 MQ基础 】
java·spring·spring cloud·微服务·云原生·rabbitmq
2201_7611990410 小时前
k8s4部署
云原生·容器·kubernetes
慌ZHANG10 小时前
云原生技术驱动 IT 架构现代化转型:企业实践与落地策略全解
云原生
小柏ぁ10 小时前
calico/node is not ready: BIRD is not ready: BGP not established with xxx
运维·docker·kubernetes
三劫散仙11 小时前
kubernetes jenkins pipeline优化拉取大仓库性能指定分支+深度
容器·kubernetes·jenkins
西京刀客12 小时前
k8s热更新-subPath 不支持热更新
云原生·容器·kubernetes·configmap·subpath
weixin_4349362812 小时前
k8S 命令
linux·容器·kubernetes
nuczzz14 小时前
GPU虚拟化
docker·kubernetes·k8s·gpu·nvidia
Johny_Zhao15 小时前
2025年6月Docker镜像加速失效终极解决方案
linux·网络·网络安全·docker·信息安全·kubernetes·云计算·containerd·yum源·系统运维