kubesphere登录不跳转问题

kubesphere登录不跳转问题

问题描述:由于增加了ks-apiserver副本数量,但是ks-apiserver 没有配置 Redis,因此将使用内存缓存,这可能在运行多个 ks-apiserver 副本时导致不一致性.

查看kubesphere-system空间情况

kubectl get all -n kubesphere-system
[root@k8s-master ~]# kubectl get all -n kubesphere-system
NAME                                         READY   STATUS    RESTARTS   AGE
pod/ks-apiserver-57f76fc7f8-655qq            1/1     Running   0          85m
pod/ks-console-6d6d765964-pqm9q              1/1     Running   3          27h
pod/ks-controller-manager-5bcd4c4497-2mdhz   1/1     Running   0          85m
pod/ks-installer-86669b5744-mwddl            1/1     Running   3          27h

NAME                            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/ks-apiserver            ClusterIP   10.233.15.168   <none>        80/TCP         30h
service/ks-console              NodePort    10.233.25.135   <none>        80:30880/TCP   30h
service/ks-controller-manager   ClusterIP   10.233.9.17     <none>        443/TCP        30h

NAME                                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ks-apiserver            1/1     1            1           30h
deployment.apps/ks-console              1/1     1            1           30h
deployment.apps/ks-controller-manager   1/1     1            1           30h
deployment.apps/ks-installer            1/1     1            1           30h

NAME                                               DESIRED   CURRENT   READY   AGE
replicaset.apps/ks-apiserver-57bd87b7f7            0         0         0       29h
replicaset.apps/ks-apiserver-57f76fc7f8            1         1         1       85m
replicaset.apps/ks-apiserver-648848d49b            0         0         0       29h
replicaset.apps/ks-apiserver-69b9b6cd97            0         0         0       30h
replicaset.apps/ks-apiserver-6c64d7bb57            0         0         0       30h
replicaset.apps/ks-apiserver-6fc5b97c4c            0         0         0       25h
replicaset.apps/ks-apiserver-746ff85777            0         0         0       30h
replicaset.apps/ks-apiserver-76499696c7            0         0         0       26h
replicaset.apps/ks-apiserver-78dbf446d9            0         0         0       25h
replicaset.apps/ks-apiserver-cd9b85d5d             0         0         0       85m
replicaset.apps/ks-console-6d6d765964              1         1         1       30h
replicaset.apps/ks-controller-manager-564598db84   0         0         0       30h
replicaset.apps/ks-controller-manager-5bcd4c4497   1         1         1       85m
replicaset.apps/ks-controller-manager-76bb6cf669   0         0         0       29h
replicaset.apps/ks-controller-manager-777b4bf4c    0         0         0       85m
replicaset.apps/ks-controller-manager-779b7cffcf   0         0         0       25h
replicaset.apps/ks-controller-manager-7f999fd4c6   0         0         0       29h
replicaset.apps/ks-controller-manager-85565f9df7   0         0         0       25h
replicaset.apps/ks-controller-manager-8bfc874      0         0         0       30h
replicaset.apps/ks-controller-manager-bb8c78dc7    0         0         0       30h
replicaset.apps/ks-installer-86669b5744            1         1         1       30h

可以看到 ks-console pod名称为 ks-console-6d6d765964-pqm9q

查看kubesphere控制台日志

[root@k8s-master ~]# kubectl logs -n kubesphere-system ks-console-6d6d765964-pqm9q  
W0429 15:18:08.046214       1 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
W0429 15:18:08.048107       1 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
W0429 15:18:08.056437       1 metricsserver.go:238] Metrics API not available.
W0429 15:18:08.056475       1 options.go:180] ks-apiserver starts without redis provided, it will use in memory cache. This may cause inconsistencies when running ks-apiserver with multiple replicas.
I0429 15:18:08.120881       1 interface.go:60] start helm repo informer
I0429 15:18:08.151071       1 apiserver.go:372] Start cache objects
I0429 15:18:08.920478       1 apiserver.go:576] Finished caching objects
I0429 15:18:08.920509       1 apiserver.go:297] Start listening on :9090
W0429 15:19:51.928048       1 jwt_token.go:52] token not found in cache
W0429 15:19:51.933761       1 jwt_token.go:52] token not found in cache
E0429 15:34:30.198386       1 am.go:978] role.rbac.authorization.k8s.io "admin" not found
E0429 15:34:30.198429       1 am.go:210] role.rbac.authorization.k8s.io "admin" not found
E0429 15:37:18.313887       1 utils.go:76] /workspace/pkg/kapis/resources/v1alpha2/handler.go:334 invalid character 'p' after top-level value

