Skip to content

liatrio/sk8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sk8s

Table of Contents

Overview

This project is used for deploying a Kubernetes cluster in a greenfield AWS or Azure environment with Terraform, and setting up the GitHub Actions Runner Controller (ARC) to manage runners on the cluster. Aside from a few configuration options, everything about the creation process is automated for you. For instructions on how to get started with each cloud provider's Kubernetes service offering, clone this repository and follow the steps in the relevant Quickstart guides:

Prerequisites

The prerequisites are split into two categories: the software tools neeeded to execute our infrastructure-as-code, and the account settings and credentials needed to interact with AWS/Azure and GitHub.

Command-Line Tools

Terraform is used for the IaC, so you will have to install it either on your local workstation or in your CI/CD pipeline by clicking the link below. If you are leveraging GitHub-hosted runners already, or managing a fleet of VM-based self-hosted runners, then you can use the setup-terraform action to begin migrating your workload to Kubernetes and ARC.

Terragrunt is necessary when managing multiple environments. It is a thin wrapper around Terraform that allows you to keep your Terraform code DRY by using shared modules and configuration files. It also provides a number of other features that make it easier to work with Terraform in a team setting, such as locking and state management.

Once the cluster is up and running, the AWS CLI is needed to obtain the cluster's kubeconfig in order to connect to it using the Kubernetes command-line utility, kubectl.

Helm is used to deploy the cluster autoscaler as well as ARC and its dependencies. For convenience, a Helmfile is included that runs through each of the charts in the correct order of deployment. All other interaction with the cluster (e.g. troubleshooting failed deployments or permissions issues) is done using kubectl.

Required

Optional

Helmfile is recommended to simplify deployment of the cluster autoscaler and ARC; if you choose to use it, be sure to also install the Helm Diff plugin (helm plugin install https://github.com/databus23/helm-diff).

Account Access and Credentials

AWS

In order to deploy the infrastructure using Terraform, you must have an AWS account with appropriate permissions to spin up the EKS cluster and its worker nodes, along with the host VPC, subnets, NAT gateways, etc. Terraform can authenticate using its AWS provider in a number of different ways, as outlined here. In keeping with security best practices, we recommend that you avoid hardcoding AWS credentials anywhere in your Terraform configuration and instead use environment variables or instance profile credentials.

Azure

An Azure Kubernetes cluster uses a pair of system-assigned managed identities with the permissions necessary to modify the existing network and create the cluster infrastructure listed below. This is enough for a basic Kubernetes cluster configuration, but a user-created service principal is required to take advantage of more advanced features (e.g. the ACI Connector).

The managed identity or service principal assigned to AKS is responsible for creating the node pool VMs, any attached storage devices, and the network links for the Kubernetes API server. Therefore, it must be given Contributor access to the resource group that contains the cluster’s infrastructure resources (this RG is typically prefixed by MC_). When using Azure CNI, this SP must also be granted the built-in role of Network Contributor on the private virtual network.

In order to leverage Azure Container Instances for burstable workloads, a second managed identity must be created with Contributor access to the cluster resource group. As before, when deploying container instances in the virtual private network, the Network Contributor role must also be assigned to the SP.

GitHub

ARC runners can be deployed at the repository, organization, or enterprise level; the exact GitHub permissions required are listed here. You can use either a Personal Access Token (PAT) or install a GitHub App to authenticate the controller.