abcdesktopio / pyos

abcdesktop API services
https://abcdesktopio.github.io/
GNU General Public License v2.0
2 stars 2 forks source link

tries to use kubernetes.default.svc instead of KUBERNETES_SERVICE_HOST=k1api.domain.de #12

Open titansmc opened 7 months ago

titansmc commented 7 months ago

We are overwriting KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT because we need pyos to reach the API servers directly, since after applying some network policies, the default namespace service cannot be reached. What is it failing still why it still tries to use kubernetes.default.svc instead ?

[root@moscardo ~]# kubectl exec -ti -n abcdesktop-ns pyos-od-598d4d6989-49ffm -- env|grep KUB
KUBERNETES_SERVICE_HOST=k1api.domain.de
KUBERNETES_SERVICE_PORT=6443
KUBERNETES_SERVICE_PORT_HTTPS=6443
KUBERNETES_PORT_443_TCP=tcp://10.133.0.1:443
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT=tcp://10.133.0.1:443
KUBERNETES_PORT_443_TCP_ADDR=10.133.0.1
alexandredevely commented 7 months ago

Hello titansmc,

if KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT are defined then pyos loads the incluster config else it loads kube config.

       if os.getenv('KUBERNETES_SERVICE_HOST') and os.getenv('KUBERNETES_SERVICE_PORT') :
            config.load_incluster_config() # set up the client from within a k8s pod
        else:
            config.load_kube_config()

This could be the source of this issue, could you try to unset KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT and use kube config.

I hope this will help you

Alexandre