Set up the Kubernetes provider for Amazon EKS

Set up Spinnaker on AWS EKS using the Kubernetes-V2 provider

Before you proceed further with this setup, we strongly recommend that you familiarize yourself with Amazon EKS concepts . Also, visit the AWS global infrastructure region table for the most up-to-date information on Amazon EKS regional availability.

These instructions assume that you have AWS CLI installed and configured on an Ubuntu machine running on AWS EC2.

Preparing to install Spinnaker on EKS

The following steps describes how to the tools you need to install and manage Spinnaker and EKS.

1. Install and configure kubectl

Install kubectl to manage Kubernetes and aws-iam-authenticator to manage cluster authentication:

  1. # Download and install kubectl
  2. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  3. chmod +x ./kubectl
  4. sudo mv ./kubectl /usr/local/bin/kubectl
  5. # Verify the installation of kubectl
  6. kubectl help
  7. # Download and install aws-iam-authenticator
  8. curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.13.7/2019-06-11/bin/linux/amd64/aws-iam-authenticator
  9. chmod +x ./aws-iam-authenticator
  10. mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH
  11. echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
  12. #Verify the installation of aws-iam-authenticator
  13. aws-iam-authenticator help`

The commands return the help information for kubectl and aws-iam-authenticator respectively. If the help for either tool does not get returned, verify that you have installed the tool.

2. Install awscli

  1. # Install the awscli
  2. sudo apt install python-pip awscli
  3. # Verify the installation
  4. aws --version

The command returns the awscli version.

3. Install eksctl

Install eksctl to manage EKS clusters from the command line:

  1. # Download and configure eksctl
  2. curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
  3. sudo mv /tmp/eksctl /usr/local/bin
  4. # Verify the installation
  5. eksctl help

The command returns the help for eksctl.

4. Install Halyard

Install Halyard, which is used to install and manage Spinnaker:

  1. # Download and configure Halyard
  2. curl -O https://raw.githubusercontent.com/spinnaker/halyard/master/install/debian/InstallHalyard.sh
  3. sudo useradd halyard
  4. sudo bash InstallHalyard.sh
  5. sudo update-halyard
  6. # Verify the installation
  7. hal -v

The command returns the Halyard version.

5. Create the Amazon EKS cluster for Spinnaker

  1. eksctl create cluster --name=eks-spinnaker --nodes=2 --region=us-west-2 --write-kubeconfig=false

Install and configure Spinnaker

This section walks you through the process of installing and configuring Spinnaker for use with Amazon EKS.

1. Retrieve Amazon EKS cluster kubectl contexts

  1. aws eks update-kubeconfig --name eks-spinnaker --region us-west-2 --alias eks-spinnaker

2. Check Halyard version

More recent versions of Spinnaker require a more recent version of Halyard. For example, Spinnaker 1.19.x requires Halyard 1.32.0 or later.

Verify your Halyard version:

  1. hal -v

3. Add and configure Kubernetes accounts

Enable the Kubernetes provider for Spinnaker:

  1. # Enable the Kubernetes provider
  2. hal config provider kubernetes enable
  3. # Set the current kubectl context to the cluster for Spinnaker
  4. kubectl config use-context eks-spinnaker

A context element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, kubectl uses parameters from the current context to communicate with the cluster.

  1. # Assign the Kubernetes context to CONTEXT
  2. CONTEXT=$(kubectl config current-context)

Next, create a service account for the Amazon EKS cluster:

  1. kubectl apply --context $CONTEXT -f /downloads/kubernetes/service-account.yml

A minimal example for service-account.yaml looks like this:

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: spinnaker-service-account
  5. namespace: spinnaker

Note that this requires an existing spinnaker namespace. For RBAC bindings in addition to the service account, see Optional: Configure Kubernetes roles (RBAC) . See the Kubernetes documentation for more details on service accounts.

Extract the secret token of the created spinnaker-service-account:

  1. TOKEN=$(kubectl get secret --context $CONTEXT \
  2. $(kubectl get serviceaccount spinnaker-service-account \
  3. --context $CONTEXT \
  4. -n spinnaker \
  5. -o jsonpath='{.secrets[0].name}') \
  6. -n spinnaker \
  7. -o jsonpath='{.data.token}' | base64 --decode)

Set the user entry in kubeconfig:

  1. kubectl config set-credentials ${CONTEXT}-token-user --token $TOKEN
  2. kubectl config set-context $CONTEXT --user ${CONTEXT}-token-user

Add eks-spinnaker cluster as a Kubernetes provider:

  1. hal config provider kubernetes account add eks-spinnaker --context $CONTEXT

4. Enable artifact support

  1. hal config features edit --artifacts true

5. Configure Spinnaker to install in Kubernetes

For our environment, we will use a distributed Spinnaker installation onto the Kubernetes cluster. This installation model has Halyard deploy each of the Spinnaker microservices separately. A distributed installation helps to limit update-related downtime.

  1. hal config deploy edit --type distributed --account-name eks-spinnaker

6. Configure Spinnaker to use AWS S3

You will need your AWS account access key and secret access key.

  1. export YOUR_ACCESS_KEY_ID=<access-key>
  2. hal config storage s3 edit --access-key-id $YOUR_ACCESS_KEY_ID \
  3. --secret-access-key --region us-west-2

Enter your AWS account secret access key at the prompt.

Then, set the storage source to S3:

  1. hal config storage edit --type s3

7. Choose the Spinnaker version

To identify the latest version of Spinnaker to install, run the following command to get a list of available versions:

  1. hal version list

At the time of writing, 1.19.2 is the latest Spinnaker version. Configure Halyard to deploy Spinnaker 1.19.2:

  1. export VERSION=1.19.2
  2. hal config version edit --version $VERSION

Now, we are finally ready to install Spinnaker on the eks-spinnaker Amazon EKS cluster:

  1. hal deploy apply

8. Verify the Spinnaker installation

  1. kubectl -n spinnaker get svc

The command returns the Spinnaker services that are in the spinnaker namespace.

9. Expose Spinnaker using Elastic Load Balancer

Expose the Spinnaker API (Gate) and the Spinnaker UI (Deck) using Load Balancers by running the following commands to create the spin-gate-public and spin-deck-public services:

  1. export NAMESPACE=spinnaker
  2. # Expose Gate and Deck
  3. kubectl -n ${NAMESPACE} expose service spin-gate --type LoadBalancer \
  4. --port 80 --target-port 8084 --name spin-gate-public
  5. kubectl -n ${NAMESPACE} expose service spin-deck --type LoadBalancer \
  6. --port 80 --target-port 9000 --name spin-deck-public
  7. export API_URL=$(kubectl -n $NAMESPACE get svc spin-gate-public \
  8. -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
  9. export UI_URL=$(kubectl -n $NAMESPACE get svc spin-deck-public \
  10. -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
  11. # Configure the URL for Gate
  12. hal config security api edit --override-base-url http://${API_URL}
  13. # Configure the URL for Deck
  14. hal config security ui edit --override-base-url http://${UI_URL}
  15. # Apply your changes to Spinnaker
  16. hal deploy apply

It can take several moments for Spinnaker to restart.

You can verify that the Spinnaker Pods have restarted and check their status:

  1. kubectl -n spinnaker get pods

10. Re-verify the Spinnaker installation

Run the following command to verify that the Spinnaker services are present in the cluster:

  1. kubectl -n spinnaker get svc

11. Log in to Spinnaker console

Get the URL to Deck, the UI.

  1. kubectl -n $NAMESPACE get svc spin-deck-public -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'

Navigate to the URL in a supported browser and log in.

Last modified December 22, 2021: docs(fix): Fix various encoding issues (#170) (0475fe5)