Juju with Amazon Elastic Kubernetes Service (Amazon EKS)

This guide will ensure that you’re ready to deploy and manage Kubernetes workloads on AWS Elastic Kubernetes Service (EKS) with Juju. Juju provides built-in support for EKS. Once you’ve registered your cluster, you’ll be able to deploy workloads from Charmhub straight away.

This guide covers:

  1. Installing prerequisite software
  2. Provisioning an Amazon Elastic Kubernetes Service cluster
  3. Connecting Juju to your Kubernetes cluster
  4. Deploy workloads
  5. Cleaning Up

1. Prerequisites

Using Juju to drive Kubernetes workloads on EKS requires installing some prerequisite software:

A. Juju client
B. AWS CLI and eksctl
C. Kubernetes client

A. Juju client

You will need to install Juju. If you’re on Linux, we recommend using snap:

sudo snap install juju --classic

We also provide other installation methods as described on our detailed installation documentation.

B. AWS CLI and `eksctl`

The AWS CLI is a cross-platform command-line utility for interacting with AWS. For installation instructions, visit the AWS documentation.

Additionally, eksctl is a utility for creating and interacting with Amazon Elastic Kubernetes Service instances. Installation instructions can be found in the AWS documentation.

C. Kubernetes client

kubectl is the command-line client for directly interacting with a Kubernetes cluster. Visit the Kubernetes documentation for manual kubectl installation instructions.

2. Provision a Kubernetes cluster on AWS

Amazon AWS resources can be created using the AWS CLI tools, through the AWS Console and a myriad of other methods. In this guide, we will create and manage resources using the CLI tools.

Log in to the AWS CLI

Ensure your CLI tools are authenticated with AWS:

aws configure

Further information about authenticating with the AWS command-line tools is available.

Create the Kubernetes cluster with the AWS CLI

We will use eksctl to create our cluster:

eksctl create cluster \
--name <cluster> \
--region <region> \
--node-ami-family “Ubuntu2004” \
--node-type ”m5.large”

When specifying a --node-type, ensure that you request a machine type that provides at least 6 GB memory. This provides sufficient resources to enable Juju to be deployed alongside the Kubernetes control plane and your workloads.

Accessing the cluster

If you’ve used eksctl to provision your cluster, kubectl config file has already been loaded. Verify that you have access by enumerating the nodes in the cluster:

kubectl get nodes
”I didn’t use eksctl - how do I connect?

If you created your EKS cluster using the AWS Console or the aws CLI command, you can use the update-kubeconfig to fetch the kubeconfig file:

aws eks --region <region> update-kubeconfig --name <cluster>

If you experience difficulties at this step, detailed instructions are provided by the Amazon EKS documentation.

3. Connecting Juju to your Kubernetes cluster

There are three distinct stages to configuring your EKS cluster for management with Juju:

A. Register the cluster as a Kubernetes cloud

B. Deploy a Juju controller to the cluster

C. Create a model to house our applications.

A. Register the cluster as a Kubernetes cloud

In Juju’s vocabulary, a cloud is a space that can host deployed workloads. To register a Kubernetes cluster with Juju, execute the juju add-k8s command. The <cloud> argument is your specified name for the cloud, and will be used by Juju to refer to the cluster.

juju add-k8s <cloud-name>

B. Create a controller

Juju, as an active agent system, requires a controller to get started. Controllers are created with the juju bootstrap command that takes a cloud’s name and our intended name for the controller.

juju bootstrap <cloud>
(Optional) Specify a controller name

You can specify the name of your Juju controller if you wish:

juju bootstrap <cloud> <controller-name>

If you do not, Juju will generate the name using the name of the cloud.

C. Create a model

A model is a workspace for inter-related applications. They correspond (roughly) to a Kubernetes namespace. To create one, use juju add-model with a name of your choice:

juju add-model <model-name>

4. Deploy workloads

You’re now able to deploy workloads into your model. Workloads are provided by charms (and sets of charms called bundles). You can find a list of Kubernetes charms on Charmhub!

Cleaning Up

The following instructions allow you to undo everything we just did!

The following commands are destructive, and will destroy all running workloads that were deployed with Juju, then remove the EKS cluster.

Remove the Juju controller and any workloads deployed:

juju kill-controller -y -t0 <controller>

Delete the EKS cluster

eksctl delete cluster <cluster>