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

Enable prometheus metrics scraping #156

Merged
merged 1 commit into from
May 16, 2022

Conversation

alebedev87
Copy link
Contributor

@alebedev87 alebedev87 commented May 13, 2022

Result:
image

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 13, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alebedev87

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2022
@alebedev87
Copy link
Contributor Author

/assign @DhritiShikhar

@DhritiShikhar
Copy link
Contributor

Should there be any tests for this @alebedev87 ?

Copy link
Contributor

@arjunrn arjunrn left a comment

Choose a reason for hiding this comment

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

Just a couple of questions. Otherwise looks good.

Makefile Outdated
@@ -156,6 +156,10 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
cd config/manager && $(KUSTOMIZE) edit set image quay.io/openshift/origin-external-dns-operator=${IMG}
# webhook volume and service are added explicilty so that they don't land in the bundle where it's managed by OLM
cd config/default && $(KUSTOMIZE) edit add patch --path=manager_webhook_volume_patch.yaml
# add service monitor with certificate from the service serving certificate
cd config/prometheus && $(KUSTOMIZE) edit add resource monitor.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not add the monitor resource directly or put another way include it in the default target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, added monitor.yaml as default resource, tlsConfig patch is added for make deploy only (could not do it for the bundle to not leave uncommitted changes).

README.md Outdated Show resolved Hide resolved

The ExternalDNS Operator exposes [controller-runtime metrics](https://book-v1.book.kubebuilder.io/beyond_basics/controller_metrics.html) in the format expected by [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator).
`ServiceMonitor` object is created in the operator's namespace (by default `external-dns-operator`), make sure that your instance of the Prometheus Operator is properly configured to find it.
You can check `.spec.serviceMonitorNamespaceSelector` and `.spec.serviceMonitorSelector` fields of `prometheus` resource and edit the operator's namespace or service monitor accordingly:
Copy link
Contributor

Choose a reason for hiding this comment

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

If the namespace can be add by adding a label then shouldn't we be adding the label to the namespace resource? Or is it not possible when the namespace is created by OLM.

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, OLM creates the installation namespace and I didn't see a way to customize it.
Added labeling of the namespace in README when the bundle is generated.

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK the cluster prometheus should not be modified to monitor non cluster operator. Instead another prometheus instance should be used. The instructions are here.

@@ -6,16 +6,11 @@ resources:
- ../rbac
- ../manager
- ../webhook
- ../prometheus
Copy link
Contributor

Choose a reason for hiding this comment

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

So since the prometheus directory is already included do you need to add it with kustomize as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understood this one. It's already in kustomize. You can deploy using make deploy or with a bundle. Both ways will create ServieMonitor and all the necessary things.

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is was that if the ServiceMonitor was already part of the kustomize do you need to add it again for the make deploy target.

@arjunrn
Copy link
Contributor

arjunrn commented May 13, 2022

Do you also want to explicity set the metrics port while initializing the operator so that the configuration matches what is currently implicit.

@alebedev87
Copy link
Contributor Author

alebedev87 commented May 13, 2022

@DhritiShikhar : for the e2e test we'd need a reliable way of verifying the target creation in prometheus. Will try to find something.

@DhritiShikhar
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2022
@alebedev87
Copy link
Contributor Author

As discussed with Dhriti, the e2e testing is possible but quite heavy. Prometheus targets are not exposed on the Kubernetes level (CRs or ConfigMaps/Secrets), they have to be retrieved from the prometheus API which most often is queried by exec inf into the prometheus POD.

@alebedev87
Copy link
Contributor Author

/assign @quarterpin

@quarterpin
Copy link

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label May 16, 2022
@alebedev87
Copy link
Contributor Author

/assign @xenolinux

@CFields651
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label May 16, 2022
@alebedev87
Copy link
Contributor Author

/label docs-approved

Don't expect any docs update for the built-in controller-runtime metrics.

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label May 16, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 16, 2022

@alebedev87: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit ce1d5e0 into openshift:main May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants