ansible k8s模块无法使用503连接到集群-将/ version / openshift附加到非openshift集群

时间:2019-02-04 22:56:29

标签: kubernetes ansible

我正在尝试使用新的an k8s模块(基于2.6的ok k8_raw)来维护aks k8集群。 虽然我可以使用kubectl使用集群,但是使用k8s集群的任何命令都会失败,并显示503错误。

例如,此任务:

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

失败:

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

可用的版本:2.7 / 8(dev)

我想念什么?

更新: 当我将打印语句添加到下面的模块所使用的库中时,我发现在管道中的某处/ version / openshift附加到了主机名,这当然会失败,因为它是一个非openshift集群 有没有解决此错误的方法?

1 个答案:

答案 0 :(得分:0)

答案:原来有两个失败的请求。首先是版本/ openshift被客户端捕获,不会导致崩溃。该崩溃实际上是由于我的集群指标服务器发生错误而发生的,尽管ansible使用的k8客户端并没有真正需要它,但仍然对该请求失败。 因此,如果有人碰碰它,可能会有所帮助