新 Rancher 安装:等待 Kubernetes API 可用

新 Rancher 安装:等待 Kubernetes API 可用

在我的家庭实验室中,旧的 Rancher 安装(之前一直运行良好,直到出现问题)出现连接问题后,我决定从头开始在 k3s(在 Ubuntu 服务器上运行)上重新安装我的单节点 Rancher,希望这是最简单的方法,但它仍然不起作用。

管理界面无法访问,对配置域的任何请求都超时(我之前遇到过同样的问题)。因此,以下是我设置它时使用的所有步骤:

  • 卸载k3s:/usr/local/bin/k3s-uninstall.sh
  • 重新安装支持的 k3s 版本:curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.25.11+k3s1 sh -s - server --cluster-init
  • 添加 Helm 图表:helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
  • 复制 k3s 配置以便能够运行kubectl命令而不是sudo k3s kubectlsudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config && sudo chown aalex:aalex ~/.kube/config
  • 创建cattle-system命名空间: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=rancher.mydomain.tld --set replicas=1 --set bootstrapPassword=password

然后,这表明在几分钟内,Rancher 后端应该可以访问。我已将 DNS 条目配置为指向我的公共 IP 地址,并将端口 80、443 和 32400 转发到 ubuntu 服务器,因此在入口端一切都应该正常工作。我怀疑问题出在内部,因为当我运行

kubectl get pods --all-namespaces
NAMESPACE       NAME                                       READY   STATUS      RESTARTS   AGE
cattle-system   helm-operation-2786k                       1/2     Error       0          30m
cattle-system   helm-operation-2bvsk                       1/2     Error       0          20m
cattle-system   helm-operation-2kbjh                       1/2     Error       0          34m
cattle-system   helm-operation-2szb7                       1/2     Error       0          17m
cattle-system   helm-operation-5bksl                       1/2     Error       0          39m
cattle-system   helm-operation-5rx7n                       1/2     Error       0          21m
cattle-system   helm-operation-75cwd                       2/2     Running     0          4m3s
cattle-system   helm-operation-7t5g8                       2/2     Running     0          8m16s
cattle-system   helm-operation-8dkxf                       1/2     Error       0          24m
cattle-system   helm-operation-9jpts                       2/2     Running     0          9m19s
cattle-system   helm-operation-dvg87                       1/2     Error       0          11m
cattle-system   helm-operation-gbv8w                       1/2     Error       0          13m
cattle-system   helm-operation-hql8h                       1/2     Error       0          10m
cattle-system   helm-operation-k4pcm                       1/2     Error       0          28m
cattle-system   helm-operation-kh7kf                       1/2     Error       0          31m
cattle-system   helm-operation-ldm9n                       1/2     Error       0          15m
cattle-system   helm-operation-lf7zt                       1/2     Error       0          26m
cattle-system   helm-operation-p9kmb                       1/2     Error       0          18m
cattle-system   helm-operation-ppmhg                       1/2     Error       0          38m
cattle-system   helm-operation-pz6rd                       1/2     Error       0          14m
cattle-system   helm-operation-q7f42                       1/2     Error       0          19m
cattle-system   helm-operation-qhzzn                       1/2     Error       0          35m
cattle-system   helm-operation-qkffm                       2/2     Running     0          5m6s
cattle-system   helm-operation-qlh5q                       2/2     Running     0          116s
cattle-system   helm-operation-r5vgm                       2/2     Running     0          6m10s
cattle-system   helm-operation-r8w2t                       2/2     Running     0          54s
cattle-system   helm-operation-rwrcn                       1/2     Error       0          27m
cattle-system   helm-operation-s4xgh                       1/2     Error       0          12m
cattle-system   helm-operation-sl8s2                       1/2     Error       0          25m
cattle-system   helm-operation-sptzf                       1/2     Error       0          36m
cattle-system   helm-operation-vcxsq                       1/2     Error       0          16m
cattle-system   helm-operation-vwz4t                       2/2     Running     0          3m
cattle-system   helm-operation-x2w9x                       1/2     Error       0          32m
cattle-system   helm-operation-x69qf                       1/2     Error       0          33m
cattle-system   helm-operation-x95fc                       1/2     Error       0          22m
cattle-system   helm-operation-z8z67                       1/2     Error       0          29m
cattle-system   helm-operation-zk5h9                       2/2     Running     0          7m13s
cattle-system   helm-operation-zk8j7                       1/2     Error       0          37m
cattle-system   rancher-669557c8fd-cmrb2                   1/1     Running     0          43m
cert-manager    cert-manager-59bf757d77-84gkv              1/1     Running     0          46m
cert-manager    cert-manager-cainjector-547c9b8f95-lz9cd   1/1     Running     0          46m
cert-manager    cert-manager-webhook-6787f645b9-b6xjf      1/1     Running     0          46m
kube-system     coredns-8b9777675-qplrr                    1/1     Running     0          47m
kube-system     helm-install-traefik-8m7ck                 0/1     Completed   1          47m
kube-system     helm-install-traefik-crd-7q4f8             0/1     Completed   0          47m
kube-system     local-path-provisioner-69dff9496c-sqx5q    1/1     Running     0          47m
kube-system     metrics-server-854c559bd-2m7rd             1/1     Running     0          47m
kube-system     svclb-traefik-2bcb49c9-vmk8h               2/2     Running     0          46m
kube-system     traefik-66fd46ccd-54v59                    1/1     Running     0          46m

如您所见,helm-operations 出错了。查看日志时,它们没有显示太多信息:

aalex@macmini-ubuntu:~$ kubectl -n cattle-system logs helm-operation-2786k
Defaulted container "helm" out of: helm, proxy
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Waiting for Kubernetes API to be available
Timeout waiting for kubernetes

有人能帮帮我吗?为什么有些 Pod 无法使用 Kubernetes API?为了解决此问题,我接下来应该运行哪些命令?

我发现了很多类似的帖子这个 github 问题但大多数人不知道该如何修复,而且我对 Kubernetes 的经验也不够,无法

检查集群的 k8s API 是否正常通信。

我自己。

相关内容