Deploy an Ubuntu Pro EKS cluster

This guide shows how to deploy an EKS Cluster with Ubuntu Pro nodes using Ubuntu Pro tokens and EC2 launch templates.

Prerequisites

You need:

  • eksctl: Check the instructions to install eksctl

  • packer: only needed if you want to enable FIPS for the cluster nodes. Install it with sudo snap install packer

  • your AWS access key ID and secret access key

  • an Ubuntu Pro token

Prepare the cluster for deployment

Although Ubuntu Pro AMIs are available in AWS, at the time of writing this guide, there is no such offer for the EKS service. So you’ll need to provision the EKS cluster with customised Ubuntu nodes.

The steps needed for deploying the cluster depend on whether you need to enable FIPS or not.

When FIPS is not enabled, you can use one of the existing Ubuntu EKS AMIs and customise it using cloud-init’s ubuntu-advantage module during deployment.

For this deployment, you’ll also need to have an existing launch template on AWS.

Update user-data in launch template

On the advanced section of your launch template (user-data section), copy the following code (replacing the “token” field with your Pro token):

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"
ubuntu_advantage:
token: <pro_token>
enable:
- esm

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
sudo /etc/eks/bootstrap.sh procluster

--==MYBOUNDARY==--

Cloud-init will use this user-data to enable ESM on the cluster nodes and bootstrap the AWS EKS cluster.

Create the eksctl config file

You’re now ready to deploy the EKS cluster with Ubuntu Pro nodes. To do so, start by creating a cluster.yaml with the following content

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: procluster
region: us-east-1
version: 'YOUR_EKS_VERSION'

Add the following content to your file

managedNodeGroups:
- name: ng-procluster
desiredCapacity: 2
launchTemplate:
  id: lt-12345
  version: "1"

This config file will allow you to create an EKS cluster using the launch template from above, with two nodes.

For further cluster customisation check out eksctl details.

Create the EKS cluster

To create the EKS cluster, run eksctl create cluster -f cluster.yaml (you might need to specify the --profile option if you have multiple profiles). When this command finishes, see the nodes with

$ kubectl get nodes

NAME                                           STATUS   ROLES    AGE     VERSION
ip-xxx-xxx-xx-xxx.us-east-1.compute.internal   Ready    <none>   2m45s   v1.23.x
ip-xxx-xxx-x-xx.us-east-1.compute.internal     Ready    <none>   2m45s   v1.23.x

To ensure your nodes have an Ubuntu Pro subscription, SSH into one of the cluster nodes (get the external IP of your node with kubectl get nodes -o wide):

# Replace the private SSH key and node IP according to your setup
$ ssh -i yoursshkeyname.pem ubuntu@<external_ip_of_node>
$ pro status

SERVICE          ENTITLED  STATUS    DESCRIPTION
esm-apps         yes       enabled   Expanded Security Maintenance for Applications
esm-infra        yes       enabled   Expanded Security Maintenance for Infrastructure
fips             yes       enabled   NIST-certified core packages
fips-updates     yes       disabled  NIST-certified core packages with priority security updates
usg              yes       disabled  Security compliance and audit tools

Please note that your services’ statuses might differ from this snippet based on the Pro services that you’ve chosen to enable in the above configurations.

Verify Pro subscription

You now have an Ubuntu Pro Kubernetes cluster on EKS. Your Ubuntu Pro subscription can be verified on each of the provisioned nodes with

$ pro status