-
Notifications
You must be signed in to change notification settings - Fork 194
feat: add logging.development config option for manager #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add logging.development config option for manager #639
Conversation
yorugac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kristina-Pianykh, the changes seem to work fine 🙌 I have just one small request to move the logic out to the helper file: please see my coment.
| - --leader-elect | ||
| {{- end }} | ||
| - --metrics-bind-address=:8443 | ||
| - --zap-devel={{ if hasKey .Values.manager.logging "development" }}{{ .Values.manager.logging.development | toString }}{{ else }}true{{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to move this out into _helpers.tpl, to simplify readability a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ad4c4d5 to
3375e25
Compare
3375e25 to
8a05509
Compare
yorugac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, @Kristina-Pianykh! LGTM 🙌
This PR introduces a new configuration option in the Helm chart to control the logging mode (development/production) of the
k6-operator-controller-manager.The issue and the proposed solution are laid out in #638.
Closes #638.
TL;DR: Currently, the manager's logs are in the console format, which can be difficult to parse for structured logging platforms like Datadog or Loki. This change makes the logging mode configurable, allowing users to switch to a production-mode logger.
The change is backward compatible (the default logger remains in the development mode by default as it’s currently configured).
To benefit from the production-mode logger:
Test
IMG_NAME=k6operator IMG_TAG=foo make manifests helm IMG_TAG=foo helm template k6-operator ./charts/k6-operator -f ./charts/k6-operator/values.yaml --set manager.image.tag=$IMG_TAG --set manager.logging.development=falseOutput (development-mode logging, console formatting, as expected):
2025-08-31T16:19:06Z INFO setup starting manager 2025-08-31T16:19:06Z INFO controller-runtime.metrics Starting metrics server 2025-08-31T16:19:06Z INFO controller-runtime.metrics Serving metrics server {"bindAddress": ":8080", "secure": false} 2025-08-31T16:19:06Z INFO starting server {"name": "health probe", "addr": "[::]:8081"} I0831 16:19:06.969169 1 leaderelection.go:257] attempting to acquire leader lease k6-operator-system/fcdfce80.io... I0831 16:19:07.176597 1 leaderelection.go:271] successfully acquired lease k6-operator-system/fcdfce80.io 2025-08-31T16:19:07Z DEBUG events k6-operator-controller-manager-54bc86d7db-xm69v_bf5e5a34-b65b-4a07-a8bc-6681266b22a1 became leader {"type": "Normal", "object": {"kind":"Lease","namespace":"k6-operator-system","name":"fcdfce80.io","uid":"9004a3f9-27ee-4434-be9c-055100855876","apiVersion":"coordination.k8s.io/v1","resourceVersion":"692"}, "reason": "LeaderElection"} 2025-08-31T16:19:07Z INFO Starting EventSource {"controller": "testrun", "controllerGroup": "k6.io", "controllerKind": "TestRun", "source": "kind source: *v1.Pod"} 2025-08-31T16:19:07Z INFO Starting EventSource {"controller": "privateloadzone", "controllerGroup": "k6.io", "controllerKind": "PrivateLoadZone", "source": "kind source: *v1alpha1.PrivateLoadZone"} 2025-08-31T16:19:07Z INFO Starting EventSource {"controller": "testrun", "controllerGroup": "k6.io", "controllerKind": "TestRun", "source": "kind source: *v1alpha1.TestRun"}Chart.yaml:
values.yaml:
Output (the default logger is overriden with the production logger):
{"level":"info","ts":"2025-08-31T15:27:23Z","logger":"setup","msg":"starting manager"} {"level":"info","ts":"2025-08-31T15:27:23Z","msg":"starting server","name":"health probe","addr":"[::]:8081"} {"level":"info","ts":"2025-08-31T15:27:23Z","logger":"controller-runtime.metrics","msg":"Starting metrics server"} {"level":"info","ts":"2025-08-31T15:27:23Z","logger":"controller-runtime.metrics","msg":"Serving metrics server","bindAddress":":8443","secure":false} {"level":"info","ts":"2025-08-31T15:27:23Z","msg":"Starting EventSource","controller":"testrun","controllerGroup":"k6.io","controllerKind":"TestRun","source":"kind source: *v1.Pod"} {"level":"info","ts":"2025-08-31T15:27:23Z","msg":"Starting EventSource","controller":"testrun","controllerGroup":"k6.io","controllerKind":"TestRun","source":"kind source: *v1alpha1.TestRun"}