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. Kubernetes configuration is not correctly handled, nfv can't connect to kubernetes endpoints. This prevents the nfv from reporting its status as 'service-enabled', status being 'none'. Determine the module version and handle Kubernetes configuration based on version. CentOS 7 tests: Based on the fact that Debian test passed, and existence of a similar review[1], skipping the tests. Debian Bullseye tests: PASS: patch live controller by copying the contents of the full file, nfv is reported as 'service-enabled' [1]: https://review.opendev.org/c/starlingx/config/+/825448 Story: 2009101 Task: 44790 Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com> Change-Id: Id1b2f6d12bf9b0ffb63d6b75675660fec7e7f4d2
This commit is contained in:
parent
94ce75c0d4
commit
e5ced4ade4
|
@ -1,10 +1,11 @@
|
|||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
# Copyright (c) 2018-2022 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import kubernetes
|
||||
from kubernetes import __version__ as K8S_MODULE_VERSION
|
||||
from kubernetes.client.models.v1_container_image import V1ContainerImage
|
||||
from kubernetes.client.rest import ApiException
|
||||
from six.moves import http_client as httplib
|
||||
|
@ -12,6 +13,8 @@ from six.moves import http_client as httplib
|
|||
from nfv_common import debug
|
||||
from nfv_common.helpers import Result
|
||||
|
||||
K8S_MODULE_MAJOR_VERSION = int(K8S_MODULE_VERSION.split('.')[0])
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.clients.kubernetes_client')
|
||||
|
||||
|
||||
|
@ -45,7 +48,10 @@ def get_client():
|
|||
kubernetes.config.load_kube_config('/etc/kubernetes/admin.conf')
|
||||
|
||||
# Workaround: Turn off SSL/TLS verification
|
||||
c = kubernetes.client.Configuration()
|
||||
if K8S_MODULE_MAJOR_VERSION < 12:
|
||||
c = kubernetes.client.Configuration()
|
||||
else:
|
||||
c = kubernetes.client.Configuration().get_default_copy()
|
||||
c.verify_ssl = False
|
||||
kubernetes.client.Configuration.set_default(c)
|
||||
|
||||
|
|
Loading…
Reference in New Issue