Update Grafana Kubernetes components
The engineering team regularly pushes updates to Grafana Cloud Kubernetes Monitoring and the Grafana Agent. You must update these components manually to take advantage of any updates to Grafana dashboards, alerting & recording rules, and new Grafana Agent features.
Update dashboards, alerting rules, and recording rules
To get the latest versions of dashboards, alerting rules, and recording rules, you must uninstall and reinstall Grafana Agent.
Warning: Uninstalling Agent deletes its associated dashboard folder, and its alert and recording rule namespace. Custom dashboards or alerts added to the default locations for this integration are also removed. Be sure to save a copy of these if you’ve modified the provisioned versions.
- Navigate to your Grafana Cloud instance and click Monitoring and then Kubernetes.
- Click Configuration.
- Click Uninstall dashboards and alert rules.
- Click Install dashboards and alert rules to reinstall.
From here, you can reinstall Agent. This will install the latest version of the Kubernetes Monitoring components into your Grafana instance.
Update Grafana Agent Operator
To upgrade the Agent Operator chart to the required version, use the following command:
helm upgrade ksm grafana/grafana-agent-operator --set image.tag=<version-number> -n <namespace>
Replace the following field values:
- Replace
<version-number>
with image version number you want to use. - Replace
<namespace>
with the namespace in which the Grafana Agent Helm release was deployed.
Update Grafana Agent
After performing the uninstall/reinstall step for dashboards and rules, you need to also update Grafana Agent. The Agent instructions in the Kubernetes Monitoring Configuration tab contain the latest version of the preconfigured Agent manifests.
The recommended way to run Grafana Agent in Kubernetes is as a StatefulSet. If the Kubernetes objects have the same name and are in the same namespace, the kubectl apply -f
command updates the objects to the latest version.
Update the container image of your Grafana Agent StatefulSet
To update the image version, run the following command:
kubectl set image statefulset/<grafana-agent-sts-name> grafana-agent=grafana/agent:<version-number>
Replace the following field values:
- Replace
<grafana-agent-sts-name>
with the name of the Grafana Agent StatefulSet. - Replace
<version-number>
with the image version number you want to use.
Replace your Grafana Agent deployment with a StatefulSet
To replace your Grafana Agent deployment with a StatefulSet (recommended, and now the default), follow the instructions on the Kubernetes Monitoring Configuration tab. Following the steps updates your existing Agent ConfigMap (or creates it if it doesn’t exist), and creates an Agent StatefulSet.
Once that’s up and running, you can delete the existing Deployment by running the following command:
kubectl delete deployment/grafana-agent
At this point you’ll have an Agent StatefulSet scraping Prometheus metrics in your cluster and shipping these to Grafana Cloud. This StatefulSet is also configured by default to collect Kubernetes events and ship these to Grafana Cloud Loki. You can disable this by modifying the StatefulSet’s ConfigMap.
Update kube-state-metrics
You can update kube-state-metrics using one of the following methods:
Update the kube-state-metrics Helm chart
The Kubernetes Monitoring configuration instructions include a step to deploy kube-state-metrics using Helm.
To upgrade the kube-state-metrics chart to the required version, use the following command:
helm upgrade <helm-release-name> prometheus-community/kube-state-metrics --set image.tag=<version-number> -n <namespace>
Replace the following field values:
- Replace
<helm-release-name>
with the name of the Helm release for kube-state-metrics. - Replace
<version-number>
with the image version number you want to use. - Replace
<namespace>
with the namespace in which the kube-state-metrics Helm release was deployed.
Update a kube-state-metrics deployment
To update the image version in the kube-state-metrics deployment, run the following command:
kubectl set image deployment/<ksm-deployment-name> grafana-agent=grafana/agent:<version-number>
Replace the following field values:
- Replace
<ksm-deployment-name>
with the name of the kube-state-metrics deployment. - Replace
<version-number>
with the image version number you want to use.