Juju 101 - Services and ports [4/12]


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 - “Configuration”.

Explore other tutorials >

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.

Learn more about operators >

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.

Learn more about Juju OLM >

In this tutorial you will learn how to:

  • Deploy another application to the existing model with an operator

  • Map applications to Kubernetes services

  • Expose applications for an external consumption

You will only need:

  • A machine with 8 GB of RAM

  • Microk8s and Juju installed

  • Juju controller bootstrapped on MicroK8s

  • Prometheus deployed to MicroK8s with an operator

Deploy another application

Duration: 5:00

In the following steps, we will deploy another application to the existing model with an operator. We will use Grafana as an example. Grafana is open source analytics and interactive visualisation web application that can be configured to display the monitoring data that Prometheus gathers in snappy-looking graphics.

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  11:54:30+01:00

App             Version                 Status  Scale  Charm           Store     Channel  Rev  OS          Address       Message
prometheus-k8s  prom/prometheus:latest  active      2  prometheus-k8s  charmhub  stable     1  kubernetes

Unit               Workload  Agent  Address     Ports     Message
prometheus-k8s/0*  active    idle  9090/TCP
prometheus-k8s/1   active    idle   9090/TCP

Then deploy Grafana with an operator:

$ juju deploy grafana-k8s
Located charm "grafana-k8s" in charm-hub, revision 1
Deploying "grafana-k8s" from charm-hub charm "grafana-k8s", revision 1 in channel stable

As you know from the previous tutorials, you can monitor the status of deployed applications by executing the juju status command:

$ juju status

Once the Grafana application turns to the “active” state as on the output above, you can consider the deployment to be finished.

Accessing applications over the network

Duration: 5:00

Operators and Juju OLM provide provisioning capabilities so that network resources can be provisioned for applications in a fully automated way to enable access to applications over the network.

In the previous tutorial, we assumed that the Prometheus application is exposed over the network when accessing its admin API. This may not be the case in all environments, though.

Look at the juju status command output and note the IP addresses used by the applications and their units:

NOTE: IP addresses may vary across the environments. In the following steps use IP addresses from your environment rather than the ones presented in this tutorial.

$ juju status
Unit               Workload  Agent  Address     Ports     Message
grafana-k8s/0*     active    idle  3000/TCP
prometheus-k8s/0*  active    idle  9090/TCP

They are different. This is because deployed applications are exposed as Kubernetes services, while application units simply inherit their pod’s IP. You can check it by running the kubectl command:

$ microk8s.kubectl get services -n monitoring
NAME                       TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
modeloperator              ClusterIP    <none>        17071/TCP   19m
prometheus-k8s-operator    ClusterIP   <none>        30666/TCP   18m
prometheus-k8s             ClusterIP     <none>        9090/TCP    18m
prometheus-k8s-endpoints   ClusterIP   None             <none>        <none>      18m
grafana-k8s-operator       ClusterIP    <none>        30666/TCP   2m17s
grafana-k8s                ClusterIP   <none>        3000/TCP    2m
grafana-k8s-endpoints      ClusterIP   None             <none>        <none>      2m

Although the service port is not displayed next to the application, it shows up next to each application unit on the juju status command output.

Let’s now try to access the Grafana dashboard. Based on the outputs above we can see that the grafana application is exposed at the IP address of and its port is 3000. Thus, we should be able to access the Grafana dashboard at the URL. Pass it to your browser and the following page should show up:

Grafana comes with a default admin user, which has the following credentials “admin”/“admin”.

As you can see, in our local deployment on MicroK8s all applications are exposed over the network as Kubernetes services by default. There are some environments, however, like public clouds where applications have to be exposed for external consumption so that public IP addresses could be used to access them over the Internet.

In order to expose an application for external consumption, execute the following command:

$ juju expose grafana-k8s

This command will allocate public IP for the application and configure underlying security groups to enable external traffic.

Next steps

Duration: 2:00

Congratulations! You have reached the end of this tutorial.

You can now move to the next tutorial - “5. Integration”.

In this tutorial you have learnt how to:

  • Deploy another application to the existing model with an operator

  • Map applications to Kubernetes services

  • Expose applications for an external consumption

Where to go from here?