0

我正在开发春季云数据流流应用程序。我能够在 Cloud Foundry 中运行船长来运行 Spring 云数据流服务器。现在我正在尝试与在 kubernetes 集群中运行的船长运行相同的操作,并且在部署时遇到错误,即使我在部署的环境配置中明确给出了用户名。

引起:io.fabric8.kubernetes.client.KubernetesClientException:执行失败:GET at:kubernetes_cluster_url:6443/api/v1/namespaces/pocdev/services?labelSelector=spring-app-id%3Dtest444-pocclient。服务帐户可能已被撤销。禁止服务:用户“system:anonymous”无法在命名空间“poc-dev”中的 API 组“”中列出资源“服务”。

用于 Kubernetes 部署的 SKIPPER YML

apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: skipper-server
      labels:
        app: skipper-server
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: skipper-server
      template:
        metadata:
          labels:
            app: skipper-server
          annotations:
            kubernetes.io/psp: nonroot
        spec:
          containers:
            - name: skipper-server
              image: <image_location>
              imagePullPolicy: Always
              ports:
                - containerPort: 7577
                  protocol: TCP
              resources:
                limits:
                  cpu: "4"
                  memory: 2Gi
                requests:
                  cpu: 25m
                  memory: 1Gi
              securityContext:
                runAsUser: 99        
              env:
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_MASTER_URL"
                  value: "<kubernetes_master_url>:6443"
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME"
                  value: "<user>"
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD"
                  value: "<pwd>"
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_NAMESPACE"
                  value: "<namespace>"
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_TRUST_CERTS"
                  value: "true"
                - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_CREATE_LOAD_BALANCER"
                  value: "true"

完整的堆栈跟踪

Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: <kubernetes_cluster_url:6443/api/v1/namespaces/pocdev/services?labelSelector=spring-app-id%3Dtest444-pocclient . Service account may have been revoked. services is forbidden: User "system:anonymous" cannot list resource "services" in API group "" in the namespace "poc-dev".     at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:476) ~[kubernetes-client-4.1.0.jar!/:na]      at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:413) ~[kubernetes-client-4.1.0.jar!/:na]
        at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:381) ~[kubernetes-client-4.1.0.jar!/:na]
        at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:344) ~[kubernetes-client-4.1.0.jar!/:na]
        at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:328) ~[kubernetes-client-4.1.0.jar!/:na]
        at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:598) ~[kubernetes-client-4.1.0.jar!/:na]
        at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:63) ~[kubernetes-client-4.1.0.jar!/:na]
        at org.springframework.cloud.deployer.spi.kubernetes.KubernetesAppDeployer.status(KubernetesAppDeployer.java:196) ~[spring-cloud-deployer-kubernetes-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
        at org.springframework.cloud.deployer.spi.kubernetes.KubernetesAppDeployer.deploy(KubernetesAppDeployer.java:103) ~[spring-cloud-deployer-kubernetes-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
        at org.springframework.cloud.skipper.server.deployer.DefaultReleaseManager.install(DefaultReleaseManager.java:115) ~[spring-cloud-skipper-server-core-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        ... 50 common frames omitted 
4

1 回答 1

0

当我从 env 属性列表中删除以下属性并且船长开始使用默认服务而不是我的用户帐户时,此问题已得到修复

  • 名称:“SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME”值:“”-名称:“SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD”值:“”
于 2019-11-04T22:03:58.647 回答