Esempio n. 1
0
def __dict_to_deployment_spec(spec):
    """
    Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance.
    """
    spec_obj = AppsV1beta1DeploymentSpec(template=spec.get("template", ""))
    for key, value in iteritems(spec):
        if hasattr(spec_obj, key):
            setattr(spec_obj, key, value)

    return spec_obj
Esempio n. 2
0
def __dict_to_deployment_spec(spec):
    '''
    Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance.
    '''
    spec_obj = AppsV1beta1DeploymentSpec()
    for key, value in iteritems(spec):
        if hasattr(spec_obj, key):
            setattr(spec_obj, key, value)

    return spec_obj
Esempio n. 3
0
 def _build_deployment(self):
     pod_spec = V1PodSpec(containers=self.containers,
                          volumes=self.volumes,
                          node_name=self.node_name,
                          hostname=self.host_name)
     template = V1PodTemplateSpec(metadata=V1ObjectMeta(
         labels=self.target_labels, annotations=self.annotations or None),
                                  spec=pod_spec)
     strategy = AppsV1beta1DeploymentStrategy(
         type="RollingUpdate",
         rolling_update=AppsV1beta1RollingUpdateDeployment(max_surge=0))
     deployment_spec = AppsV1beta1DeploymentSpec(replicas=self.replicas,
                                                 selector=self.selector,
                                                 template=template,
                                                 strategy=strategy)
     deployment = AppsV1beta1Deployment(metadata=self.meta,
                                        spec=deployment_spec)
     return deployment