backport support for python-kubernetes v12 to ansible 2.9 (#72792)

Support for using python-kubernetes v12 has been added to the
new upstream repo:
https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/module_utils/common.py#L256-L261
This PR backports that support to ansible 2.9
pull/73178/head
Richard Megginson 5 years ago committed by GitHub
parent 5a92beb575
commit 7eb1703740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- k8s - add support for python-kubernetes v12 and later - backport of
support in community.kubernetes

@ -188,7 +188,12 @@ class K8sAnsibleMixin(object):
kubernetes.config.load_kube_config(auth.get('kubeconfig'), auth.get('context'))
# Override any values in the default configuration with Ansible parameters
configuration = kubernetes.client.Configuration()
# As of kubernetes-client v12.0.0, get_default_copy() is required here
try:
configuration = kubernetes.client.Configuration().get_default_copy()
except AttributeError:
configuration = kubernetes.client.Configuration()
for key, value in iteritems(auth):
if key in AUTH_ARG_MAP.keys() and value is not None:
if key == 'api_key':

@ -0,0 +1,8 @@
---
# just test that authentication works
- name: Ensure testing1 namespace exists
k8s:
api_version: v1
kind: Namespace
name: testing1

@ -65,6 +65,40 @@
recreate_crd_default_merge_expectation: recreate_crd is failed
playbook_namespace: ansible-test-k8s-older-openshift
- file:
path: "{{ virtualenv }}"
state: absent
no_log: yes
# Test works with kubernetes==11.* and kubernetes>11
- pip:
name:
- openshift
- kubernetes==11.*
- coverage
virtualenv: "{{ virtualenv }}"
virtualenv_command: "{{ virtualenv_command }}"
virtualenv_site_packages: no
- include_tasks: basic_validation.yml
- file:
path: "{{ virtualenv }}"
state: absent
no_log: yes
- pip:
name:
- openshift
- kubernetes>11
- coverage
virtualenv: "{{ virtualenv }}"
virtualenv_command: "{{ virtualenv_command }}"
virtualenv_site_packages: no
- include_tasks: basic_validation.yml
- file:
path: "{{ virtualenv }}"
state: absent

Loading…
Cancel
Save