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
相关推荐
Linux运维老纪2 小时前
DNS缓存详解(DNS Cache Detailed Explanation)
计算机网络·缓存·云原生·容器·kubernetes·云计算·运维开发
JunLan~7 小时前
Docker 部署 GLPI(IT 资产管理软件系统)
运维·docker·容器
青草地溪水旁8 小时前
c++ list的front和pop_front的概念和使用案例
c++·容器·list
元气满满的热码式10 小时前
K8S部署DevOps自动化运维平台
运维·kubernetes·devops
LUCIAZZZ11 小时前
基于Docker以KRaft模式快速部署Kafka
java·运维·spring·docker·容器·kafka
IT艺术家-rookie15 小时前
k8s--部署k8s集群--控制平面节点
容器·kubernetes
康世行16 小时前
Windows环境下MaxKB大模型 Docker部署图文指南
windows·docker·容器
Elastic 中国社区官方博客16 小时前
使用 Ollama 和 Kibana 在本地为 RAG 测试 DeepSeek R1
大数据·数据库·人工智能·elasticsearch·ai·云原生·全文检索
Linux运维老纪1 天前
windows部署deepseek之方法(The Method of Deploying DeepSeek on Windows)
linux·人工智能·分布式·云原生·运维开发·devops
Elastic 中国社区官方博客1 天前
Elastic Cloud Serverless 获得主要合规认证
大数据·数据库·elasticsearch·搜索引擎·云原生·serverless·全文检索