title: rancher 安装
tag: [kubernate]
comments: true
参考 https://docs.rancher.cn/docs/rancher2.5/installation/install-rancher-on-k8s/_index
1. 设置 repo
helm repo add rancher-<CHART_REPO> http://rancher-mirror.oss-cn-beijing.aliyuncs.com/server-charts/<CHART_REPO>
替换为 stable
helm repo add rancher-stable http://rancher-mirror.oss-cn-beijing.aliyuncs.com/server-charts/stable
2. 为 Rancher 创建 Namespace
kubectl create namespace cattle-system
3. 选择您的 SSL 选项 (使用自己签发的证书)
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=k3s.stu77.cn \
--set replicas=1 \
--set ingress.tls.source=secret
- 假如出现以下错误:
Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
或者Error: Kubernetes cluster unreachable: the server could not find the requested resource
,
先在 shell 执行export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
(参考 https://blog.csdn.net/varyuan/article/details/112111547)
3.1 自有证书需要添加证书
kubectl -n cattle-system create secret tls tls-rancher-ingress \
--cert=/etc/letsencrypt/live/stu77.cn-0001/fullchain.pem \
--key=/etc/letsencrypt/live/stu77.cn-0001/privkey.pem