Merge "Add support for python-kubernetes 12"

This commit is contained in:
Zuul 2022-02-24 14:02:54 +00:00 committed by Gerrit Code Review
commit cf2f630c76

View File

@ -5,6 +5,7 @@ import os
import subprocess import subprocess
from cephclient import wrapper from cephclient import wrapper
from kubernetes import __version__ as K8S_MODULE_VERSION
from kubernetes import config from kubernetes import config
from kubernetes import client from kubernetes import client
from kubernetes.client import Configuration from kubernetes.client import Configuration
@ -12,6 +13,8 @@ from kubernetes.client.rest import ApiException
from six.moves import http_client as httplib from six.moves import http_client as httplib
from cephclient import wrapper from cephclient import wrapper
K8S_MODULE_MAJOR_VERSION = int(K8S_MODULE_VERSION.split('.')[0])
# Kubernetes Files # Kubernetes Files
KUBERNETES_ADMIN_CONF = '/etc/kubernetes/admin.conf' KUBERNETES_ADMIN_CONF = '/etc/kubernetes/admin.conf'
@ -35,9 +38,12 @@ class KubeOperator(object):
raise exception.KubeNotConfigured() raise exception.KubeNotConfigured()
config.load_kube_config(KUBERNETES_ADMIN_CONF) 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 # Workaround: Turn off SSL/TLS verification
c = Configuration()
c.verify_ssl = False c.verify_ssl = False
Configuration.set_default(c) Configuration.set_default(c)