Docker部署rancher2.6.7页面打不开

Rancher Server 设置

  • Rancher 版本:2.6.7
  • 安装选项 (Docker install/Helm Chart):
    • docker部署,docker版本: 20.10.21

问题描述:
docker部署,打开网页没有任何反应。

docker run -d --restart=unless-stopped \
  --name ranche \
  -v /opt/data/rancher_data:/var/lib/rancher \
  -p 80:80 -p 443:443 \
  --privileged \
  rancher/rancher:v2.6.7

查看k3s日志

日志
E1115 15:32:54.728083      51 controller.go:166] Unable to perform initial Kubernetes service initialization: Service "kubernetes" is invalid: spec.clusterIPs: Invalid value: []string{"10.43.0.1"}: failed to allocate IP 10.43.0.1: cannot allocate resources of type serviceipallocations at this time
...
E1115 15:33:03.142234      51 kubelet.go:1298] "Image garbage collection failed once. Stats initialization may not have completed yet" err="invalid capacity 0 on image filesystem"
I1115 15:33:03.146046      51 volume_manager.go:289] "Starting Kubelet Volume Manager"
...
E1115 15:33:03.184728      51 kubelet.go:1998] "Skipping pod synchronization" err="[container runtime status check may not have completed yet, PLEG is not healthy: pleg has yet to be successful]"

W1115 15:33:03.189849      51 reflector.go:324] k8s.io/client-go@v1.24.1-k3s1/tools/cache/reflector.go:167: failed to list *v1.Endpoints: endpoints "kubernetes" is forbidden: User "system:k3s-controller" cannot list resource "endpoints" in API group "" in the namespace "default"

E1115 15:33:03.189867      51 reflector.go:138] k8s.io/client-go@v1.24.1-k3s1/tools/cache/reflector.go:167: Failed to watch *v1.Endpoints: failed to list *v1.Endpoints: endpoints "kubernetes" is forbidden: User "system:k3s-controller" cannot list resource "endpoints" in API group "" in the namespace "default"

E1115 15:33:03.246121      51 kubelet.go:2419] "Error getting node" err="node \"local-node\" not found"

W1115 15:33:03.266493      51 watcher.go:93] Error while processing event ("/sys/fs/cgroup/kubepods": 0x40000100 == IN_CREATE|IN_ISDIR): readdirent /sys/fs/cgroup/kubepods: no such file or directory

E1115 15:33:03.266506      51 node_container_manager_linux.go:61] "Failed to create cgroup" err="cannot enter cgroupv2 \"/sys/fs/cgroup/kubepods\" with domain controllers -- it is in an invalid state" cgroupName=[kubepods]

E1115 15:33:03.266536      51 kubelet.go:1378] "Failed to start ContainerManager" err="cannot enter cgroupv2 \"/sys/fs/cgroup/kubepods\" with domain controllers -- it is in an invalid state"


这是那里出错了,怎么修改呢?

从日志来看,rancher 并没有启动成功

单节点 rancher ,也就是通过 docker run 方式启动的 rancher 内置的是 K3s 集群,所以可以根据 k3s的支持矩阵选择兼容的操作系统:Support matrix | SUSE

我重新安装ubuntu系统,我查了这个系统是兼容的。发现还是打不开页面。

aa@aa:~/rancher$ cat /etc/issue
Ubuntu 22.04.1 LTS \n \l

docker logs
日志:

2022/11/17 02:51:00 [FATAL] failed to update operations.catalog.cattle.io apiextensions.k8s.io/v1, Kind=CustomResourceDefinition for  operations.catalog.cattle.io: Patch "https://127.0.0.1:6444/apis/apiextensions.k8s.io/v1/customresourcedefinitions/operations.catalog.cattle.io?timeout=15m0s": unexpected EOF
INFO: Running k3s server --cluster-init --cluster-reset
2022/11/17 02:51:31 [INFO] Rancher version v2.6.7 (e5c6f0f6a) is starting
2022/11/17 02:51:31 [INFO] Rancher arguments {ACMEDomains:[] AddLocal:true Embedded:false BindHost: HTTPListenPort:80 HTTPSListenPort:443 K8sMode:auto Debug:false Trace:false NoCACerts:false AuditLogPath:/var/log/auditlog/rancher-api-audit.log AuditLogMaxage:10 AuditLogMaxsize:100 AuditLogMaxbackup:10 AuditLevel:0 Features: ClusterRegistry:}
2022/11/17 02:51:31 [INFO] Listening on /tmp/log.sock
2022/11/17 02:51:31 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:33 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:35 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:37 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:39 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:41 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:43 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:45 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused
2022/11/17 02:51:47 [INFO] Waiting for server to become available: Get "https://127.0.0.1:6444/version?timeout=15m0s": dial tcp 127.0.0.1:6444: connect: connection refused

...
2022/11/17 02:52:12 [FATAL] k3s exited with: exit status 1

aa@aa:~/rancher$ curl http://192.168.42.171
curl: (7) Failed to connect to 192.168.42.171 port 80 after 0 ms: Connection refused
aa@aa:~/rancher$ curl https://192.168.42.171
curl: (7) Failed to connect to 192.168.42.171 port 443 after 0 ms: Connection refused

我稍后会看看能不能重现,我没在 22.04 上测试过,我一般都用 20.04

2.6.9开始才能支持ubuntu 22.04,是cgroup v2的兼容问题。