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

[stable/mongodb-replicaset] Prometheus Metrics export - #6282

Merged
k8s-ci-robot merged 8 commits into
helm:masterfrom
scality:ft/ZENKO-125
Jul 15, 2018
Merged

k8s-ci-robot merged 8 commits into
helm:masterfrom
scality:ft/ZENKO-125

Conversation

@ssalaues

Copy link
Copy Markdown
Collaborator

Original PR #5874

What this PR does / why we need it:
Adds Prometheus metrics to the mongodb-replicaset chart using the a readonly clusterMonitor mongodb account for metrics authentication.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:
Fixes from the previous PR

  • Uses clusterMonitor role for authenticating the metrics exporter into the replicaset
  • Fixes best practices for specifying images
  • Removed makefile (was originally intending for the Dockerfile to be hosted here but not necessary)

Need clarification on the Prometheus annotations.

  • Since I am using the annotations to also define the exporter port and path, should I leave those defined in the metrics container definition? Or would it be preferred to create separate values not tied to the annotations?

Salim Salaues added 4 commits June 22, 2018 14:50
Adds a sidecar to export replicaset metrics
1. Moves context of ssl configuration script into /work-dir
where certain files are expected to be created.

2. Specifies the --sslMode=requireSSL flag on the container command when using TLS
as specified by mongo docs.
https://docs.mongodb.com/manual/tutorial/configure-ssl/
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 22, 2018
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 22, 2018
@ssalaues

Copy link
Copy Markdown
Collaborator Author

/assign @unguiculus

@unguiculus

Copy link
Copy Markdown
Member

/assign

@agolomoodysaada

agolomoodysaada commented Jun 26, 2018 •

Copy link
Copy Markdown
Contributor

@ssalaues , you can find prometheus operator settings in the kafka chart example: https://github.com/kubernetes/charts/blob/master/incubator/kafka/values.yaml#L266-L278

There they automatically deploy the kafka exporter and ServiceMonitor CRD. I suggest this PR do something similar.

Check this template: https://github.com/kubernetes/charts/blob/master/incubator/kafka/templates/servicemonitors.yaml

@ssalaues

Copy link
Copy Markdown
Collaborator Author

Thanks @agolomoodysaada ! I'll try that out

Separate metric configuration options from annotations
@ssalaues

Copy link
Copy Markdown
Collaborator Author

I just added a commit to move away from the always on annotations that was specified before and separate the metrics configuration (had it combined with the annotations before). This will make it easier to setup ServiceMonitor for Prometheus Operator and have it separate from traditional Prometheus Service Discovery.

Comment thread stable/mongodb-replicaset/README.md Outdated
enabled: true
image: ssalaues/mongodb-exporter
imageTag: 0.5
imagePullPolicy: IfNotPresent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Follow best practices:

metrics:
  image:
    repository:
    tag:
    pullPolicy:

Comment thread stable/mongodb-replicaset/README.md Outdated
metrics:
enabled: true
image: ssalaues/mongodb-exporter
imageTag: 0.5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about using 0.6.1?

mongo admin "${ssl_args[@]}" --eval "db.createUser({user: '$admin_user', pwd: '$admin_password', roles: [{role: 'root', db: 'admin'}]})"
if [[ "$METRICS" == "true" ]]; then
log "Creating cluterMonitor user..."
mongo admin "${ssl_args[@]}" --eval "db.auth('$admin_user', '$admin_password'); db.createUser({user: '$metrics_user', pwd: '$metrics_password', roles: [{role: 'clusterMonitor', db: 'admin'}]})"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

