spring cloud dataflow on kubernetes error on deploy

11/4/2019

I am working on spring cloud dataflow stream app. I am able to run Spring cloud data flow server with the skipper running in Cloud Foundry . Now i am trying to run the same with the skipper running in kubernetes cluster and getting below error on deployment even though i am explicitly giving the username in the environment config in deployment.

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".

SKIPPER YML for KUBERNETES DEPLOYMENT

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"

FULL STACKTRACE

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 
-- Ajith Kannan
kubernetes-ingress
spring-cloud-dataflow
spring-cloud-kubernetes
spring-cloud-stream

1 Answer

11/4/2019

This got fixed when i removed below properties from the env properties list and skipper started using the default service instead of my user account

  • name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME" value: "" - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD" value: ""
-- Ajith Kannan
Source: StackOverflow