Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/kong] Options to install Prometheus plugin with ServiceMonitor #14346

Merged
merged 10 commits into from
Aug 19, 2019
Merged

[stable/kong] Options to install Prometheus plugin with ServiceMonitor #14346

merged 10 commits into from
Aug 19, 2019

Conversation

decayofmind
Copy link
Collaborator

What this PR does / why we need it:

This PR provides an option to install kong-prometheus plugin as KongPlugin custom resource.
Prometheus-operator ServiceMonitor could be installed as well.

As a side-effect of this PR, Kong CRDs are not being deleted with the release anymore. It prevents from losing Kong declarative configuration while uninstalling Kong.

The proposed change was inspired by Prometheus-operator and Velero charts.

Checklist

  • DCO signed
  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [stable/chart])

@helm-bot helm-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label May 30, 2019
@helm-bot helm-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 30, 2019
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 30, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @decayofmind. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@decayofmind
Copy link
Collaborator Author

/assign @hbagdi

@decayofmind
Copy link
Collaborator Author

/assign @shashiranjan84

@decayofmind
Copy link
Collaborator Author

@hbagdi any luck this will be useful?

@hbagdi
Copy link
Collaborator

hbagdi commented Jun 13, 2019

@decayofmind Sorry for the delayed responses on this. Have been very busy with multiple things flying around. I'll try to get to this soon.

@hbagdi
Copy link
Collaborator

hbagdi commented Jun 18, 2019

We will keep this PR around for now.
There is a feature that needs to land in this Helm chart which exposes a metrics port on all Kong deployments, based on a ConfigMap, similar to how we do it here.

Once that get's in, this PR can be simplified quite a bit:

  • please do not over-complicate the logic of how installation is done for CRDs, let's keep it simple.
  • While automatically enabling Prometheus plugin when ServiceMonitor is enabled, it is going a bit too far IMHO of providing a magical button for everything. It is okay to document thing and ask users to enable the plugin by themselves, depending on how they are running Kong (with or without Ingress Controller, with or without DB)

@hbagdi
Copy link
Collaborator

hbagdi commented Jul 3, 2019

Since #15079 is merged in. We can work on this PR.
Please see my comment above.

Also, it probably might be more accurate to provide serviceMonitor.enabled, rather than metrics.serviceMonitor.enabled as a config value. Please refer to other stable charts in this repository.

@decayofmind
Copy link
Collaborator Author

@hbagdi serviceMonitor.enabled is under metrics., because if metrics itself are disabled it has no sense. I can imagine a case, where someone will leave metrics.enabled: false, but serviceMonitor.enabled: true.

But, if you think it's better, I have no objections to change the variable name as you said :)

@decayofmind
Copy link
Collaborator Author

  • please do not over-complicate the logic of how installation is done for CRDs, let's keep it simple.

For installation of CRDs I've used a built-in Helm feature/hook (https://github.com/helm/helm/blob/master/docs/charts_hooks.md#the-available-hooks) to install CRDs before any other template. If something else is over-complicated, let me now, I'll remove it from PR.

  • While automatically enabling Prometheus plugin when ServiceMonitor is enabled, it is going a bit too far IMHO of providing a magical button for everything. It is okay to document thing and ask users to enable the plugin by themselves, depending on how they are running Kong (with or without Ingress Controller, with or without DB)

A ServiceMonitor will be installed only if metrics.serviceMonitor.create set to true.

Copy link
Collaborator

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

Please rebase this PR on latest master.

stable/kong/templates/cleanup-crds.yaml Outdated Show resolved Hide resolved
stable/kong/templates/prometheus-plugin.yaml Outdated Show resolved Hide resolved
@decayofmind
Copy link
Collaborator Author

@hbagdi I've done some changes you requested, could you please take a look at my PR one more time.

@@ -0,0 +1,13 @@
{{- if and .Values.ingressController.enabled .Values.ingressController.metrics.enabled }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I said in a review before, let's remove this.
The user can create an additional KongPlugin resource if the need be after the Kong Ingress Controller is installed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do note that Kong will expose some basic observability stats even if this plugin is not enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, let it be as you're suggesting, I've got the point :)

@@ -251,5 +251,5 @@ spec:
volumes:
- name: custom-nginx-template-volume
configMap:
name: {{ .Release.Name }}-kong-default-custom-server-blocks
name: {{ template "kong.fullname" . }}-default-custom-server-blocks
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It may not be the matter of this PR, but in general, all objects in a chart should be addressing {{ template "<chartname.fullname>" }} in its names.

It allows a user to override objects naming for the whole installation, by taking into account .Values.nameOverride and .Values.fullNameOverride (not yet in Kong chart) variables passed to the chart.

@@ -8,6 +8,9 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
"helm.sh/hook": crd-install
"helm.sh/hook-delete-policy": "before-hook-creation"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe these changes can go away once KongPlugin resource is removed.

@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 16, 2019
Signed-off-by: Roman Komkov <[email protected]>
@@ -8,6 +8,9 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
"helm.sh/hook": crd-install
"helm.sh/hook-delete-policy": "before-hook-creation"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these changes to CRDs can be removed since the Prometheus plugin is not being automatically created.

Another problem that I see here:
If multiple Kong Ingress Controllers are being installed one after the other, then this will incorrectly delete the CRD first, and then re-install the CRD. This will lead to deletion of all the custom resources that were present in the cluster before the installation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@decayofmind Could you address this comment?
Thanks!

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 16, 2019

@decayofmind Left one comment and other than that, this PR looks good.
#16293 will be merged before this so please rebase again.

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 16, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 16, 2019
@hbagdi
Copy link
Collaborator

hbagdi commented Aug 19, 2019

Please rebase on master. This is real close and almost ready to merge.

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 19, 2019

@decayofmind Please address the one outstanding comment and fix the lint failure.

Once that's done, we are good to merge.

@decayofmind
Copy link
Collaborator Author

@hbagdi It seems like everything is finally fixed

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 19, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: decayofmind, hbagdi

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2019
@k8s-ci-robot k8s-ci-robot merged commit 75c2526 into helm:master Aug 19, 2019
@hbagdi
Copy link
Collaborator

hbagdi commented Aug 19, 2019

@decayofmind Thank you for your contribution!

@decayofmind decayofmind deleted the kong/prometheus-integration branch August 20, 2019 00:36
kengou pushed a commit to kengou/charts that referenced this pull request Sep 18, 2019
helm#14346)

* Options to install Prometheus plugin with ServiceMonitor

Signed-off-by: Roman Komkov <[email protected]>

* Changes after code review

Signed-off-by: Roman Komkov <[email protected]>

* Removed ingressController and plugin dependency.

Signed-off-by: Roman Komkov <[email protected]>

* Version bumped

Signed-off-by: Roman Komkov <[email protected]>

* Remove helm-hook annotations

Signed-off-by: Roman Komkov <[email protected]>

* Remove trailing whitespace

Signed-off-by: Roman Komkov <[email protected]>
ramkumarvs pushed a commit to yugabyte/charts-helm-fork that referenced this pull request Sep 30, 2019
helm#14346)

* Options to install Prometheus plugin with ServiceMonitor

Signed-off-by: Roman Komkov <[email protected]>

* Changes after code review

Signed-off-by: Roman Komkov <[email protected]>

* Removed ingressController and plugin dependency.

Signed-off-by: Roman Komkov <[email protected]>

* Version bumped

Signed-off-by: Roman Komkov <[email protected]>

* Remove helm-hook annotations

Signed-off-by: Roman Komkov <[email protected]>

* Remove trailing whitespace

Signed-off-by: Roman Komkov <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged. ok-to-test size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants