Deploy Ubuntu Pro containers on Kubernetes

You can easily deploy your Ubuntu Pro container images on Kubernetes clusters, provided that said clusters are composed of Ubuntu Pro nodes. Read more on the Ubuntu Pro website.

Prerequisites

You will need

  • an Ubuntu Pro container image on a private registry. This can be built using the procedure given at Building Ubuntu Pro OCI images. Since the image is attached to your Ubuntu Pro subscription, it should be kept private to avoid the sharing of your Ubuntu Pro subscription with unwanted users.

  • a Kubernetes cluster with an Ubuntu Pro subscription. To learn to deploy it for different clouds, refer to the options shown below:

Deploying Pro Kubernetes clusters in various clouds

Check out Deploy an Ubuntu Pro EKS cluster - using Pro tokens to learn how to deploy an Ubuntu Pro Kubernetes cluster on Elastic Kubernetes Service (EKS).

Create a Secret for Private Registry

Since your Ubuntu Pro container image is in a private registry, you will need to create a secret in Kubernetes (For more details about pulling images from private registries, check out the Kubernetes documentation).

You can use the following example command to create a secret named regcred for Docker Hub (i.e. using https://index.docker.io/v1/ as <your-registry-server>).

kubectl create secret docker-registry regcred \
    --docker-server=<your-registry-server> \
    --docker-username=<your-username> \
    --docker-password=<your-password> \
    --docker-email=<your-email>

Deploy Pro container image to Pro Kubernetes cluster

You can deploy your Pro container image in a Pod, Deployment, or as a Service. Make sure to include your created secret and your Pro container image correctly.

Here is a manifest for a Pod that consists of a container running your Ubuntu Pro image. It uses your secret regcred to pull the Pro container image from your private registry.

# pro-container-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pro-container-pod
spec:
  imagePullSecrets:
  - name: regcred
  containers:
  - name: ubuntu-pro-container
    image: <your-private-pro-image>
  restartPolicy: OnFailure

Replace <your-private-pro-image> with your private Pro container image (something similar to janedoe/jdoe-private:v1 for Docker Hub).

Create the Pod, and verify that the Pod is running:

kubectl apply -f pro-container-pod.yaml
kubectl get pod pro-container-pod

Check pod logs

Your Pro container image is deployed in the Pro Kubernetes cluster and running inside a Pod. You can check the logs by running:

kubectl logs pod/pro-container-pod