spring-cloud-kubernetes
spring-cloud-kubernetes copied to clipboard
Spring kubernetes fabric8 ignoring KUBERNETES_MASTER for local IDE development
I'm using cloud 2021.0.0 I'd like to connect from my local IDE (Eclipse) into k8s secret on google cloud. The API key required for my app is stored on k8s secret on google and periodically changed by k8s admin, so I have to use the one fromk8s.
My application is not running in k8s (need to debug the app via eclipse), but the config must be taken from k8s secret.
This documentation imply that it is possible to do that.
I already setup the KUBERNETES_MASTER and FABRIC8_PROFILES env variable as stated here.
I'm using windows 11, so I'm setting it through windows env variable, and windows already recognizes them.
But my local IDE still cannot take data from k8s cluster.
This warning still exists
2022-02-02 17:44:44.480 WARN 12312 --- [ main] ubernetesProfileEnvironmentPostProcessor : Not running inside kubernetes. Skipping 'kubernetes' profile activation.
2022-02-02 17:44:44.482 INFO 12312 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2022-02-02 17:44:45.332 INFO 12312 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=6a1bfdf1-8ebb-365a-a342-04a9b382db3f
2022-02-02 17:44:45.676 INFO 12312 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-02-02 17:44:45.687 INFO 12312 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-02-02 17:44:45.687 INFO 12312 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-02-02 17:44:45.811 INFO 12312 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-02-02 17:44:45.812 INFO 12312 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1295 ms
2022-02-02 17:44:46.976 INFO 12312 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-02-02 17:44:47.473 INFO 12312 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 6.531 seconds (JVM running for 7.62)
Api key : from-local-file
2022-02-02 17:44:51.232 INFO 12312 --- [on(2)-127.0.0.1] inMXBeanRegistrar$SpringApplicationAdmin : Application shutdown requested.
2022-02-02 17:44:51.259 INFO 12312 --- [on(2)-127.0.0.1] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
bootstrap.yml
spring:
cloud:
kubernetes:
secrets:
enable-api: true
enabled: true
namespace: java-k8s-test
name: java-test
Or is there any other way to run locally (IDE) using spring-fabric8 kubernetes library, but the secret / configmap is taken from k8s cluster (not local k8s, but at google cloud)
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-fabric8-config'
Thanks
That warning comes from a post processor, to begin with.
The real question here is can you read the secret with plain kubectl from your machine? No matter the answer - you should read into KUBECONGIF and how that is set-up.
I had the same problem when I upgraded to version 2021.0.1. it works fine when the version of spring cloud is Hoxton.SR9.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.