4

Question regarding SpringBootAdmin server with Kubernetes please.

I have a very simple SpringBootAdmin Server application as follow

@EnableScheduling
@EnableDiscoveryClient
@EnableAdminServer
@EnableConfigServer
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }

}
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-kubernetes</artifactId>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
            <version>2.3.0</version>
        </dependency>

It starts up fine on local machine. However, when put onto a Kubernetes environment, it yields:

ERROR [,e6d057e7abaf4a65,e6d057e7abaf4a65,true] 62 --- [   scheduling-1] o.s.c.k.d.KubernetesCatalogWatch         : Error watching Kubernetes Services

io.fabric8.kubernetes.client.KubernetesClientException: Operation: [list]  for kind: [Endpoints]  with name: [null]  in namespace: [null]  failed.
    at io.fabric8.kubernetes.client.KubernetesClientException.launderThrowable(KubernetesClientException.java:64) ~[kubernetes-client-4.10.3.jar!/:na]

Why those [null] please? I did use

spring.cloud.kubernetes.config.namespace=my-namespace

What is the issue please?

Thank you

PatPanda
  • 3,644
  • 9
  • 58
  • 154

1 Answers1

0

This could be a problem with Roles.

Try running this script in your Kubernetes:

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: spring-admin-role
  namespace: default
rules:
  - apiGroups: [""]
    resources: ["pods", "services", "endpoints"]
    verbs: ["get", "list", "watch"]

---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: spring-admin-role-binding
  namespace: default
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
roleRef:
  kind: Role
  name: spring-admin-role
  apiGroup: rbac.authorization.k8s.io

In the application.properties change this property to false if you don't need it. Otherwise, you will need a ClusterRole.

spring.cloud.kubernetes.discovery.all-namespaces=false

For more information: https://github.com/fabric8io/fabric8/issues/6840

Thiago Bomfim
  • 408
  • 6
  • 12