Closed foroozf001 closed 3 years ago
@foroozf001 Can you verify what version of the kubernetes python library you are now using there? This sounds like #314 where kubernetes 12.0 causes previous.y working code to break.
@tima I have tried both 11.0.0 and 12.0.1.
The problem I had with 11.0.0 was my RBAC. I had to create a clusterrole binding like so:
kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts
This is the stack trace for 12.0.1:
The full traceback is:
File "/tmp/ansible_community.kubernetes.k8s_payload__r_yk6ni/ansible_community.kubernetes.k8s_payload.zip/ansible_collections/community/kubernetes/plugins/module_utils/common.py", line 265, in get_api_client
return DynamicClient(kubernetes.client.ApiClient(configuration))
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py", line 71, in __init__
self.__discoverer = discoverer(self, cache_file)
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 259, in __init__
Discoverer.__init__(self, client, cache_file)
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 31, in __init__
self.__init_cache()
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 78, in __init_cache
self._load_server_info()
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 158, in _load_server_info
'kubernetes': self.client.request('get', '/version', serializer=just_json)
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py", line 42, in inner
resp = func(self, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py", line 235, in request
return self.client.call_api(
File "/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py", line 348, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py", line 180, in __call_api
response_data = self.request(
File "/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py", line 373, in request
return self.rest_client.GET(url,
File "/usr/local/lib/python3.8/dist-packages/kubernetes/client/rest.py", line 239, in GET
return self.request("GET", url,
File "/usr/local/lib/python3.8/dist-packages/kubernetes/client/rest.py", line 212, in request
r = self.pool_manager.request(method, url,
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 75, in request
return self.request_encode_url(
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 97, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"api_key": null,
"api_version": "v1",
"append_hash": false,
"apply": false,
"ca_cert": null,
"client_cert": null,
"client_key": null,
"context": null,
"force": false,
"host": null,
"kind": "Namespace",
"kubeconfig": null,
"merge_type": null,
"name": "testing",
"namespace": null,
"password": null,
"persist_config": null,
"proxy": null,
"resource_definition": null,
"src": null,
"state": "present",
"template": null,
"username": null,
"validate": null,
"validate_certs": null,
"wait": false,
"wait_condition": null,
"wait_sleep": 5,
"wait_timeout": 120
}
},
"msg": "Failed to get client due to HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd75aca4b20>: Failed to establish a new connection: [Errno 111] Connection refused'))"
}
@foroozf001: OK so maybe not #314. Thought we could take a shortcut figuring out the root of your problem.
We will need more info to try and reproduce this.
ansible-galaxy collection list
in the version you are running. playbook.main.yaml
? The example output doesn't seem to line up.k8s
role? What is the complete task declaration that causes the error?I am not able to reproduce this with -
pip list | egrep 'kubernetes|openshift|ansible'
ansible 2.10.7
ansible-base 2.10.5
kubernetes 12.0.1
openshift 0.11.2
You are using community.kubernetes 1.1.0
which reproduces this behavior
# ansible-galaxy collection list
# /home/akasurde/collections/ansible_collections
Collection Version
-------------------- -------
community.kubernetes 1.1.0
TASK [k8s_info] *******************************************************************************
task path: /tmp/test_k8s/k8s_info.yml:4
redirecting (type: modules) ansible.builtin.k8s_info to community.kubernetes.k8s_info
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to get client due to HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10ff0cd60>: Failed to establish a new connection: [Errno 61] Connection refused'))"}
Please remove the older community.kubernetes collection and upgrade to latest i.e. 1.1.1
.
@foroozf001: OK so maybe not #314. Thought we could take a shortcut figuring out the root of your problem.
We will need more info to try and reproduce this.
- You said "I have used Ansible with community.kubernetes before without fail. I expect to connect to my cluster." When did it start failing? What changed? Did you upgrade the collection or ansible itself?
I upgraded from Ansible 2.9 to 2.10. I have upgraded the collection as well.
- What version of kubernetes.core/community.kubernetes you are running? You can use
ansible-galaxy collection list
in the version you are running.
ffo@ffo-ThinkPad-T490:~$ ansible-galaxy collection list | grep kubernetes
community.kubernetes 1.1.1
- Is the example playbook under "Steps To Reproduce" the same as
playbook.main.yaml
? The example output doesn't seem to line up.
Yes it is the same playbook.
- What is in the
k8s
role? What is the complete task declaration that causes the error?
The K8S role is simply this.
- name: Create a k8s namespace
community.kubernetes.k8s:
name: testing
api_version: v1
kind: Namespace
state: present
@foroozf001 Are you still facing issue after upgrading?
SUMMARY
Running an Ansible playbook against my cluster results in a failed connection error.
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
I can not establish any Ansible connection with my cluster so all use-cases fail.
Hosts-file
EXPECTED RESULTS
I have used Ansible with community.kubernetes before without fail. I expect to connect to my cluster.
ACTUAL RESULTS