ansible k8s module failing to connect to cluster with 503

I’m trying to use ansible new k8s module (based ok k8_raw from 2.6) to maintain an aks k8 cluster. While I can work with the cluster with kubectl , any command with the k8s cluster fails with a 503 error.

For example this task:

- name: deploy kured daemonset
  k8s:
    state: present
    context: "{{ cluster_name}}"
    host: "redacted"# tried specifying this, but does not helo
    kubeconfig: "~/.kube/config"
    src: "aks/utils/kured-ds.yaml"

I suspect I’m missing something with configuring how to connect to the cluster

And failure:

Traceback (most recent call last):
  File "/home/alonisser/.ansible/tmp/ansible-tmp-1549320815.98-157731551192134/AnsiballZ_k8s.py", line 113, in <module>
    _ansiballz_main()
  File "/home/alonisser/.ansible/tmp/ansible-tmp-1549320815.98-157731551192134/AnsiballZ_k8s.py", line 105, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/alonisser/.ansible/tmp/ansible-tmp-1549320815.98-157731551192134/AnsiballZ_k8s.py", line 48, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_k8s_payload_IYmGFG/__main__.py", line 233, in <module>
  File "/tmp/ansible_k8s_payload_IYmGFG/__main__.py", line 229, in main
  File "/tmp/ansible_k8s_payload_IYmGFG/ansible_k8s_payload.zip/ansible/module_utils/k8s/raw.py", line 131, in execute_module
  File "/tmp/ansible_k8s_payload_IYmGFG/ansible_k8s_payload.zip/ansible/module_utils/k8s/common.py", line 172, in get_api_client
  File "/home/alonisser/.local/lib/python2.7/site-packages/openshift/dynamic/client.py", line 103, in __init__
    self.__init_cache()
  File "/home/alonisser/.local/lib/python2.7/site-packages/openshift/dynamic/client.py", line 113, in __init_cache
    self.__resources.update(self.parse_api_groups())
  File "/home/alonisser/.local/lib/python2.7/site-packages/openshift/dynamic/client.py", line 169, in parse_api_groups
    new_group[version] = self.get_resources_for_api_version(prefix, group['name'], version, preferred)
  File "/home/alonisser/.local/lib/python2.7/site-packages/openshift/dynamic/client.py", line 181, in get_resources_for_api_version
    resources_response = load_json(self.request('GET', path))['resources']
  File "/home/alonisser/.local/lib/python2.7/site-packages/openshift/dynamic/client.py", line 363, in request
    _return_http_data_only=params.get('_return_http_data_only', True)
  File "/home/alonisser/.local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 321, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/home/alonisser/.local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 155, in __call_api
    _request_timeout=_request_timeout)
  File "/home/alonisser/.local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 342, in request
    headers=headers)
  File "/home/alonisser/.local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 231, in GET
    query_params=query_params)
  File "/home/alonisser/.local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (503)
Reason: Service Unavailable

Ansible version: 2.7/8(dev)

What am I missing?

Last few days, I crake my head on this and I believe I can able to help you :

Thanks, this does not seem to work for me, seems that the client appends version/openshift to the http request -which won’t work because this isn’t an openshift installation :frowning:
Can you please share what openshift version is installed in your system? and what ansible? Maybe it’s this kind of quirk