一、环境预备
1.1服务器预备
服务器
体系 | Debian11 | |
---|---|---|
Cpu | 2/4/8/16 | |
内存 | 4/8/16/32 |
1.2 服务器装置k3s
K3s 供给了一个装置脚本,能够方便的在 systemd 或 openrc 的体系上将其作为服务装置。这个脚本能够在 https://get.k3s.io 获得。要使用这种方法装置 K3s,只需运转以下命令:
curl -sfL https://get.k3s.io | sh -
提示
国内用户,能够使用以下方法加快装置:
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
为方便后续操作
一定要将kube_config_cluster.yml文件内容拷贝到 ~/.kube/config文件中 可不用指定kubeconfig参数
二、rancher装置
添加rancher chart库房
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
创建命名空间
kubectl create namespace cattle-system
装置证书管理
# 如果你手动装置了CRD,而不是在Helm装置命令中添加了`--set installCRDs=true`选项,你应该在晋级Helm chart之前晋级CRD资源。
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml
# 添加 Jetstack Helm 库房
helm repo add jetstack https://charts.jetstack.io
# 更新本地 Helm chart 库房缓存
helm repo update
# 装置 cert-manager Helm chart
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.5.1
装置完 cert-manager 后,你能够通过查看 cert-manager 命名空间中正在运转的 Pod 来验证它是否已正确部署:
kubectl get pods --namespace cert-manager
NAME READY STATUS RESTARTS AGE
cert-manager-5c6866597-zw7kh 1/1 Running 0 2m
cert-manager-cainjector-577f6d9fd7-tr77l 1/1 Running 0 2m
cert-manager-webhook-787858fcdb-nlzsq 1/1 Running 0 2m
根据你挑选的 SSL 选项,通过 Helm 装置 Rancher
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=rancher.phpdoc.net \
--set replicas=3 \
--set ingress.tls.source=letsEncrypt \
--set letsEncrypt.email=30515651@qq.com \
--version 2.5.11
等待 Rancher 运转:
kubectl -n cattle-system rollout status deploy/rancher
Waiting for deployment "rancher" rollout to finish: 0 of 3 updated replicas are available...
deployment "rancher" successfully rolled out