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: Add annotations only to the karpenter service #6065

Closed
wants to merge 2 commits into from

Conversation

afreyermuth98
Copy link
Contributor

Description
Allow to put some annotations only for the service. It's useful when we have some prometheus operator and I don't want to put my prometheus annotations on every resources.
How was this change tested?
I deployed it using the chart locally. As it's a very small change it's ok :)
Does this change impact docs?

  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@afreyermuth98 afreyermuth98 requested a review from a team as a code owner April 19, 2024 14:53
Copy link

netlify bot commented Apr 19, 2024

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit b0e769a
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/662285535e2d8f0008012d29

@@ -5,7 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "karpenter.labels" . | nindent 4 }}
{{- with .Values.additionalAnnotations }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change for anyone who is currently expecting that these additionalAnnotations are going to be added to their service. Just to understand your use-case -- which annotations are you trying to add to the service that you don't want to add to the other components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, maybe we can put both additional annotations AND service annotations to the service ?
I want to put the prometheus annotations only on my service and not on my pods for example.

Copy link
Contributor

@jonathan-innis jonathan-innis Apr 23, 2024

Choose a reason for hiding this comment

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

I want to put the prometheus annotations only on my service and not on my pods for example.

Can you clarify a bit on the use-case here? I'd like to avoid getting building bespoke configuration for each resource so I think we need a pretty common use-case.

Is there a possibility that you could leverage helm template and then use an overlay to update the Service to be what you want? Or maybe use jq/yq to update the configuration directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the time, people have prometheus as a resource discovery. So it looks for every pods / services that have the prometheus annotations to allow scraping. If I put my annotations inside the additionalAnnotations, my pods AND my service would be discovered by prometheus and be scrapped what I want to avoid.
I don't want to customize my way to deploy / do some hotfix like that.
I think we can just combine additionalAnnotations AND serviceAnnotations here what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

my service would be discovered by prometheus and be scrapped what I want to avoid

I thought the mechanism that Prometheus discovered services and pods were different and you would be able to filter out services that contain a given label through your prometheus config. Do you mind sharing your prometheus config?

I also don't see this pattern just from glancing around at a few helm charts. Do you have some examples of helm charts out in the community that implement this pattern of sectioning out their service and pod annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's indeed possible but my config is scraping every pods AND service that have these annotations without any differences. So yeah maybe this is a bad usage on my side but for example, see node exporter from prometheus :
https://github.com/prometheus-community/helm-charts/blob/a1a6d92b04d4ac3eb553348b127ab7871045c934/charts/prometheus-node-exporter/values.yaml#L95

Copy link
Contributor

Choose a reason for hiding this comment

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

@afreyermuth98 I'm just realizing that we have a podAnnotations value. Can you just use this to add the annotations you're targeting to the pods? https://github.com/aws/karpenter-provider-aws/blob/main/charts/karpenter/templates/deployment.yaml#L30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @jonathan-innis my use case is the contrary. I want to annotate only the service ^^

Copy link
Contributor

Choose a reason for hiding this comment

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

So, if you use the service here, I think you are going to run into problems. The service is going to randomly pick pods from the selector and that's going to cause issues with something that is running with leader election. Sometimes, you're going to get the thing that's actually firing metrics. Sometimes, you're going to get the thing that isn't firing metrics. We added the service mainly for: 1) Endpoint discovery for the ServiceMonitor and 2) Serving the webhook endpoint.

Can you just scrape the pods here?

@jonathan-innis jonathan-innis self-assigned this Apr 21, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8755536921

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 82.0%

Totals Coverage Status
Change from base Build 8733550496: 0.0%
Covered Lines: 5371
Relevant Lines: 6550

💛 - Coveralls

Copy link
Contributor

This PR has been inactive for 14 days. StaleBot will close this stale PR after 14 more days of inactivity.

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

Successfully merging this pull request may close these issues.

3 participants