Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

K8s-event logging #136

Closed
nolar opened this issue Jul 4, 2019 · 0 comments
Closed

K8s-event logging #136

nolar opened this issue Jul 4, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@nolar
Copy link
Contributor

nolar commented Jul 4, 2019

It would be convenient, if all the important log messages are automatically sent to K8s events, same as they are logged to stdout/stderr.

Only the important messages, not the debug messages.

Both Kopf-internal messages (already sent to k8s now), and the operator-produced messages (as logged via the per-object logger kwarg).

There should be a way to opt out at least on a per-message level — i.e. to explicitly say to not send it as a k8s-event, but to keep it as a log message only (except as logging it as a debug-message).

import kopf

@kopf.on.create('zalando.org', 'v1', 'kopfexamples')
def create_fn(spec, logger, **kwargs):
    image = spec.get('image')
    if not image.startswith('trusted.repo.com/'):
        logger.warning("Only images from trusted.repo.com are trusted. "
                       "Got potentially insecure image %r", image)

This will hide Kopf's explicit k8s-event-sending routines — as it goes against Kopf's mission (of not being a K8s client library). But this will integrate Python logging machinery into K8s's logging/eventing subsystem — which perfectly fits into Kopf's mission of bringing Pythonic ways of coding to the K8s operators field.

@nolar nolar self-assigned this Jul 4, 2019
@nolar nolar added the enhancement New feature or request label Jul 4, 2019
@nolar nolar mentioned this issue Jul 4, 2019
2 tasks
@nolar nolar closed this as completed Jul 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant