You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
I have created simple operator using kopf and its has children service created which is a clusterip service using adopt. if this service is deleted it should be recreated automatically
Actual Behavior
Child service of operator is not recreated automatically
If at least one finalizer exists on the object, k8s will not delete it, but only mark for deletion (by setting metadata.deletionTimestamp).
The operator must release its child object from duties somehow, when it decides it is suitable — by removing its own finalizer (but keeping the others if necessary):
This operation will read the child Service to get its current list of finalizers, remove its own finalizer, and put the modified list of the finalizers back to the object.
Another way is to indeed add an additional handler — e.g. the spy-handlers.
Please use kopf>=0.19 for this. The apiVersion: v1 objects are supported only in 0.19rc2 & 0.19+.
@kopf.on.create(...)defcreate_fn(**_):
svc= {'apiVersion': 'v1', 'metadata': {'name' : name}, 'spec': { 'selector': {'app': 'db'}, 'type': 'NodePort'}}
kopf.adopt(svc, owner=body)
kopf.label(svc, {'my-app': True})
obj=api.create_namespaced_service(namespace, svc)
@kopf.on.event('', 'v1', 'services')defservice_event(meta, name, namespace, event, **_):
# filter out irrelevant servicesifnotmeta.get('labels', {}).get('my-app'):
return# Now, it is surely our service.# NB: the old service is already absent at this event, so there will be no HTTP 409 conflict.ifevent['type'] =='DELETED':
_recreate_service(name, namespace)
This will produce extra log messages for all existing services in the namespace/cluster, which looks not nice, but does not create problems. This could be solved soon with decorator-level filtering instead of calling the handler for a single if statement (see issues).
Expected Behavior
I have created simple operator using kopf and its has children service created which is a clusterip service using adopt. if this service is deleted it should be recreated automatically
Actual Behavior
Child service of operator is not recreated automatically
Steps to Reproduce the Problem
Is there way to adopt child in such a way that we can recreate automatically or is there vent handler available
Specifications
kubectl version
) 1.14python --version
) 3.7pip freeze --all
)The text was updated successfully, but these errors were encountered: