Skip to content
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

optional pod selector labels #98

Merged
merged 3 commits into from
Jun 29, 2022
Merged

optional pod selector labels #98

merged 3 commits into from
Jun 29, 2022

Conversation

tanmaykm
Copy link
Contributor

This allows enabling core-dump-handler only on pods that match a configured selector pod-label. Useful if we need core-dump-handler only for a subset of our workload. The composer checks for the pod label and only prepares the upload only if the pod matches the selector configured. The default (empty selector label) is to have no selectors and enable collection for all. Only the existence of the label is checked for.

The selector can be configured via daemonSet.podSelectorLabel in values.yaml, which translates to the POD_SELECTOR_LABEL environment variable in the daemonset.

@No9
Copy link
Collaborator

No9 commented Jun 23, 2022

Thanks for this as well.
In principle this is a great feature but I need to map the specifics to the cloudevent work going on in this branch.
https://github.com/IBM/core-dump-handler/tree/cloud-event
I want to keep the labeling for the different features consistent. It might be able to land 'as-is' or it may make sense to define a specific label.
I'm busy today but I'll provide guidance before the weekend.
If you could apply the rustfmt fix I'd appreciate it.

@tanmaykm
Copy link
Contributor Author

Thanks for looking into it!
Added 89010c6 to fix ci and rustfmt

tanmaykm added 2 commits June 24, 2022 06:29
This allows enabling core-dump-handler only on pods that match a configured selector pod-label. Useful if we need core-dump-handler only for a subset of our workload. The composer checks for the pod label and only prepares the upload only if the pod matches the selector configured. The default (empty selector label) is to have no selectors and enable collection for all. Only the existence of the label is checked for.

The selector can be configured via `daemonSet.podSelectorLabel` in `values.yaml`, which translates to the `POD_SELECTOR_LABEL` environment variable in the daemonset.
@@ -214,6 +214,7 @@ The agent pod has the following environment variables and these are all set by t
* INTERVAL - The amount of time in milliseconds between each check of the core dump folder for files to upload.
* SCHEDULE - A CRON formatted string [See cron library](https://github.com/mvniekerk/tokio-cron-scheduler#usage).
* USE_INOTIFY - Set a listener for the coredump folder can be used in conjunction with SCHEDULE
* POD_SELECTOR_LABEL - Optional selector label to filter pods that have core dump collection enabled. Default (empty) disables filter.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation this should be COMP_POD_SELECTOR_LABEL
Also add an an example label so it's clear how this works

@@ -33,6 +33,7 @@ daemonset:
hostDirectory: "/var/mnt/core-dump-handler"
coreDirectory: "/var/mnt/core-dump-handler/cores"
crioEndpoint: "unix:///run/containerd/containerd.sock"
podSelectorLabel: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation should be in composer not daemonset

@@ -33,6 +33,7 @@ daemonset:
hostDirectory: "/var/mnt/core-dump-handler"
coreDirectory: "/var/mnt/core-dump-handler/cores"
crioEndpoint: "unix:///run/containerd/containerd.sock"
podSelectorLabel: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation should be in composer not daemonset

@@ -33,6 +33,7 @@ daemonset:
hostDirectory: "/var/mnt/core-dump-handler"
coreDirectory: "/var/mnt/core-dump-handler/cores"
crioEndpoint: "unix:///run/containerd/containerd.sock"
podSelectorLabel: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation should be in composer not daemonset

@@ -34,6 +34,7 @@ daemonset:
hostDirectory: "/var/mnt/core-dump-handler"
coreDirectory: "/var/mnt/core-dump-handler/cores"
crioEndpoint: "unix:///run/containerd/containerd.sock"
podSelectorLabel: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation should be in composer not daemonset

@@ -45,6 +45,8 @@ spec:
value: {{ .Values.daemonset.deployCrioConfig | quote }}
- name: CRIO_ENDPOINT
value: {{ .Values.daemonset.crioEndpoint | quote }}
- name: POD_SELECTOR_LABEL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have COMP_ prefix

@@ -205,6 +205,9 @@
"crioEndpoint": {
"type": "string"
},
"podSelectorLabel": {
"type": "string"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move to composer definition

@@ -33,6 +33,7 @@ daemonset:
hostDirectory: "/var/mnt/core-dump-handler"
coreDirectory: "/var/mnt/core-dump-handler/cores"
crioEndpoint: "unix:///run/containerd/containerd.sock"
podSelectorLabel: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per conversation should be in composer not daemonset

@No9
Copy link
Collaborator

No9 commented Jun 26, 2022

The good news is that this doesn't interfere with the cloud events.

The bad news is that the pod selector config mapping isn't quite in the right place.

All config that is passed to the composer should be in the composer section
https://github.com/IBM/core-dump-handler/blob/main/charts/core-dump-handler/values.yaml#L23
The values should map to an environment variable prefixed with COMP_ in the agent.

Could you add an example of a label value in the Environment config
https://github.com/IBM/core-dump-handler/pull/98/files#diff-35330df803a4bbfce6b8b734490d5f0b77bb117755aeac1958500a4934a86bb8R217

The values section in the docs also needs to be updated along with the environment section.
https://github.com/IBM/core-dump-handler/pull/98/files#diff-35330df803a4bbfce6b8b734490d5f0b77bb117755aeac1958500a4934a86bb8R248

I've gone through the PR to also highlight where I think these changes need to be done.
Hope it isn't too noisy.

(Edit) Once the mapping is aligned I'm happy to merge and push a release.

@tanmaykm
Copy link
Contributor Author

I have now added 1186de2 which hopefully addresses these. Thanks for the guidance!

@No9 No9 merged commit a1ccae1 into IBM:main Jun 29, 2022
@No9
Copy link
Collaborator

No9 commented Jun 29, 2022

Looks good - I have some dep updates to land then I'll put together a release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants