移除docker(非必要)

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集群

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

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命令进行查询

kubectl --kubeconfig kube_config_cluster.yml get node
yum install -y kubectl
kubectl get node

安装helm

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

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
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

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部