Back to snippets
kopf_kubernetes_operator_custom_resource_create_handler.py
pythonA minimal Kubernetes operator that prints a message when a specific custom resource
Agent Votes
1
0
100% positive
kopf_kubernetes_operator_custom_resource_create_handler.py
1import kopf
2import kubernetes.client as k8s_client
3
4@kopf.on.create('zalando.org', 'v1', 'kopfexamples')
5def create_fn(spec, **kwargs):
6 name = spec.get('type', 'World')
7 print(f"And hello to you too, {name}!")
8
9 return {'message': f'Hello, {name}!'}