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 - Models.
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:
- Deploy applications with operators using Juju bundles
You will only need:
-
A machine with 8 GB of RAM
-
Microk8s and Juju deployed
-
Juju controller bootstrapped on MicroK8s
-
A “monitoring” model created under the controller
Deploy applications with bundles
Duration 5:00
While operators are packages of operation software, they still have to be individually deployed, scaled, configured, and integrated. In complex environments, this may create an unnecessary complexity as the number of commands to execute can inflate quickly.
As a response to this challenge, Juju OLM supports the concept of bundles - YAML files which contain a complete description of the deployment: applications, their configuration, number of units, relations between them, etc. Such bundles can be re-used and shared for reproducibility purposes.
In the previous tutorials, we deployed Prometheus and Grafana using a series of Juju commands:
$ juju deploy prometheus-k8s prometheus
$ juju scale-application prometheus 2
$ juju deploy grafana-k8s grafana
$ juju relate prometheus grafana
In the following steps, we will deploy the entire model using a single command and the bundle.
First, let’s see what the current status of the model is:
$ juju status
Model Controller Cloud/Region Version SLA Timestamp
monitoring mk8s microk8s/localhost 2.9.9 unsupported 10:16:44+01:00
Model "admin/monitoring" is empty.
The model is empty, so we can deploy our bundle there. We start with creating it:
$ cat <<EOF > monitoring.yaml
bundle: kubernetes
applications:
prometheus:
charm: prometheus-k8s
scale: 2
grafana:
charm: grafana-k8s
scale: 1
relations:
- - prometheus
- grafana
EOF
We can then deploy it using the juju deploy
command in the same way as we deployed Prometheus and Grafana applications:
$ juju deploy ./monitoring.yaml
Located charm "grafana-k8s" in charm-hub, channel stable
Located charm "prometheus-k8s" in charm-hub, channel stable
Executing changes:
- upload charm grafana-k8s from charm-hub with architecture=amd64
- deploy application grafana from charm-hub with 1 unit using grafana-k8s
added resource grafana-image
- upload charm prometheus-k8s from charm-hub with architecture=amd64
- deploy application prometheus from charm-hub with 2 units using prometheus-k8s
- add relation prometheus - grafana
Deploy of bundle completed.
The deployment starts right away and the status is reflected in the juju status
command output immediately. Once all applications turn to the “active” state, you can consider the deployment to be finished:
$ juju status
Model Controller Cloud/Region Version SLA Timestamp
monitoring mk8s microk8s/localhost 2.9.9 unsupported 11:39:15+01:00
App Version Status Scale Charm Store Channel Rev OS Address Message
grafana grafana/grafana@7f26ece active 1 grafana-k8s charmhub stable 1 kubernetes 10.152.183.11
prometheus prom/prometheus:latest active 2 prometheus-k8s charmhub stable 1 kubernetes 10.152.183.200
Unit Workload Agent Address Ports Message
grafana/0* active idle 10.1.98.46 3000/TCP
prometheus/0* active idle 10.1.98.53 9090/TCP
prometheus/1 active idle 10.1.98.42 9090/TCP
To view the grafana dashboard use juju status
to locate the grafana/0
unit IP address and port or run the following:
$ juju show-unit grafana/0 --format="json" | jq -r '.["grafana/0"] | .address'
Then navigate to the IP address with the port to view the grafana dashboard. The default grafana credentials are “admin” and “admin” for the password. Remember to change this after entering the dashboard!
Next steps
Duration: 2:00
Congratulations! You have reached the end of this tutorial.
You can now move to the next tutorial - “10. Logs”.
In this tutorial you have learnt how to:
- Deploy applications with operators using Juju bundles