Skip to main content
Warning This document has not been updated for a while now. It may be out of date.
Last updated: 24 Feb 2024

Access a GOV.UK EKS cluster

There are 3 GOV.UK clusters: integration, staging and production. These correspond to the integration, staging and production GOV.UK environments, which belong to the integration, staging and production AWS accounts respectively.

Prerequisites

This document assumes that you have already followed the steps in Get started developing on GOV.UK.

Obtain AWS credentials for your role in the cluster’s AWS account

  1. Choose the AWS IAM role that you will use to access the cluster:
- `admin`: has read-write access to everything in the cluster, including secrets
- `poweruser`: has read-write access to everything in the `apps` namespace, but cannot view or modify secrets
- `readonly`: can read everything in the `apps` namespace, except for secrets
  1. Obtain AWS credentials using gds-cli for the desired GOV.UK environment and role:
  eval $(gds aws govuk-<govuk-environment>-<role> -e --art 8h)
  export AWS_REGION=eu-west-1

where: - <govuk-environment> is integration, staging, or production - <role> is admin, poweruser, or readonly

Access a cluster for the first time

  1. If it’s your first time accessing the cluster through kubectl, add the govuk cluster to your kubectl configuration in ~/.kube/config:

    aws eks update-kubeconfig --name govuk
    
  2. To make it easier to switch between clusters, namespaces or users, you can rename the new context to match the name of the environment:

    Edit the name field of the last context in ~/.kube/config. For example, for the staging environment you could set name to govuk-staging.

    See the Kubernetes documentation on configuring access to multiple clusters for more information.

  3. Set the current context:

    kubectl config use-context <govuk-environment>
    

    Where govuk-environment is the name of the context from step 2.

  4. Set the default namespace

    kubectl config set-context --current --namespace=apps
    
  5. Check that you can access the cluster:

    kubectl get deploy/frontend
    

    You should see output similar to:

    NAME       READY   UP-TO-DATE   AVAILABLE   AGE
    frontend   2/2     2            2           399d
    

Access a cluster that you have accessed before

To switch to a cluster that you have previously configured in ~/.kube/config as above:

  1. Obtain AWS credentials using gds-cli for the desired GOV.UK environment and role:

     eval $(gds aws govuk-<govuk-environment>-<role> -e --art 8h)
     export AWS_REGION=eu-west-1
    

    where:

    • <govuk-environment> is integration, staging, or production
    • <role> is admin, poweruser, or readonly
  2. Switch to the corresponding kubectl context:

     kubectl config use-context <govuk-environment>
    

    You can list the available contexts by running:

     kubectl config get-contexts