Overview
Duration: 3:00
Before you get started!
Welcome to the world of operators! In this series of tutorials, we will walk you through all the necessary steps to explore and learn operators through some basic examples. Starting with just your laptop, you will learn how to use operators for sophisticated application management at scale, across multiple Kubernetes clusters, cloud virtual machines, and ultimately bare metal.
This tutorial assumes you have successfully completed the previous tutorial - “Services and port”.
What are operators?
Operators are pieces of software designed to drive other software. They encapsulate the operational code of applications, shifting the burden of lifecycle management from configuration files and manual steps to an operator instance. Operators are a form of automation that is gaining popularity in the Kubernetes domain where traditional configuration management does not work. However, operators work with traditional virtual and bare metal machines as well.
What is Juju OLM?
Juju is a universal Operator Lifecycle Manager (OLM) which provides services to operators. It provides resources for operators, deploys them, manages their lifecycle, delivers configuration updates, etc. Juju OLM is universal, meaning that it supports container substrates like Kubernetes as well as traditional machine substrates like bare metal, VMware, OpenStack, or public cloud instances.
In this tutorial, you will learn how to:
-
Recognise which applications can be integrated
-
Integrate applications using declarative interfaces
You will only need:
-
A machine with 8 GB of RAM
-
Microk8s and Juju installed
-
Juju controller bootstrapped on MicroK8s
-
Prometheus and Grafana deployed to MicroK8s with an operator
Integrate applications
Duration: 10:00
Operators from the Open Operator Collection declare interfaces that can be used for application integration. This allows users to compose even very complex application topologies using operators and integration lines between them.
In the following steps, we will integrate Prometheus with Grafana through operators. As a result, Grafana will be able to consume the data provided by Prometheus and display them in a visualised form.
First, let’s see what the current status of the model is:
$ juju status --relations
The output should look something like the following:
Model Controller Cloud/Region Version SLA Timestamp
monitoring mk8s microk8s/localhost 2.9.9 unsupported 12:21:22+01:00
App Version Status Scale Charm Store Channel Rev OS Address Message
grafana-k8s grafana/grafana@7f26ece active 1 grafana-k8s charmhub stable 1 kubernetes 10.152.183.126
prometheus-k8s prom/prometheus:latest active 2 prometheus-k8s charmhub stable 1 kubernetes 10.152.183.7
Unit Workload Agent Address Ports Message
grafana-k8s/0* active idle 10.1.98.59 3000/TCP
prometheus-k8s/0* active idle 10.1.98.51 9090/TCP
prometheus-k8s/1 active idle 10.1.98.5 9090/TCP
Relation provider Requirer Interface Type Message
grafana-k8s:grafana grafana-k8s:grafana grafana-peers peer
Note that we’ve passed in the --relations
flag, and we can see the grafana provides a “grafana” relation. Prometheus can consume that relation by running the following command:
$ juju relate prometheus-k8s grafana-k8s
The juju relate
command creates an integration line (a relation) between two deployed applications. Now watch what happens by executing the juju status
command in the “watch” loop:
$ watch --color 'juju status --color --relations'
You will see that each Prometheus and Grafana unit briefly enters an "executing” state. This is because their operators are executing the code responsible for setting the relation between those applications. Once all units turn to the “active” state back, we can display the status of deployed applications and relations between them by executing the following command:
$ juju status --relations
Model Controller Cloud/Region Version SLA Timestamp
monitoring mk8s microk8s/localhost 2.9.9 unsupported 12:23:27+01:00
App Version Status Scale Charm Store Channel Rev OS Address Message
grafana-k8s grafana/grafana@7f26ece active 1 grafana-k8s charmhub stable 1 kubernetes 10.152.183.126
prometheus-k8s prom/prometheus:latest active 2 prometheus-k8s charmhub stable 1 kubernetes 10.152.183.7
Unit Workload Agent Address Ports Message
grafana-k8s/0* active idle 10.1.98.61 3000/TCP
prometheus-k8s/0* active idle 10.1.98.51 9090/TCP
prometheus-k8s/1 active idle 10.1.98.5 9090/TCP
Relation provider Requirer Interface Type Message
grafana-k8s:grafana grafana-k8s:grafana grafana-peers peer
grafana-k8s:grafana-source prometheus-k8s:grafana-source grafana-datasource regular
You can now visit the Grafana dashboard at http://<ip address>:3000
, and note that it has now been populated with the data from Prometheus. The operators have taken care of writing configuration files and dropping in URLs. You can now set about the more interesting work of making your graphs look just the way that you like them.
More content here about what specific items they should be able to see in the Grafana dashboards. We might want to play with microk8s.enable metrics-server
and integrate that with Prometheus and Grafana to provide interesting metrics on their k8s cloud (the functionality is there.)
Next steps
Duration: 2:00
Congratulations! You have reached the end of this tutorial.
You can now move to the next tutorial - “6. Updates”
In this tutorial you have learnt how to:
-
Recognise which applications can be integrated
-
Integrate applications using declarative interfaces