From f9f54f20484b7b920560be1075c9996b453127d7 Mon Sep 17 00:00:00 2001 From: Fabricio Henrique Ramos Date: Thu, 3 Feb 2022 17:07:11 -0300 Subject: [PATCH] Add support for python-kubernetes 12 This work is part of debian integration effort. On CentOS 7 python-kubernetes version 8 is used. On Debian Bullseye python-kubernetes version 12 is used. The API was slightly changed in version 12. Determine the module version and handle Kubernetes configuration based on version. Test Plan: Pass: Build package and ISO CentOS Pass: Controller unlocked/enabled/available CentOS Story: 2009101 Task: 44596 Signed-off-by: Fabricio Henrique Ramos Change-Id: I85fb672c086f3f0281b079ef54e5da3ad0943168 --- .../rook-ceph-provisioner/templates/_helpers.tpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stx-rook-ceph/stx-rook-ceph/helm-charts/rook-ceph-provisioner/templates/_helpers.tpl b/stx-rook-ceph/stx-rook-ceph/helm-charts/rook-ceph-provisioner/templates/_helpers.tpl index 932f8a6..0719f80 100644 --- a/stx-rook-ceph/stx-rook-ceph/helm-charts/rook-ceph-provisioner/templates/_helpers.tpl +++ b/stx-rook-ceph/stx-rook-ceph/helm-charts/rook-ceph-provisioner/templates/_helpers.tpl @@ -5,6 +5,7 @@ import os import subprocess from cephclient import wrapper +from kubernetes import __version__ as K8S_MODULE_VERSION from kubernetes import config from kubernetes import client from kubernetes.client import Configuration @@ -12,6 +13,8 @@ from kubernetes.client.rest import ApiException from six.moves import http_client as httplib from cephclient import wrapper +K8S_MODULE_MAJOR_VERSION = int(K8S_MODULE_VERSION.split('.')[0]) + # Kubernetes Files KUBERNETES_ADMIN_CONF = '/etc/kubernetes/admin.conf' @@ -35,9 +38,12 @@ class KubeOperator(object): raise exception.KubeNotConfigured() config.load_kube_config(KUBERNETES_ADMIN_CONF) + if K8S_MODULE_MAJOR_VERSION < 12: + c = Configuration() + else: + c = Configuration().get_default_copy() # Workaround: Turn off SSL/TLS verification - c = Configuration() c.verify_ssl = False Configuration.set_default(c)