========节点1=====================
==========安装docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo docker run hello-world
=========安装Rancher
mkdir -p /etc/rancher/rke2 ##创建目录
vim /etc/rancher/rke2/config.yaml ##编辑配置文件
token: rke2-create-token ##自定义token
tls-san: 175.24.254.23 ##tls-san参数
system-default-registry: "registry.cn-hangzhou.aliyuncs.com" ##阿里云镜像库地址
curl -sfL https://get.rke2.io | sh -
systemctl start rke2-server.service && systemctl enable rke2-server.service
ln -s /var/lib/rancher/rke2/bin/kubectl /usr/bin/kubectl
ln -s /var/lib/rancher/rke2/bin/crictl /usr/bin/crictl
kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get node
===========节点2
==========安装docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo docker run hello-world
=========安装Rancher
mkdir -p /etc/rancher/rke2 ##创建目录
vim /etc/rancher/rke2/config.yaml ##编辑配置文件
server: https://172.17.0.4:9345 ##第一个节点地址
token: K10c2e42f9f1c7a4c3fbb704bd2b00eecba2bc5969a944c510258f4c4f138523c1a::server:rke2-create-token ##在第一个节点上执行 cat /var/lib/rancher/rke2/server/token
tls-san: 172.17.0.4
system-default-registry: "registry.cn-hangzhou.aliyuncs.com"
curl -sfL https://get.rke2.io | sh -
systemctl start rke2-server.service && systemctl enable rke2-server.service
===========节点3
==========安装docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo docker run hello-world
=========安装Rancher
mkdir -p /etc/rancher/rke2 ##创建目录
vim /etc/rancher/rke2/config.yaml ##编辑配置文件
server: https://172.17.0.4:9345 ##第一个节点地址
token: K10c2e42f9f1c7a4c3fbb704bd2b00eecba2bc5969a944c510258f4c4f138523c1a::server:rke2-create-token ##在第一个节点上执行 cat /var/lib/rancher/rke2/server/token
tls-san: 172.17.0.4
system-default-registry: "registry.cn-hangzhou.aliyuncs.com"
curl -sfL https://get.rke2.io | sh -
systemctl start rke2-server.service && systemctl enable rke2-server.service
=============节点1上检查
==========节点1 安装rancher=======
安装helm
wget https://mirrors.huaweicloud.com/helm/v3.10.0/helm-v3.10.0-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm
helm repo add rancher-latest http://rancher-mirror.oss-cn-beijing.aliyuncs.com/server-charts/latest
创建ns
kubeconfig=/etc/rancher/rke2/rke2.yaml
kubectl --kubeconfig=$kubeconfig create namespace cattle-system
kubeconfig=/etc/rancher/rke2/rke2.yaml
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml
kubectl --kubeconfig=$kubeconfig apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
# 安装 cert-manager Helm Chart
helm --kubeconfig=$kubeconfig install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.7.1
kubectl --kubeconfig=$kubeconfig get pods --namespace cert-manager
kubeconfig=/etc/rancher/rke2/rke2.yaml
helm --kubeconfig=$kubeconfig install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=playground.aicoder.tech \
--set bootstrapPassword=admin \
--set rancherImage=registry.cn-hangzhou.aliyuncs.com/rancher/rancher \
--set systemDefaultRegistry=registry.cn-hangzhou.aliyuncs.com \
--set rancherImageTag=v2.6.8
helm --kubeconfig=$kubeconfig upgrade rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=playground.aicoder.tech \
--set bootstrapPassword=admin \
--set rancherImage=registry.cn-hangzhou.aliyuncs.com/rancher/rancher \
--set systemDefaultRegistry=registry.cn-hangzhou.aliyuncs.com \
--set rancherImageTag=v2.6.8
kubeconfig=/etc/rancher/rke2/rke2.yaml
kubectl --kubeconfig=$kubeconfig -n cattle-system rollout status deploy/rancher
kubeconfig=/etc/rancher/rke2/rke2.yaml
echo https://playground.aicoder.tech/dashboard/?setup=$(kubectl --kubeconfig=$kubeconfig get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
helm --kubeconfig=$kubeconfig upgrade rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=playground.aicoder.tech \
--set bootstrapPassword=admin \
--set rancherImage=registry.cn-hangzhou.aliyuncs.com/rancher/rancher \
--set systemDefaultRegistry=registry.cn-hangzhou.aliyuncs.com \
--set rancherImageTag=v2.6.8
echo https://playground.aicoder.tech/dashboard/?setup=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
密码:~@mt
1.15.23.54
标签:rke2,set,--,com,kubeconfig,rancher,Rancher,K8S,安装 From: https://www.cnblogs.com/littlesuccess/p/16790812.html