disabling discovery for k8s api client

1.3k views Asked by At

Right now i used the way from the 1st answer from: Cannot read configmap with name: [xx] in namespace ['default'] Ignoring

But in application logs:

2022-04-19 14:14:57.660 [controller-reflector-io.kubernetes.client.openapi.models.V1ConfigMap-1] [] INFO  i.k.c.informer.cache.ReflectorRunnable - class io.kubernetes.client.openapi.models.V1ConfigMap#Start listing and watching...
2022-04-19 14:14:57.662 [controller-reflector-io.kubernetes.client.openapi.models.V1ConfigMap-1] [] ERROR i.k.c.informer.cache.ReflectorRunnable - class io.kubernetes.client.openapi.models.V1ConfigMap#Reflector loop failed unexpectedly
io.kubernetes.client.openapi.ApiException: 
    at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:974)
    at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:886)
    at io.kubernetes.client.informer.SharedInformerFactory$1.list(SharedInformerFactory.java:207)
    at io.kubernetes.client.informer.cache.ReflectorRunnable.run(ReflectorRunnable.java:88)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

And its works properly and reading configmaps mounted in deployment. How can i disable the all another features? Using implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-client-config:2.1.1")

In bootstrap.yml:

spring:
  application:
    name: toast
  cloud:
    vault:
      enabled: false
    kubernetes:
      reload:
        enabled: true
        mode: event
        strategy: refresh
      config:
        sources:
          - name: ${spring.application.name}-common
          - name: ${spring.application.name}
        enabled: true
        paths:
          #- { { .Values.application } }-common-config/data.yml
          #- { { .Values.application } }-config/application.yml
          - /etc/${spring.application.name}-common/config/application.yml
          - /etc/${spring.application.name}/config/data.yml
      enabled: true

I need can use it without rbac resource in k8s.

1

There are 1 answers

0
littl3rud3 On

Try to change it to spring-cloud-starter-kubernetes-fabric8-config instead of spring-cloud-starter-kubernetes-client-config

implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-fabric8-config:2.1.1")