Closed kwoodson closed 3 years ago
@kwoodson Have you upgraded the community.kubernetes then what shipped with those ansible distros or maybe installed the kubernetes.core collection? I'm just verifying which version you are running with here.
I think I know what's the problem here:
currently unreleased version of community.kubernetes
has a fix to work with python's kubernetes
library of version 12 and up (here #276). The last released version of community.kubernetes
(1.1.1) does not contain this fix hence it breaks when used with Python's kubernetes
library of version 12 and up. The error looks exactly as one I've encountered when using this buggy combination. The only solution I came up with was to stick to kubernetes
version 11.0.0 and use currently released community.kubernetes
.
@resmo I've seen that version of Python's kubernetes
on your local machine is 11.0.0. I suspect that version of this library on remote machine is 12.0.0.
The actual solution would be to release new version of community.kubernetes
ASAP because it contains relevant bugfix.
@stanislaw55 Your assumption might be correct. Here are the versions:
[root@bastion ~]# rpm -qa | grep python2-kubernetes
python2-kubernetes-12.0.1-1.el7.noarch
[root@bastion ~]# rpm -qa | grep openshift
python2-openshift-0.11.2-1.el7.noarch
@stanislaw55 I was able to find a copy of the older rpm:
[root@bastion cloud-user]# rpm -qa | grep python2-kubernetes
python2-kubernetes-11.0.0-1.el7.noarch
This solved my problem.
@kwoodson can you confirm if the current git version of community.kubernetes works for you with 12.0.0?
I confirm that python2-kubernetes-12.0.1-1.el7.noarch is causing the problem (I just tested on a server that had python2-kubernetes-11.0.0-2.el7.noarch, it worked, then I updated that precise package and reproduced this error).
@goneri if there is an easy way to test that the git version works I'll be happy to test. I installed the collection from git but this still fails because of the underlying python2-kubernetes-12.0.1 is causing the issue not the collection itself. When removing the rpm it is missing and collection doesn't provide it AFAIK.
@kwoodson, You can install the collection from git
this way:
rm -r ~/.ansible/collections/ansible_collections/community/kubernetes/
git clone https://github.com/ansible-collections/community.kubernetes ~/.ansible/collections/ansible_collections/community/kubernetes/
You will still need python2-kubernetes-12.0.1.
@goneri
[root@bastion community.kubernetes]# rpm -qa | grep openshift
python2-openshift-0.11.2-1.el7.noarch
[root@bastion community.kubernetes]# rpm -qa | grep kubernetes
python2-kubernetes-12.0.1-1.el7.noarch
[root@bastion community.kubernetes]# ll ~/.ansible/collections/ansible_collections/community/kubernetes/
total 92
-rw-r--r--. 1 root root 36 Dec 2 18:09 bindep.txt
-rw-r--r--. 1 root root 12518 Dec 2 18:09 CHANGELOG.rst
drwxr-xr-x. 3 root root 64 Dec 2 18:09 changelogs
-rw-r--r--. 1 root root 107 Dec 2 18:09 codecov.yml
-rw-r--r--. 1 root root 3278 Dec 2 18:09 CONTRIBUTING.md
-rw-r--r--. 1 root root 857 Dec 2 18:09 galaxy.yml
...
Still receiving this error with the latest collection:
TASK [fetch etcd credentials] *******************************************************************************************************************
fatal: [52.165.158.15]: FAILED! => {"changed": false, "msg": "Failed to get client due to Host value http://localhost should start with https:// when talking to HTTPS endpoint"}
@kwoodson So just to sum up:
community.kubernetes
1.1.1 with kubernetes
11.0.0 works fine.community.kubernetes
1.1.1 with kubernetes
12.0.0 and up is broken (expected by me).community.kubernetes
from main
with kubernetes
12.0.0 and up is broken - this is unexpected. To clarify - I did not test this combination but the solutions I found in web suggest that fix provided by #276 should be sufficient.I confirm that python2-kubernetes-12.0.1-1.el7.noarch is causing the problem (I just tested on a server that had python2-kubernetes-11.0.0-2.el7.noarch, it worked, then I updated that precise package and reproduced this error).
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
https://github.com/kubernetes-client/python/issues/1333 appears to be related to this
Update on 10 Feb 2021 -
Ansible | Kubernetes-python | Openshift | Works |
2.9.17 | 11.0.0 | 0.11.2 | Yes |
2.9.17 | 12.0.1 | 0.11.2 | Yes |
2.10.5 | 11.0.0 | 0.11.2 | Yes |
2.10.5 | 12.0.1 | 0.11.2 | Yes |
SUMMARY
I'm attempting to run a few
k8s
commands. For example,I'm receiving the following error:
I have attempted to supply the environment variable
K8S_AUTH_KUBECONFIG
as well as pass thekubeconfig
argument. TheK8S_AUTH_KUBECONFIG
does not change anything or is being ignored. Thekubeconfig
fails with an error that it cannot be found. This is a bit puzzling as I have the files required and both my local and remote hosts have a valid kubeconfig file. (Tested withkubectl --kubeconfig /home/kwoodson/.kube/config get pods
)I am able to execute the following commands locally and remotely:
I'm a bit confused whether this executes on the remote host or this executes locally. The error messages lead me to believe the execution is occurring remotely. If this is the case, the kubeconfig exists, is valid, can be found via the stat file task. I'm not sure why I would be seeing an empty client.
ISSUE TYPE
COMPONENT NAME
ansible k8s module
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Fedora 32 (local)
Rhel 7.9 (remote host) Python 2.7.5
STEPS TO REPRODUCE
Run the following playbook
EXPECTED RESULTS
I would expect that the k8s query would be successful.
ACTUAL RESULTS