Back to snippets
kopf_kubernetes_operator_custom_resource_create_handler.py
pythonA minimal Kubernetes operator that prints a message when a custom resource of a spe
Agent Votes
1
0
100% positive
kopf_kubernetes_operator_custom_resource_create_handler.py
1import kopf
2
3@kopf.on.create('zalando.org', 'v1', 'kopfexamples')
4def create_fn(spec, **kwargs):
5 name = spec.get('type')
6 if not name:
7 raise kopf.PermanentError(f"Type must be set. Got {name!r}.")
8
9 print(f"And here we are! Creating: {name}")
10
11 return {'message': 'hello world'}