Only own and reconcile Prometheus if supported
What does this MR do?
Only own and reconcile Prometheus if supported
If the Prometheus API is available in `monitoring.coreos.com/v1`, then
own Prometheus objects.
If Prometheus is enabled in the configuration, it will reconcile related
objects.
Closes
https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/issues/339
Changelog: fixed
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
Merge Request Title and Description are up to date, accurate, and descriptive -
MR targeting the appropriate branch -
MR has a green pipeline on GitLab.com -
When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes -
Documentation created/updated -
Tests added -
Integration tests added to GitLab QA -
Equivalent MR/issue for omnibus-gitlab opened -
Validate potential values for new configuration settings. Formats such as integer10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.
Related issues
Closes #339 (closed)
Test plan
Without Prometheus API available
-
TAG=339-prometheus-condition task build_operator
-
task deploy_operator
-
Confirm that there is no message about owning Prometheus:
$ stern -n gitlab-system -l control-plane=controller-manager -i Prometheus + gitlab-controller-manager-6fb664b4c8-bn5xh › kube-rbac-proxy + gitlab-controller-manager-6fb664b4c8-bn5xh › manager
With Prometheus API available
-
Install Prometheus CRDs:
$ LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name) $ curl -sLO https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml $ kubectl apply -f bundle.yaml --server-side # needed this flag to avoid error about annotations being too long ... $ kubectl api-resources | grep -i prometheus prometheusagents promagent monitoring.coreos.com/v1alpha1 true PrometheusAgent prometheuses prom monitoring.coreos.com/v1 true Prometheus prometheusrules promrule monitoring.coreos.com/v1 true PrometheusRule
-
Restart the Operator Pod by deleting it.
-
Watch the logs and confirm it owns Prometheus:
$ stern -n gitlab-system -l control-plane=controller-manager -i Prometheus + gitlab-controller-manager-5445f78774-m8sdr › kube-rbac-proxy + gitlab-controller-manager-5445f78774-m8sdr › manager gitlab-controller-manager-5445f78774-m8sdr manager 2023/07/11 22:04:38 mitchdebug: comparing: Probe Prometheus gitlab-controller-manager-5445f78774-m8sdr manager 2023/07/11 22:04:38 mitchdebug: comparing: Prometheus Prometheus gitlab-controller-manager-5445f78774-m8sdr manager 2023-07-11T22:04:38Z INFO controllers.GitLab Using monitoring.coreos.com/v1/Prometheus gitlab-controller-manager-5445f78774-m8sdr manager 2023-07-11T22:04:54Z INFO Starting EventSource {"controller": "gitlab", "controllerGroup": "apps.gitlab.com", "controllerKind": "GitLab", "source": "kind source: *v1.Prometheus"}
Edited by Mitchell Nielsen