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

Set prometheus in agent mode and upgrade kube-prometheus-stack to 30.0.0 #510

Merged
merged 11 commits into from
Jan 12, 2022

Conversation

NissesSenap
Copy link
Contributor

@NissesSenap NissesSenap commented Jan 10, 2022

Upgrade kube-prometheus-stack to 30.0.0, this to get the latest prometheus-operator version so we can use
prometheus in agent mode.
Also run prometheus in agent mode, this to lower resource usage and a smarter way of handling WAL.

This to get the latest prometheus-operator version so we can use
prometheus-agent.
@NissesSenap NissesSenap self-assigned this Jan 10, 2022
@NissesSenap
Copy link
Contributor Author

NissesSenap commented Jan 10, 2022

When upgrading the helm chart I got the following error:

Error: cannot patch "prometheus-kube-state-metrics" with kind Deployment: Deployment.apps "prometheus-kube-state-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"prometheus", "app.kubernetes.io/name":"kube-state-metrics"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable
│ 
│   with module.aks1_core.module.prometheus["prometheus"].helm_release.prometheus,
│   on .terraform/modules/aks1_core/modules/kubernetes/prometheus/main.tf line 38, in resource "helm_release" "prometheus":
│   38: resource "helm_release" "prometheus" {

I solved it by deleting the deployment:

k delete deployment prometheus-kube-state-metric -n prometheus

Just as it says in the error:

# OLD
  selector:
    matchLabels:
      app.kubernetes.io/name: kube-state-metrics

# new 
  selector:
    matchLabels:
      app.kubernetes.io/instance: prometheus
      app.kubernetes.io/name: kube-state-metrics

@NissesSenap
Copy link
Contributor Author

It's possible to run in agent mode but it's currently not a first class citizen: prometheus-operator/prometheus-operator#3989

But I will try to apply the workaround described here: https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/customizations/prometheus-agent.md

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
@NissesSenap NissesSenap changed the title Upgrade kube-prometheus-stack to 30.0.0 Set prometheus in agent mode and upgrade kube-prometheus-stack to 30.0.0 Jan 10, 2022
@NissesSenap
Copy link
Contributor Author

As a part of upgrading to this version you will need to delete the old prometheus PVC.
Ether delete the prometheus xks
kubectl delete prometheus xks -n prometheus

or you can also set the replicas to 0
kubectl edit prometheus xks -n prometheus

Then delete the PVC

kubectl delete pvc prometheus-xks-db-prometheus-xks-0 prometheus-xks-db-prometheus-xks-1 -n prometheus

Copy link
Contributor

@phillebaba phillebaba left a comment

Choose a reason for hiding this comment

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

LGTM! Great Work 🌹

@NissesSenap NissesSenap merged commit c84b049 into main Jan 12, 2022
@NissesSenap NissesSenap deleted the prom_agent branch January 12, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants