Get started with Charmed Kubernetes

1. Overview

Kubernetes fuses the automatic deployment, scaling and management of containerised applications into a single platform. It is open source and rapidly growing in capabilities, reputation and influence.

Charmed Kubernetes packages Canonical’s operational expertise alongside the same upstream binaries as Kubernetes, making it easily re-deployable across public clouds (AWS, GCE, Azure or Rackspace), private infrastructure (OpenStack, VMware), and even bare metal - from your laptop to the lab.

About Charmed Kubernetes

To substantiate these claims, we are going to build a highly available (HA) production ready Kubernetes cluster — with 2 masters, 3 workers, 3 etcd nodes and a load balancer for the HA control plane. It includes logging, monitoring, scaling and the operational tools to automate deployment and lifecycle management of your cluster.

Kubernetes bundle

In this tutorial you’ll learn how to…

  • Get your Kubernetes cluster up and running
  • Open the K8s dashboard
  • Control your cluster from the kubectl CLI client
  • Deploy your first container workload
  • Add extra features to your Kubernetes cluster

You will need…


2. Deploy Charmed Kubernetes with JAAS

To kick off the deployment, open a Charmed Kubernetes at JAAS.

Kubernetes Direct Deploy

The deployment is made via JAAS - Juju-as-a-Service solution from Canonical. You will need to login or create JAAS account. Add your credentials if you have not done so before. The deployment will then take several minutes, as Juju creates new instances in the cloud and sets up the Kubernetes cluster components. Pending units are outlined in orange. Up and running ones are outlined in black.

Status GUI


3. Install client software

Install the Juju client

In order to operate the deployment you will need to have Juju client installed locally. Skip this step, if you already have it.

Juju client is available on many platforms and distributions. If you are running Ubuntu, you can install Juju client by running the following command: sudo snap install juju --classic

If you are using other Linux distribution, you have to install snapd firt. Refer to Snapd documentation for more information on installing snapd on your Linux distribution.

If you are using other OS than Linux, such as macOS or Windows, refer to Juju documentation.

Verify that you can run juju command. You will see a list of commands to control your Juju cluster. juju

Learn more about Juju by visiting the official documentation.

Install the Kubernetes client

In order to deploy and manage applications on Kubernetes you will need kubectl client installed locally. Skip this step, if you already have it.

Kubectl is available on many platforms and distributions. If you are running Ubuntu, you can install kubectl by running the following command: sudo snap install kubectl --classic

If you are using other Linux distribution, you have to install snapd firt. Refer to Snapd documentation for more information on installing snapd on your Linux distribution.

If you are using macOS, run: brew install kubectl

If you are using Windows, use Chocolatey: choco install kubectl

Verify that you can run kubectl command. You will see a list of commands to control your Kubernetes cluster. kubectl

Learn more about kubectl by visiting the official documentation.


4. Operate your cluster

To operate your cluster with kubectl you need to download the configuration needed to speak to your cluster. The first step to getting the config is to make sure you have an SSH key in your JAAS deployment of your cluster.

  1. To connect to JAAS from the command line you will need to register with the JAAS controller. You will only need to do this the first time: juju register jimm.jujucharms.com

  2. This command will open a new window in your browser. Use Ubuntu SSO to login and authorise your account.

  3. You will then be asked to enter a descriptive name for the JAAS controller. We suggest using jaas.

  4. You can now import your SSH key from Launchpad or Github into your cluster (if you did not add it earlier). For instance, a user with the Github username ghuser would use the following command: juju import-ssh-key gh:ghuser

  5. Verify your SSH key is working by running the date command on the first machine: juju run --machine 0 -- date With SSH operating properly you can now setup kubectl.

  6. Fetch the credentials from the Kubernetes master node: Make a directory: mkdir -p ~/.kube and then copy the config file: juju scp kubernetes-master/0:config ~/.kube/config This might open a separate modal window, in which you should enter the passphrase for your SSH key you added in step 4: Passphrase window

  7. Establish a secure proxy to the Kubernetes apiserver with the following command: kubectl proxy

  8. Navigate to the Kubernetes dashboard UI through the proxy http://xxx.xxx.xxx.xxx:8001/ui. Note the trailing /ui: Kubectl proxy Note: The browser may warn you that the connection is not private or secure. Bypass the warnings (via the ‘Advanced’) option. The browser will then ask you to login. The default username and password are both admin.

  9. You can now use the Kubernetes Dashboard to drive your cluster: Kubernetes dashboard


5. Run your first workload

Spin up a simple static website in your Kubernetes cluster.

  1. You can run a charm action to create an example microbot web application, deploying 5 replicas inside the Kubernetes cluster: juju run-action kubernetes-worker/0 microbot replicas=5

  2. This action creates a deployment titled microbots comprised of 5 replicas defined during the run of the action. It also creates a service named microbots which binds an endpoint, using all 5 of the microbots pods. Finally, it will create an ingress resource, which points at a xip.io domain to simulate a proper DNS service

  3. To see the result of this action, run: juju show-action-output [id above] You should get a similar response to: Address microbot Note: Your FQDN will be different and contains the address of the cloud instance.

  4. Copy and paste the microbot address into your web browser: microbot.xxx.xxx.xxx.xip.io. It is normal to see a 502 / 503 errors during initial application turnup. App microbot

  5. You have successfully connected to a microbot container! Within a few seconds your microbot example application will be online, and load balanced across the 5 pods running the microbot application. Refresh and the hostname at the bottom should change with each request

To learn more about this, go to the Running the packaged example section in the bundle details.


6. That’s all folks!