Deploy the COS Lite observability stack on MicroK8s
|Summary||Deploy the COS Lite observability stack on MicroK8s.|
The COS Lite bundle is a Juju-based observability stack, running on Kubernetes. The bundle consists of Prometheus, Loki, Alertmanager and Grafana.
This tutorial assumes you have a Juju controller bootstrapped on a MicroK8s cloud that is ready to use. A typical setup using snaps can be found in the Juju docs. Follow the instructions there to install Juju and MicroK8s.
Let’s go and deploy that bundle!
For the COS Lite bundle deployment to go smoothly, make sure the following MicroK8s addons are enabled:
You can check this with
microk8s status, and if any are missing, enable them with
microk8s enable dns hostpath-storage
The bundle comes with Traefik to provide ingress, for which the
metallb addon should be enabled:
IPADDR=$(ip -4 -j route get 126.96.36.199 | jq -r '. | .prefsrc') microk8s enable metallb:$IPADDR-$IPADDR
To wait for all the addons to be rolled out,
microk8s kubectl rollout status deployments/hostpath-provisioner -n kube-system -w microk8s kubectl rollout status deployments/coredns -n kube-system -w microk8s kubectl rollout status daemonset.apps/speaker -n metallb-system -w
If you have an HTTP proxy configured, you will need to give this information to MicroK8s. See the proxy docs for details.
By default, MicroK8s will use 188.8.131.52 and 184.108.40.206 as DNS servers, which can be adjusted. See the dns docs for details.
Deploy the COS Lite bundle
It is usually a good idea to create a dedicated model for the COS Lite bundle. So let’s do just that and call the new model
juju add-model cos juju switch cos
Next, deploy the bundle with:
juju deploy cos-lite --trust
Now you can sit back and watch the deployment take place:
watch --color juju status --color --relations
The status of your deployment should eventually be very similar to the following:
> juju status --relations Model Controller Cloud/Region Version SLA Timestamp cos charm-dev microk8s/localhost 2.9.33 unsupported 16:00:00-00:00 App Version Status Scale Charm Channel Rev Address Exposed Message alertmanager active 1 alertmanager-k8s stable 28 10.152.183.92 no grafana active 1 grafana-k8s stable 39 10.152.183.130 no loki active 1 loki-k8s stable 41 10.152.183.216 no prometheus 2.33.5 active 1 prometheus-k8s stable 56 10.152.183.240 no traefik active 1 traefik-k8s stable 84 192.168.1.11 no Unit Workload Agent Address Ports Message alertmanager/0* active idle 10.1.55.21 grafana/0* active idle 10.1.55.17 loki/0* active idle 10.1.55.26 prometheus/0* active idle 10.1.55.27 traefik/0* active idle 10.1.55.16 Relation provider Requirer Interface Type Message alertmanager:alerting loki:alertmanager alertmanager_dispatch regular alertmanager:alerting prometheus:alertmanager alertmanager_dispatch regular alertmanager:grafana-dashboard grafana:grafana-dashboard grafana_dashboard regular alertmanager:grafana-source grafana:grafana-source grafana_datasource regular alertmanager:replicas alertmanager:replicas alertmanager_replica peer alertmanager:self-metrics-endpoint prometheus:metrics-endpoint prometheus_scrape regular grafana:grafana grafana:grafana grafana_peers peer loki:grafana-dashboard grafana:grafana-dashboard grafana_dashboard regular loki:grafana-source grafana:grafana-source grafana_datasource regular loki:metrics-endpoint prometheus:metrics-endpoint prometheus_scrape regular prometheus:grafana-dashboard grafana:grafana-dashboard grafana_dashboard regular prometheus:grafana-source grafana:grafana-source grafana_datasource regular prometheus:prometheus-peers prometheus:prometheus-peers prometheus_peers peer traefik:ingress-per-unit loki:ingress ingress_per_unit regular traefik:ingress-per-unit prometheus:ingress ingress_per_unit regular traefik:metrics-endpoint prometheus:metrics-endpoint prometheus_scrape regular
Now COS Lite is good to go: you can relate software with it to begin the monitoring!
Alternatively, you may want to deploy the bundle with one or more of our readily available overlays, which is what we’ll cover next.
Deploy the COS Lite bundle with overlays
An overlay is a set of model-specific modifications that avoid repetitive overhead in setting up bundles like COS Lite.
Specifically, we offer the following overlays:
offersoverlay makes your COS model ready for cross-model relations
storage-smalloverlay applies some defaults for the various storages used by the COS Lite components.
You can apply the
offers overlay do an existing COS Lite bundle by executing the
juju deploy command.
storage-small overlay, however, is applicable only on the first deployment.
So, if you were following the previous steps you would first need to switch to a new Juju model or remove all applications from the current one.
To use any of the overlays above, you need to include an
--overlay argument per overlay (applied in order):
curl -L https://raw.githubusercontent.com/canonical/cos-lite-bundle/main/overlays/offers-overlay.yaml -O curl -L https://raw.githubusercontent.com/canonical/cos-lite-bundle/main/overlays/storage-small-overlay.yaml -O juju deploy cos-lite \ --trust \ --overlay ./offers-overlay.yaml \ --overlay ./storage-small-overlay.yaml
When all the charms are deployed you can head over to browse their built-in web-UIs. You can find out their addresses from
juju status, which should have a section similar to:
Unit Workload Agent Address Ports Message alertmanager/0* active idle 10.1.24.70 grafana/0* active idle 10.1.24.71 loki/0* active idle 10.1.24.82 prometheus/0* active idle 10.1.24.73
In this case, the dashboards would be something like:
http://10.1.24.70:9093, for alertmanager
http://10.1.24.71:3000, for grafana
http://10.1.24.73:9090, for prometheus
(Note: the IP addresses are almost certainly going to be different in your case.)
That’s all folks!
Congrats, you made it! You should now be able to easily:
- deploy the COS Lite observability stack
- augment the COS Lite bundle file with ready-made overlays
- find the URLs of the web-UI dashboards
- Use the scrape target charm to have the COS stack scrape any open-metrics target.
- Relate your own charm to the COS stack with relation interfaces such as
- Configure alertmanager to have alerts routed to your receivers.
- If you need support, the charmhub community is the best place to get all your questions answered and get in touch with the community.
Last updated 5 months ago.