openshift/openshift-restclient-python

Issues with latest python kubernetes client

StevenBarre opened this issue · 3 comments

I'm using Ansible Runner in a container in OCP 4.5. Building my image ontop of openshift/cli which I think is RHEL7 based.

I'm using a service account injected into the pod and relying on all the default env vars that get injected.

Previously with python2-kubernetes-11.0.0-2.el7.noarch everything worked great. Now with python2-kubernetes-12.0.1-1.el7.noarch I get an error trying to use the k8s_info ansible module.

ValueError: Host value http://localhost should start with https:// when talking to HTTPS endpoint

The changelog mentions there is a breaking change with how the client handles configuration.

I suspect this module is not handling that breaking change properly, and so the env vars that set the host and port for the k8s API are not being set in the client config, and so it still has the default value of http://localhost.

I've verified that installing python2-kubernetes-11.0.0-2.el7.noarch instead of python2-kubernetes-12.0.1-1.el7.noarch does fix the issue.

If this isn't the right place to seek help, could you point me in the right direction? There's a lot of connected components here.

I am hitting the same issue.

It seems we have to change the module to use new get_default_copy() function which has been cahnged since python2-kubernetes-12.0.1-1.

Otherwise the default value will be used instead, which is set to http://localhost.
https://github.com/kubernetes-client/python/blob/818e5ba0ba8cfc6d866195de706f58b7431110c1/kubernetes/client/configuration.py#L75

kubernetes-client/python#1284

Hmm, seems like the client itself is behaving properly (this behavior is just inherited from the core kubernetes client). I think the modules will need to be updated to be compatible with these changes kubernetes 12.x, by the time the dynamic client is created the configuration has already been loaded