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

Adding ClusterIP service in helm chart to expose controller metrics. #73

Merged
merged 1 commit into from
May 27, 2021

Conversation

vijtrip2
Copy link
Contributor

Description of changes:

Adding ClusterIP service in helm chart to expose controller metrics.

It is much simpler and easier to update prometheus scraping configuration with a static endpoint.

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

@vijtrip2 vijtrip2 self-assigned this May 27, 2021
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Great! 👍

Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

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

I don't think this is necessary for any of the default installations we offer. There is no reason to access the controller pods through a service as they offer no network APIs. I would rather see a separate service spec added to cluster gitops alongside the helm chart if a customer wants to expose metrics in this way.

If this is a must, then at least gating the service behind a create: true/false in the helm values would be required. (Default being false)

@a-hilaly
Copy link
Member

I don't think this is necessary for any of the default installations we offer. There is no reason to access the controller pods through a service as they offer no network APIs. I would rather see a separate service spec added to cluster gitops alongside the helm chart if a customer wants to expose metrics in this way.

There is a metrics api exposed at :8080 in every controller https://github.com/aws-controllers-k8s/runtime/blob/main/pkg/config/config.go#L60-L64

@a-hilaly
Copy link
Member

If this is a must, then at least gating the service behind a create: true/false in the helm values would be required. (Default being false)

LGTM, If we're going with solution, we could also gate the metrics API using service controller flags, thinking --enable-metrics-server

@RedbackThomson
Copy link
Contributor

I don't think this is necessary for any of the default installations we offer. There is no reason to access the controller pods through a service as they offer no network APIs. I would rather see a separate service spec added to cluster gitops alongside the helm chart if a customer wants to expose metrics in this way.

There is a metrics api exposed at :8080 in every controller https://github.com/aws-controllers-k8s/runtime/blob/main/pkg/config/config.go#L60-L64

I understand that, but does Prometheus not detect all metrics servers in every pod by default?

@vijtrip2
Copy link
Contributor Author

vijtrip2 commented May 27, 2021

"If this is a must, then at least gating the service behind a create: true/false in the helm values would be required. (Default being false)"

Good Idea. I will definitely do this.
[Edit:] Done.

"I understand that, but does Prometheus not detect all metrics servers in every pod by default?"

While prototyping, I did not find this to be the case. I can double check.
a) First I tried to use prometheus Kubernetes Service Discovery for finding these metrics but was not able to successfully do it.
b) Then I tried this static config method where we ask Prometheus to scrape the metric from a static endpoint. It was very simple, straight forward and clean.
Hence I went ahead with method (b).

@RedbackThomson
Copy link
Contributor

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented May 27, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, RedbackThomson, vijtrip2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson,vijtrip2]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 8f9a108 into aws-controllers-k8s:main May 27, 2021
@a-hilaly
Copy link
Member

I understand that, but does Prometheus not detect all metrics servers in every pod by default?

AFAIK Prometheus does not detect any metrics at all by default - it needs to be configured for pod discovery

Comment on lines +19 to +21
service:
create: false
type: "ClusterIP"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@vijtrip2 @RedbackThomson @a-hilaly

Can we rename this to specify that it has to do with the metrics server and not the service controller itself?

Perhaps something like this?

metrics:
  service:
    # Set to true to automatically create a Kubernetes Service resource for the
    # Prometheus metrics server endpoint in controller
    create: false
    # Which Type to use for the Kubernetes Service?
    # See: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
    type: ClusterIP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I will get it done.

@@ -0,0 +1,30 @@
{{- if .Values.service.create }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we rename this file to templates/metrics-service.yaml please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants