Merge pull request #42845 from brejoc/updates-for-kubernetes-2.0.0

API changes for Kubernetes version 2.0.0
This commit is contained in:
Nicole Thomas 2017-08-11 10:04:30 -04:00 committed by GitHub
commit c7750d5717

View File

@ -40,6 +40,14 @@ try:
except ImportError:
HAS_LIBS = False
try:
# There is an API change in Kubernetes >= 2.0.0.
from kubernetes.client import V1beta1Deployment as AppsV1beta1Deployment
from kubernetes.client import V1beta1DeploymentSpec as AppsV1beta1DeploymentSpec
except ImportError:
from kubernetes.client import AppsV1beta1Deployment
from kubernetes.client import AppsV1beta1DeploymentSpec
log = logging.getLogger(__name__)
@ -762,7 +770,7 @@ def create_deployment(
'''
body = __create_object_body(
kind='Deployment',
obj_class=kubernetes.client.V1beta1Deployment,
obj_class=AppsV1beta1Deployment,
spec_creator=__dict_to_deployment_spec,
name=name,
namespace=namespace,
@ -1013,7 +1021,7 @@ def replace_deployment(name,
'''
body = __create_object_body(
kind='Deployment',
obj_class=kubernetes.client.V1beta1Deployment,
obj_class=AppsV1beta1Deployment,
spec_creator=__dict_to_deployment_spec,
name=name,
namespace=namespace,
@ -1276,9 +1284,9 @@ def __dict_to_object_meta(name, namespace, metadata):
def __dict_to_deployment_spec(spec):
'''
Converts a dictionary into kubernetes V1beta1DeploymentSpec instance.
Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance.
'''
spec_obj = kubernetes.client.V1beta1DeploymentSpec()
spec_obj = AppsV1beta1DeploymentSpec()
for key, value in iteritems(spec):
if hasattr(spec_obj, key):
setattr(spec_obj, key, value)