How to use the kopf.on.delete function in kopf

To help you get started, we’ve selected a few kopf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zalando-incubator / kopf / tests / registries / test_decorators.py View on Github external
    @kopf.on.delete('group', 'version', 'plural')
    def fn(**_):
        pass
github zalando-incubator / kopf / tests / registries / test_decorators.py View on Github external
    @kopf.on.delete('group', 'version', 'plural',
                    id='id', registry=registry,
                    errors=ErrorsMode.PERMANENT, timeout=123, retries=456, backoff=78,
                    optional=optional,
                    labels={'somelabel': 'somevalue'},
                    annotations={'someanno': 'somevalue'})
    def fn(**_):
        pass
github aws-samples / containerized-game-servers / NodePortController / src / main.py View on Github external
@kopf.on.delete('', 'v1', 'pods', when=lambda meta, **_: meta['ownerReferences'][0]['kind']=='StatefulSet')
def delete_fn(meta, spec, namespace, logger, **kwargs):
    name=meta['labels']['statefulset.kubernetes.io/pod-name']
    logging.info(namespace)
    logging.info(name)
    api_response = api_instance.delete_namespaced_service(name,namespace)
    logging.info(api_response)
github elemental-lf / benji / src / benji / k8s_operator / crd / retention_schedule.py View on Github external
@kopf.on.delete('batch', 'v1', 'jobs', labels={LABEL_PARENT_KIND: ClusterBenjiRetentionSchedule.kind})
@kopf.on.field('batch', 'v1', 'jobs', field='status', labels={LABEL_PARENT_KIND: ClusterBenjiRetentionSchedule.kind})
def benji_track_job_status_cluster_retention_schedule(**kwargs) -> Optional[Dict[str, Any]]:
    return track_job_status(crd=ClusterBenjiRetentionSchedule, **kwargs)
github Viasat / nhd / nhd / TriadController.py View on Github external
@kopf.on.delete('sigproc.viasat.io', 'v1', 'triadsets')
def delete_fn(meta, **_):
    logger = NHDCommon.GetLogger(__name__)
    logger.info('Received delete request for TriadSet')
github zalando-incubator / kopf / examples / 12-embedded / example.py View on Github external
@kopf.on.delete('zalando.org', 'v1', 'kopfexamples')
def delete_fn(**_):
    pass
github elemental-lf / benji / src / benji / k8s_operator / crd / backup_schedule.py View on Github external
@kopf.on.delete(CRD_CLUSTER_BACKUP_SCHEDULE.api_group, CRD_CLUSTER_BACKUP_SCHEDULE.api_version,
                CRD_CLUSTER_BACKUP_SCHEDULE.plural)
def benji_backup_schedule_delete(name: str, namespace: str, body: Dict[str, Any], logger,
                                 **_) -> Optional[Dict[str, Any]]:
    try:
        benji.k8s_operator.scheduler.remove_job(job_id=cr_to_job_name(body, 'scheduler'))
    except JobLookupError:
        pass
    delete_all_dependant_jobs(name=name, namespace=namespace, kind=body['kind'], logger=logger)
github zalando-incubator / kopf / examples / 99-all-at-once / example.py View on Github external
@kopf.on.delete('zalando.org', 'v1', 'kopfexamples')
def delete(body, meta, spec, status, **kwargs):
    pass
github elemental-lf / benji / src / benji / k8s_operator / crd / backup_schedule.py View on Github external
@kopf.on.delete('batch', 'v1', 'jobs', labels={LABEL_PARENT_KIND: CRD_CLUSTER_BACKUP_SCHEDULE.name})
@kopf.on.field('batch', 'v1', 'jobs', field='status', labels={LABEL_PARENT_KIND: CRD_CLUSTER_BACKUP_SCHEDULE.name})
def benji_track_job_status_cluster_backup_schedule(**_) -> Optional[Dict[str, Any]]:
    return track_job_status(crd=CRD_CLUSTER_BACKUP_SCHEDULE, **_)
github elemental-lf / benji / src / benji / k8s_operator / crd / restore.py View on Github external
@kopf.on.delete(*BenjiRestore.group_version_plural())
def benji_backup_schedule_delete(name: str, namespace: str, body: Dict[str, Any], logger,
                                 **_) -> Optional[Dict[str, Any]]:
    delete_all_dependant_jobs(name=name, namespace=namespace, kind=body['kind'], logger=logger)