Skip to main content
This feature is in early access and behind a feature flag. Contact your Augment Solutions Architect to enable it for your tenant

Introduction

This guide walks through connecting a self-hosted Kubernetes cluster to Cosmos. It uses an AWS EC2 instance running Ubuntu and Minikube as a reference environment, then covers deployment with either generated k8s manifests or Helm.

Prerequisites

Cosmos AWS
  • Must have permission to deploy and manage a AWS EC2 instance
  • Outbound access to gw.cosmos.augmentcode.com:443
  • An x86_64/amd64 Ubuntu host with KVM and nested virtualization enabled
  • At least 100 GB of storage
  • Permission to install Docker, Minikube, kubectl, and Helm

Configure AWS EC2 Ubuntu + Minikube

Create a Cosmos service account

Go to cosmos.augmentcode.com, go to Settings > Service Accounts > + Create service account:
  • Account name: k8s-self-hosted
  • Description: To connect our hosted k8s cluster to Cosmos
You’ll get “You service account is ready”. Then click on Create API token > New token name: token01 > click on Create token Then click on “Copy token” and store it securely. You will use it later to create a k8s secret.

Create a Cosmos sandbox provider

Go to cosmos.augmentcode.com > Settings > Sandbox Providers > + Create provider:
  • Display name: my-k8s-0
  • Slug: my-k8s-0
  • Enabled: keep toggled on
  • Click on Create provider
You should see my-k8s-0 in the list with an Enabled status.:

Create an AWS EC2 instance + Minikube

Deploy the EC2 instance

Go to your AWS Console > deploy a new EC2 instance:
  • OS: Ubuntu 26.04 LTS HVM
  • Architecture: 64-bit (x86)
  • Instance type: m7i.2xlarge
  • Configure storage: 100 GB gp3
  • Advanced details > Nested virtualization > Enabled
After launching the EC2 instance, verify the architecture, virtualization support, and KVM device:
Expected result:

Install Minikube

Install Docker Engine

Follow the Docker Engine installation guide for Ubuntu, or configure the official apt repository directly:
Verify that Docker is running:
Expected result:
If it is not running, start it:

Install kubectl

The checksum command should return kubectl: OK.

Grant Docker access and start Minikube

The reference EC2 image uses the ubuntu user:

Run a Docker Hello World

Start Minikube with the Docker driver:
All core pods in the kube-system namespace should reach Running status.
Minikube uses a container-in-container architecture, so Docker shows one Minikube container rather than each Kubernetes workload. Run minikube stop when you need to stop the cluster.
Verify the cluster:
Expected result:

Label the KVM-capable node

Expected result:

Enable the Minikube registry via the built-in add-on and capture its cluster IP

Expected result:
Create a port-forward to access that registry:
Expected results:
Before continuing, confirm that the registry IP is available:
Expected result:

Store the Cosmos service account token

Create the controller namespace, then enter the Cosmos service-account token when prompted. This method does not store the token in a file or command argument.

Option1: Deploy with k8s manifests

Download the Cosmos deployment binary

Generate and apply the k8s manifests

Generate the manifests:
Add the Minikube KVM group ID to the sandbox pod security context:
Inspect cosmos-sh.k8s.yaml and confirm that the sandbox pod template includes the KVM group under securityContext.supplementalGroups, run:
Expected node in your yaml:
Validate the manifests before applying them:
Expected result:
Apply the manifests:
Expected result:

Set again the Cosmos service account token

With the approach above, you generated cosmos-sh.k8s.yaml without the token value in it, and since kubectl apply is declarative (=the live object match the YAML) apply happened with an unset token value. Set the secret again:
Reload the controllers:
Why it’s important: updating a Kubernetes Secret does not automatically restart the applications using it. So perform a rolling restart of the three controller pods so each process reads the new token. Kubernetes replaces the pods gradually, keeping available old pods until replacements are ready. It does not restart Minikube or the EC2 instance. The mounted Secret file may eventually update automatically, but the controller might only read it during startup; the rolling restart guarantees immediate use.
Token management is more elegantly handled via the Helm chart approach in the next section

Verify the controller pods are running

Expected result:

Configure a new env in Cosmos

In cosmos.augmentcode.com, go to Settings > Environments > Create an environment > Self-hosted
  • Name: K8s on EC2
  • Description: Self-hosted k8s cluster on EC2
  • Self-hosted compute > Sandbox Provider > Select my-k8s-0
  • Base image: keep Cosmos Default selected
  • Repositories: select your repositories from github.com, gitlab.com, ADO
  • Refresh: toggle on
  • Click on Create Environment
Screenshot 2026 09 18 At 12 08 37 PM The environment will build (can range from 15sec to a few minutes) Screenshot 2026 09 18 At 12 10 10 PM Once completed you should see this: Screenshot 2026 09 18 At 12 11 19 PM Click on Done. Now under In cosmos.augmentcode.com > Settings > Environments you’ll see your new environment with a specific self-hosted icon (different from Cloud Environments that will have a cloud icon): Screenshot 2026 09 18 At 12 12 22 PM

Run a test Cosmos session

In cosmos.augmentcode.com > New session > Bottom left of the prompt box select your “K8s on EC2” self-hosted env and prompt it with What repos are available in this environment? Your session would look like this below, note the env name on the right-side drawer and the list of the repos in that env: Screenshot 2026 09 18 At 12 22 13 PM Congrats you’ve configured Cosmos with your self-hosted k8s cluster! 🎉

Option 2: Deploy with Helm

If you already deployed the generated manifests, the Helm command below uses --take-ownership to adopt those resources. After migration, manage the installation only with helm upgrade; do not continue applying cosmos-sh.k8s.yaml.

Install Helm

Download and verify Helm:
Expected response:
Install Helm and take ownership:
Expected response:

Create the file mapped to the Cosmos service account token

Create cosmos0-values.yaml:
The chart references the existing k8s secret without storing its value in the values file.

Calculate Minikube-specific values

Verify the node label:
Expected result:
Verify the chart:
Expected result:

Dry-run and install

Run a server-side dry run without displaying Secret values:
Install the release:
Expected result:
Verify the deployment:
Expected result:

(Optional) Rotate the service account token

Note: if you have to update the secret after the cluster is already started, reset the value and reload the controllers.
Set the secret again:
Reload the controllers:

Blueprint for EKS, GKS, AKS

You can take inspiration from the Helm chart approach above to bring your own k8s clusters, whether they are managed or not. This guide will later be updated with blueprints for EKS, GKS, AKS, stay tuned! 🚧