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

feat: separate podlabels in controller-manager and audit deployment #3378

Merged

Conversation

bobertrublik
Copy link
Contributor

@bobertrublik bobertrublik commented May 9, 2024

What this PR does / why we need it:

We want to introduce new labels across our infrastructure and validate them using the K8sRequiredLabels policy. Depending on its workload each pod will receive a different workload label which is then used to enrich metrics collected from it. The Gatekeeper Helm chart doesn't allow setting separate labels for the controller manager pod and audit pod which will break our idea.

Special notes for your reviewer:

I was following the PR below to apply the changes here.

I had to remove {{- include "gatekeeper.podLabels" . | nindent 8 }} across all jobs since it's removed from the helpers.tpl file.

@bobertrublik bobertrublik requested a review from a team as a code owner May 9, 2024 13:02
@bobertrublik bobertrublik changed the title Separate podlabels in controller-manager and audit deployment feat: separate podlabels in controller-manager and audit deployment May 9, 2024
@bobertrublik bobertrublik marked this pull request as draft May 9, 2024 13:13
@bobertrublik bobertrublik marked this pull request as ready for review May 9, 2024 13:30
obj = strings.Replace(obj, " priorityClassName: system-cluster-critical", " {{- if .Values.audit.priorityClassName }}\n priorityClassName: {{ .Values.audit.priorityClassName }}\n {{- end }}", 1)
obj = strings.Replace(obj, " - emptyDir: {}", " {{- if .Values.audit.writeToRAMDisk }}\n - emptyDir:\n medium: Memory\n {{ else }}\n - emptyDir: {}\n {{- end }}", 1)
}

if kind == DeploymentKind {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR @bobertrublik! We need to ensure backward compatibilities as to not break existing things users might be using and reduce developer toil. can you pls bring back all the existing podLabels and add support for new audit and controller manager podLabels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, I'm just a little unsure how to approach this. Are you saying that I should readd the .Values.podLabels field to ensure backward compatibility? Are the labels set there added to all pods and we can additionally set the .Values.controllerManager.podLabels and .Values.audit.podLabels to add specific ones?

Copy link
Member

Choose a reason for hiding this comment

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

yes, Pod can have many labels. Please restore the existing values.podLabels field to ensure backward compatibility. Then add the new labels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I restored .values.podLabels and kept .Values.controllerManager.podLabels and .Values.audit.podLabels. 🙂

@bobertrublik bobertrublik force-pushed the separate-deployment-labels branch 4 times, most recently from dacf5ee to 5be0b6a Compare May 13, 2024 12:57
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.23%. Comparing base (3350319) to head (f8bb2b6).
Report is 113 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (f8bb2b6). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (f8bb2b6)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3378      +/-   ##
==========================================
- Coverage   54.49%   48.23%   -6.27%     
==========================================
  Files         134      219      +85     
  Lines       12329    14989    +2660     
==========================================
+ Hits         6719     7230     +511     
- Misses       5116     6946    +1830     
- Partials      494      813     +319     
Flag Coverage Δ
unittests 48.23% <ø> (-6.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bobertrublik
Copy link
Contributor Author

Hello @ritazh, I rebased the branch onto main and wanted to ask you for a short review and approval. 🙂

Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

@ritazh ritazh requested a review from a team July 24, 2024 23:41
@ritazh ritazh added this to the v3.17.0 milestone Jul 24, 2024
@sozercan
Copy link
Member

@bobertrublik looks like there are a few merge conflicts, could you ptal when you get a chance? thanks!

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@bobertrublik
Copy link
Contributor Author

Thanks for approving, I fixed the conflicts. 🙂

Signed-off-by: Robert Bublik <mail@robertbublik.de>
@ritazh ritazh merged commit 4be061f into open-policy-agent:master Aug 1, 2024
20 checks passed
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.

6 participants