To generate custom Kubernetes YAML instead of the default generic definition, provide a deployment_callback function.
Callback Signature:
deployment_callback(resource_name, image_name, namespace) -> str
resource_name: The name of the resource.image_name: The name of the image (this is the value returned by your build_callback if one was used).namespace: The target namespace.
Return Value: The callback must return a string or blob containing the Kubernetes YAML definition.
def my_microservice_deployment_generator(resource_name, image_name, namespace) -> str:
return f"""
apiVersion: apps/v1
kind: Deployment
metadata:
name: {resource_name}
namespace: {namespace}
spec:
template:
spec:
containers:
- name: {resource_name}
image: {image_name}
"""
git_resource('myMicroservice', 'git@example.com/myRepo.git', deployment_callback=my_microservice_deployment_generator)