in modules/python/clients/kubernetes_client.py [0:0]
def create_deployment(self, template, namespace="default"):
"""
Create a Deployment in the specified namespace using the provided YAML template.
:param template: YAML template for the Deployment.
:param namespace: Namespace where the Deployment will be created.
:return: Name of the created Deployment.
"""
try:
deployment_obj = yaml.safe_load(template)
response = self.app.create_namespaced_deployment(
body=deployment_obj,
namespace=namespace
)
return response.metadata.name
except yaml.YAMLError as e:
raise Exception(f"Error parsing deployment template: {str(e)}") from e
except Exception as e:
raise Exception(f"Error creating deployment {template}: {str(e)}") from e