- name: metrics
port: {{ .Values.metrics.port }}
targetPort: metrics
{{- end }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Be consistent with the rest of the chart and indent as follows:

  {{- if .Values.metrics.enabled }}
    - name: metrics
       port: {{ .Values.metrics.port }}
       targetPort: metrics
  {{- end }}

-mongodb.tls-cert=/work-dir/mongo.pem
{{- end }}
-web.metrics-path={{ .Values.metrics.path }}
-web.listen-address=:{{ .Values.metrics.port }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are timeout flags in the latest release I added in percona/mongodb_exporter#100. Please make them configurable as well.

{{ toYaml .Values.extraLabels | indent 8 }}
{{- end }}
annotations:
{{- if .Values.metrics.enabled }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You still set the annotations when metrics are enable. You don't need them when using the operator. They should be optional.

@unguiculus

Copy link
Copy Markdown
Member

@gianrubio Would you mind having a look as well?

@ssalaues

ssalaues commented Jul 4, 2018

Copy link
Copy Markdown
Collaborator Author

Made the requested changes @unguiculus. Thanks!

Comment thread stable/mongodb-replicaset/README.md Outdated
metrics:
enabled: true
image:
repository: ssalaues/mongodb-exporter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why you are not using the oficial image?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, there is no official image.

exec:
command:
- sh
- -ec

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should specify the command as above for the container using - |- and then adding the complete script instea of line by line as list.

@ssalaues ssalaues Jul 4, 2018 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added the script lines as requested. Would it be preferred to also combine the sh -ec after the - |- or keep as is?

Comment thread stable/mongodb-replicaset/values.yaml Outdated
# socketTimeout: 3s
# syncTimeout: 1m
# prometheusServiceDiscovery: true
# resources: {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dont comment out all the values.

metrics:
  enabled: false
  image:
    repository: ssalaues/mongodb-exporter
    tag: 0.6.1
    pullPolicy: IfNotPresent
  port: 9216
  path: "/metrics"
  socketTimeout: 3s
  syncTimeout: 1m
  prometheusServiceDiscovery: true
  resources: {}

@ssalaues

ssalaues commented Jul 5, 2018 •

Copy link
Copy Markdown
Collaborator Author

Added a commit to change the |- to >-. I realized this was an issue when testing the changes of the liveness probe command to |- yaml block (previous PR had escaped newlines).

@unguiculus

Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 15, 2018
@unguiculus

Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2018
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ssalaues, unguiculus

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

The pull request process is described here

Details 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 Jul 15, 2018
@k8s-ci-robot
k8s-ci-robot merged commit dc6ef90 into helm:master Jul 15, 2018
NicolasT added a commit to scality/charts that referenced this pull request Jul 15, 2018
…labels

* kubernetes/master: (411 commits)
  [stable/efs-provisioner] Chart for efs-provisioner, a Kubernetes external-storage provisioner (helm#3233)
  [stable/filebeat] filebeat fixes (helm#6332)
  [stable/stolon] Add support for priorityClasses (helm#6607)
  [stable/external-dns] Add support for priorityClasses (helm#6606)
  [stable/minio] Add support for priorityClasses (helm#6604)
  [stable/cluster-autoscaler] Add support for priorityClasses (helm#6603)
  [stable/oauth2-proxy] Add support for priorityClasses (helm#6586)
  [stable/elasticsearch-exporter] add support for priorityClasses (helm#6584)
  [stable/traefik] adding support for traefik wildcard certificates (helm#6015)
  gcloud-sqlproxy: add tolerations and affinity to the Deployment (helm#6495)
  Review readme (helm#6399)
  [stable/mongodb-replicaset] Prometheus Metrics export (helm#6282)
  [stable/artifactory-ha] Typo fix: livessProbed->livenessProbed (helm#6462)
  [stable/artifactory] livessProbed->livenessProbed (helm#6461)
  [incubator/kube-spot-termination-notice-handler] Add Support for Tolerations (helm#5813)
  [stable/kanister-operator] RBAC changes and kanister profile creation (helm#6280)
  fix redis-ha NOTE.txt, stable/redis-ha don't create master-0 pod (helm#6131)
  [stable/concourse] add support for custom envvars for the web containers (helm#6441)
  upgrade to latest prometheus release 2.3.2 and alertmanager 0.15.1 (helm#6623)
  cert-manager: fast-forward to upstream 777ce6f4 (helm#6625)
  ...
@ssalaues

Copy link
Copy Markdown
Collaborator Author

Thank you for your help in getting this merged @unguiculus

Jnig pushed a commit to Jnig/charts that referenced this pull request Nov 13, 2018
* [stable/mongodb-replicaset] Prometheus Metrics export

Adds a sidecar to export replicaset metrics

* bugfix: Fix TLS issues

1. Moves context of ssl configuration script into /work-dir
where certain files are expected to be created.

2. Specifies the --sslMode=requireSSL flag on the container command when using TLS
as specified by mongo docs.
https://docs.mongodb.com/manual/tutorial/configure-ssl/

* Documentation on metrics options

* Bump Chart Version

* Update metrics config options

Separate metric configuration options from annotations

* Best practices, cleanup, and requested changes

* Consistency and additional requested changes

* Switch commands to folded yaml blocks

Signed-off-by: Jakob Niggel <[email protected]>
gsemet pushed a commit to gsemet/charts that referenced this pull request Nov 13, 2018
* [stable/mongodb-replicaset] Prometheus Metrics export

Adds a sidecar to export replicaset metrics

* bugfix: Fix TLS issues

1. Moves context of ssl configuration script into /work-dir
where certain files are expected to be created.

2. Specifies the --sslMode=requireSSL flag on the container command when using TLS
as specified by mongo docs.
https://docs.mongodb.com/manual/tutorial/configure-ssl/

* Documentation on metrics options

* Bump Chart Version

* Update metrics config options

Separate metric configuration options from annotations

* Best practices, cleanup, and requested changes

* Consistency and additional requested changes

* Switch commands to folded yaml blocks
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants