def __init__(self, name=None, selector=None, labels=None, image_metadata=None,<EOL>namespace='<STR_LIT:default>', create_in_cluster=False, from_template=None):
self.namespace = namespace<EOL>if (from_template is not None) and (name is not None or selector is not None or<EOL>labels is not None or image_metadata is not None):<EOL><INDENT>raise ConuException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>elif from_template is not None:<EOL><INDENT>self.body = yaml.safe_load(from_template)<EOL>self.name = self.body['<STR_LIT>']['<STR_LIT:name>']<EOL><DEDENT>elif (name is not None and selector is not None and<EOL>labels is not None and image_metadata is not None):<EOL><INDENT>self.name = name<EOL>self.pod = Pod.create(image_metadata)<EOL>self.spec = client.V1DeploymentSpec(<EOL>selector=client.V1LabelSelector(match_labels=selector),<EOL>template=client.V1PodTemplateSpec(metadata=client.V1ObjectMeta(labels=selector),<EOL>spec=self.pod.spec))<EOL>self.metadata = client.V1ObjectMeta(name=self.name, namespace=self.namespace,<EOL>labels=labels)<EOL>self.body = client.V1Deployment(spec=self.spec, metadata=self.metadata)<EOL><DEDENT>else:<EOL><INDENT>raise ConuException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self.api = get_apps_api()<EOL>if create_in_cluster:<EOL><INDENT>self.create_in_cluster()<EOL><DEDENT>
Utility functions for kubernetes deployments.

:param name: str, name of the deployment
:param selector: Label selector for pods. Existing ReplicaSets whose pods are selected by
 this will be the ones affected by this deployment. It must match the pod template's labels
:param labels: dict, dict of labels
:param image_metadata: ImageMetadata
:param namespace: str, name of the namespace
:param create_in_cluster: bool, if True deployment is created in Kubernetes cluster
:param from_template: str, deployment template, example:
       - https://kubernetes.io/docs/concepts/workloads/controllers/deployment/