kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
141 stars 45 forks source link

Failed to load cluster configuration inside a pod by using function "load_incluster_config()" #180

Closed gtsal closed 1 year ago

gtsal commented 1 year ago

Hello,

hope you are well.

I tried to use the c client inside a pod by using the _load_inclusterconfig()_ function but it failed because it could not read the environment variables. The reason is that the corresponding source file does not include the config.h file that is generated during the make process. So the code into #if defined(HAVE_SECURE_GETENV) and #elif defined(HAVE_GETENV) is left out.

After adding the include statement in https://github.com/kubernetes-client/c/blob/master/kubernetes/config/incluster_config.c and recompile the library I had not problem.

ityuhui commented 1 year ago

Thanks for reporting this and providing a solution !

I think the PR https://github.com/kubernetes-client/c/pull/171 forgot to add #include <config.h> into incluster_config.c