根据提供的日志信息

  1. Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work. 这个警告表明 KubeSphere 在尝试使用集群内部配置(inClusterConfig)连接到 Kubernetes API 服务器,因为没有提供 kubeconfig 文件或 master 参数。通常情况下,当 KubeSphere 运行在 Kubernetes 集群内部时,这是可以工作的。

  2. Metrics API not available. 这个警告表明 Metrics API 不可用。你可能需要检查 Metrics Server 是否已经正确安装和运行。

  3. ks-apiserver starts without redis provided, it will use in memory cache. This may cause inconsistencies when running ks-apiserver with multiple replicas. 这个警告表明 ks-apiserver 没有配置 Redis,将使用内存缓存。如果你有多个 ks-apiserver 副本运行,可能会导致数据不一致。

  4. role.rbac.authorization.k8s.io "admin" not found 这个错误表明 “admin” 角色在 RBAC 授权中未找到。你可能需要检查 Kubernetes RBAC 配置。

  5. /workspace/pkg/kapis/resources/v1alpha2/handler.go:334 invalid character 'p' after top-level value 这个错误表明在处理 JSON 数据时遇到了非法字符 ‘p’。你可能需要检查与此相关的 JSON 数据是否格式正确。

以上都只是可能的问题和解决方案,具体情况可能需要根据你的环境和配置进行调整,此处由于我只进行过ks-apiserver的调整,所以我优先排查ks-apiserver的问题

查看ks-apiserver这个pod日志

kubectl logs -n kubesphere-system ks-apiserver-57f76fc7f8-655qq
[root@k8s-master ~]# kubectl logs -n kubesphere-system ks-apiserver-57f76fc7f8-655qq
W0429 14:01:03.227371       1 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
W0429 14:01:03.229726       1 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
W0429 14:01:03.238273       1 metricsserver.go:238] Metrics API not available.
W0429 14:01:03.238311       1 options.go:180] ks-apiserver starts without redis provided, it will use in memory cache. This may cause inconsistencies when running ks-apiserver with multiple replicas.
I0429 14:01:03.265063       1 interface.go:60] start helm repo informer
I0429 14:01:03.294912       1 apiserver.go:372] Start cache objects
I0429 14:01:04.015285       1 apiserver.go:576] Finished caching objects
I0429 14:01:04.015325       1 apiserver.go:297] Start listening on :9090

ks-apiserver starts without redis provided, it will use in memory cache. This may cause inconsistencies when running ks-apiserver with multiple replicas.: 这个警告是说 ks-apiserver 没有配置 Redis,因此将使用内存缓存。这可能在运行多个 ks-apiserver 副本时导致一些不一致性。这可能与你的问题有关,如果多个 ks-apiserver 副本之间的缓存状态不一致,可能导致一些奇怪的行为。你可能需要考虑配置一个 Redis 来解决这个问题

减少ks-apiserver副本数量

你可以通过编辑 ks-apiserver 的 Deployment 配置来更改副本数量。这可以通过 kubectl edit 命令完成:

kubectl -n kubesphere-system edit deployment ks-apiserver

这将在你的默认编辑器中打开一个 YAML 文件。找到 spec.replicas 字段并将其更改为 1。例如:

...
spec:
  replicas: 1
...

保存并退出编辑器后,Kubernetes 将自动更新该 Deployment,以匹配新的配置。

如果你更喜欢命令行,你也可以使用 kubectl scale 命令直接更改副本数量:

kubectl -n kubesphere-system scale deployment ks-apiserver --replicas=1

这将立即将 ks-apiserver 的副本数量更改为 1。

  • 20
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值