• 安装部署
  • 启用多集群功能后,项目中已部署的应用列表不再显示。

wmwm061061 1. 3.1.1 已经没有 openpitrix-system 这个单独的 ns 了,合并到了 ks-apiserver 里。2. 跟多集群没有关系。你先用我说的命令检查一下那几个项目 namespace 在后台是否还存在。

    Feynman 使用这个命令看了,项目对应的ns都还在的,之前部署的那些应用对应pod也都在正常运行。

      Feynman

      1. 我之前使用的ns,都不是使用kubectl create namespace命令创建的,而是直接在浏览器管理界面上的企业空间创建的项目。

      2. 我现在可以正常看到企业空间下的项目,包括项目下的服务、工作负载、任务、应用路由、容器组,存储等等,唯独“应用”这个选项下无任何内容。

      3. 我之前在项目下创建了redis、rabbitmq、kafka、mysql等应用现在都看不到了

        wmwm061061
        在KubeSphere由v3.0升级到v3.1时,会将已有的应用数据迁移到新的格式中,此操作由一个job pod执行,你可查看该pod日志,检查其是否正常运行结束

        kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l component=openpitrix-upgrade-job -o name)

        在v3.1中,部署的应用由helmrelease CR对象表示,你可检查其是否存在:

        kubectl get helmreleases

        若release都存在,只是workspace与namespace不正确,可手动修改,即可在项目页面中展示。

          kevendeng
          1、 kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l component=openpitrix-upgrade-job -o name) 这个命令执行报错,component=openpitrix-upgrade-job 这个标签我这里找不到。我这里是这个 component=openpitrix-import-job
          执行完命令之后,输出以下信息

          $ kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l component=openpitrix-import-job -o name)
          
          I0817 11:05:15.915258       1 dumpconfig.go:22] configmap: authentication:
            authenticateRateLimiterMaxTries: 10
            authenticateRateLimiterDuration: 10m0s
            loginHistoryRetentionPeriod: 168h
            maximumClockSkew: 10s
            multipleLogin: False
            kubectlImage: kubesphere/kubectl:v1.18.0
            jwtSecret: "****************"
          
          ldap:
            host: openldap.kubesphere-system.svc:389
            managerDN: cn=admin,dc=kubesphere,dc=io
            managerPassword: ******************
            userSearchBase: ou=Users,dc=kubesphere,dc=io
            groupSearchBase: ou=Groups,dc=kubesphere,dc=io
          
          redis:
            host: redis.kubesphere-system.svc
            port: 6379
            password: ""
            db: 0
          
          
          s3:
            endpoint: http://minio.kubesphere-system.svc:9000
            region: us-east-1
            disableSSL: True
            forcePathStyle: True
            accessKeyID: ************
            secretAccessKey: ****************
            bucket: **********
          
          network:
            ippoolType: none
          devops:
            host: http://ks-jenkins.kubesphere-devops-system.svc/
            username: admin
            password: ********************
            maxConnections: 100
          openpitrix:
            s3:
              endpoint: http://minio.kubesphere-system.svc:9000
              region: us-east-1
              disableSSL: True
              forcePathStyle: True
              accessKeyID: ******************
              secretAccessKey: ****************
              bucket: app-store
          monitoring:
            endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
          logging:
            host: http://elasticsearch.kubesphere-logging-system.svc.cluster.local:9200
            indexPrefix: ks-logstash-log
          W0817 11:05:15.916224       1 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
          I0817 11:05:15.920830       1 import.go:163] start to create app, chart name: apisix, version: 0.1.7
          I0817 11:05:15.935448       1 import.go:176] helm application exists, name: apisix, version: 0.1.7
          I0817 11:05:15.943249       1 import.go:248] start to create app version, chart name: apisix, version: 0.1.7
          I0817 11:05:15.951316       1 import.go:265] helm application version exists, name: apisix, version: 0.1.7
          I0817 11:05:15.952862       1 import.go:163] start to create app, chart name: elasticsearch-exporter, version: 3.3.3
          I0817 11:05:15.962680       1 import.go:176] helm application exists, name: elasticsearch-exporter, version: 3.3.3
          I0817 11:05:15.968032       1 import.go:248] start to create app version, chart name: elasticsearch-exporter, version: 3.3.3
          I0817 11:05:15.974375       1 import.go:265] helm application version exists, name: elasticsearch-exporter, version: 3.3.3
          I0817 11:05:15.975153       1 import.go:163] start to create app, chart name: etcd, version: 0.1.3
          I0817 11:05:15.983965       1 import.go:176] helm application exists, name: etcd, version: 0.1.3
          I0817 11:05:15.986288       1 import.go:248] start to create app version, chart name: etcd, version: 0.1.3
          I0817 11:05:15.993135       1 import.go:265] helm application version exists, name: etcd, version: 0.1.3
          I0817 11:05:16.000161       1 import.go:163] start to create app, chart name: harbor, version: 1.4.1
          I0817 11:05:16.009126       1 import.go:176] helm application exists, name: harbor, version: 1.4.1
          I0817 11:05:16.128821       1 import.go:248] start to create app version, chart name: harbor, version: 1.4.1
          I0817 11:05:16.327854       1 import.go:265] helm application version exists, name: harbor, version: 1.4.1
          I0817 11:05:16.328935       1 import.go:163] start to create app, chart name: memcached, version: 3.2.5
          I0817 11:05:16.530525       1 import.go:176] helm application exists, name: memcached, version: 3.2.5
          I0817 11:05:16.725069       1 import.go:248] start to create app version, chart name: memcached, version: 3.2.5
          I0817 11:05:16.928136       1 import.go:265] helm application version exists, name: memcached, version: 3.2.5
          I0817 11:05:16.931702       1 import.go:163] start to create app, chart name: minio, version: 6.0.5
          I0817 11:05:17.129929       1 import.go:176] helm application exists, name: minio, version: 6.0.5
          I0817 11:05:17.326450       1 import.go:248] start to create app version, chart name: minio, version: 6.0.5
          I0817 11:05:17.528415       1 import.go:265] helm application version exists, name: minio, version: 6.0.5
          I0817 11:05:17.529363       1 import.go:163] start to create app, chart name: mongodb, version: 0.3.2
          I0817 11:05:17.730688       1 import.go:176] helm application exists, name: mongodb, version: 0.3.2
          I0817 11:05:17.924722       1 import.go:248] start to create app version, chart name: mongodb, version: 0.3.2
          I0817 11:05:18.127806       1 import.go:265] helm application version exists, name: mongodb, version: 0.3.2
          I0817 11:05:18.129118       1 import.go:163] start to create app, chart name: mysql, version: 1.6.8
          I0817 11:05:18.329761       1 import.go:176] helm application exists, name: mysql, version: 1.6.8
          I0817 11:05:18.525503       1 import.go:248] start to create app version, chart name: mysql, version: 1.6.8
          I0817 11:05:18.727580       1 import.go:265] helm application version exists, name: mysql, version: 1.6.8
          I0817 11:05:18.729744       1 import.go:163] start to create app, chart name: mysql-exporter, version: 0.5.6
          I0817 11:05:18.930170       1 import.go:176] helm application exists, name: mysql-exporter, version: 0.5.6
          I0817 11:05:19.124942       1 import.go:248] start to create app version, chart name: mysql-exporter, version: 0.5.6
          I0817 11:05:19.328055       1 import.go:265] helm application version exists, name: mysql-exporter, version: 0.5.6
          I0817 11:05:19.329202       1 import.go:163] start to create app, chart name: nginx, version: 1.3.5
          I0817 11:05:19.530190       1 import.go:176] helm application exists, name: nginx, version: 1.3.5
          I0817 11:05:19.725616       1 import.go:248] start to create app version, chart name: nginx, version: 1.3.5
          I0817 11:05:19.927725       1 import.go:265] helm application version exists, name: nginx, version: 1.3.5
          I0817 11:05:19.928601       1 import.go:163] start to create app, chart name: postgresql, version: 0.4.2
          I0817 11:05:20.130900       1 import.go:176] helm application exists, name: postgresql, version: 0.4.2
          I0817 11:05:20.324928       1 import.go:248] start to create app version, chart name: postgresql, version: 0.4.2
          I0817 11:05:20.528573       1 import.go:265] helm application version exists, name: postgresql, version: 0.4.2
          I0817 11:05:20.529390       1 import.go:163] start to create app, chart name: rabbitmq, version: 0.3.2
          I0817 11:05:20.731234       1 import.go:176] helm application exists, name: rabbitmq, version: 0.3.2
          I0817 11:05:20.924464       1 import.go:248] start to create app version, chart name: rabbitmq, version: 0.3.2
          I0817 11:05:21.127815       1 import.go:265] helm application version exists, name: rabbitmq, version: 0.3.2
          I0817 11:05:21.130421       1 import.go:163] start to create app, chart name: radondb-mysql, version: 1.0.0
          I0817 11:05:21.330610       1 import.go:176] helm application exists, name: radondb-mysql, version: 1.0.0
          I0817 11:05:21.529355       1 import.go:248] start to create app version, chart name: radondb-mysql, version: 1.0.0
          I0817 11:05:21.728154       1 import.go:265] helm application version exists, name: radondb-mysql, version: 1.0.0
          I0817 11:05:21.732403       1 import.go:163] start to create app, chart name: radondb-postgresql, version: 1.0.1
          I0817 11:05:21.931000       1 import.go:176] helm application exists, name: radondb-postgresql, version: 1.0.1
          I0817 11:05:22.130203       1 import.go:248] start to create app version, chart name: radondb-postgresql, version: 1.0.1
          I0817 11:05:22.327998       1 import.go:265] helm application version exists, name: radondb-postgresql, version: 1.0.1
          I0817 11:05:22.328836       1 import.go:163] start to create app, chart name: redis, version: 0.3.5
          I0817 11:05:22.529785       1 import.go:176] helm application exists, name: redis, version: 0.3.5
          I0817 11:05:22.724634       1 import.go:248] start to create app version, chart name: redis, version: 0.3.5
          I0817 11:05:22.928914       1 import.go:265] helm application version exists, name: redis, version: 0.3.5
          I0817 11:05:22.930119       1 import.go:163] start to create app, chart name: redis-exporter, version: 3.4.4
          I0817 11:05:23.129751       1 import.go:176] helm application exists, name: redis-exporter, version: 3.4.4
          I0817 11:05:23.324993       1 import.go:248] start to create app version, chart name: redis-exporter, version: 3.4.4
          I0817 11:05:23.527861       1 import.go:265] helm application version exists, name: redis-exporter, version: 3.4.4
          I0817 11:05:23.528746       1 import.go:163] start to create app, chart name: tomcat, version: 0.4.3
          I0817 11:05:23.730017       1 import.go:176] helm application exists, name: tomcat, version: 0.4.3
          I0817 11:05:23.924565       1 import.go:248] start to create app version, chart name: tomcat, version: 0.4.3
          I0817 11:05:24.127770       1 import.go:265] helm application version exists, name: tomcat, version: 0.4.3

          以上日志中只有这一条有问题W0817 11:05:15.916224 1 client_config.go:552] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work. ,其他日志内容看不出问题。不知道迁移工作是否成功。

          2、 执行完 kubectl get helmreleases 命令后,release都存在,workspace和namespace也全部正确。但是浏览器管理界面还是看不到应用

            wmwm061061
            这说明部署的应用CR都还保存在集群中,但是没有正确获取到。

            试试在界面按下F12看看具体的网络请求路径与响应值,是否有什么异常吗?

              kevendeng
              非常感谢,找到原因了,是这次升级之后新加了一个 kubesphere 集群,变成了多集群,点击项目应用时请求K8S apiserver 会多传入一个label kubesphere.io/cluster,而 helmrelease 下的资源CLUSTER为空,所以在项目应用下看不到之前的应用。

              1、执行 kubectl get helmreleases 之后,会发现CLUSTER为空。

              2、在浏览器按F12打开调试模式,点击项目应用时,会出现下面这条报文,其中 labelSelector 会选择两条标签
              ,分别是 kubesphere.io/clusterkubesphere.io/namespace。由于 helmreleases 资源的 CLUSTER 为空,所以点击项目应用时看不到之前安装的应用。
              ws://192.168.xxx.xxx:30xxx/apis/application.kubesphere.io/v1alpha1/watch/helmreleases?labelSelector=kubesphere.io/cluster=host,kubesphere.io/namespace=xx-test

              3、编辑 CLUSTER 为空的资源,然后添加一个 labels kubesphere.io/cluster: host,其中host为集群名。
              kubectl edit helmreleases.application.kubesphere.io cl-j30xqr8lo31m5m

              apiVersion: application.kubesphere.io/v1alpha1
              kind: HelmRelease
              metadata:
                labels:
                  kubesphere.io/cluster: host

              之后再执行 kubectl get helmreleases,会发现 CLUSTER 这一列的值为 host。

              此时在浏览器管理界面的项目应用下就可以看到之前安装的应用了。

                wmwm061061
                是的,这应该就是真实原因了,我猜测这是由于在启用多集群功能之前,因为并没有多集群的概念,这些已部署应用的CR对象中是没有对应信息的。而启用多集群之后,由于API查询条件加入了集群信息,因此这些应用都没有查到。

                这应该是一个Bug。

                建议将此贴标记为已解决,并将你的解决方法标记为最佳回复,以方便其他遇到类似问题的人检索。

                同时,也建议将帖子标题修改为更加符合实际情况的描述:启用多集群功能后,项目中已部署的应用列表不再显示。

                  wmwm061061 更改标题为「启用多集群功能后,项目中已部署的应用列表不再显示。

                  kevendeng
                  是的,在发现这个问题的前一天,我对 kubesphere 集群做了两个比较大的操作

                  1. 将 kubesphere 版本由 v3.1.0 升级至 v3.1.1
                  2. 启用了多集群功能,添加了另一个 kubesphere 集群。

                  开始以为是版本升级的原因,经过这么多次排错。真正的原因就是你说的这个

                  由于在启用多集群功能之前,因为并没有多集群的概念,这些已部署应用的CR对象中是没有对应信息的。而启用多集群之后,由于API查询条件加入了集群信息,因此这些应用都没有查到。