mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
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:
commit
c7750d5717
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user