This is just to explain how we do very basic ci/cd with GitHub workflow using amazon EK ( k8s ) as a container orchestrator.

GitHub Workflow & EKS Architecture

cluster-architect.png

EKS Cluster

Let’s start with the EKS cluster. EKS cluster is a variant of kubernetes that you can use to manage your container in AWS.

  1. First, operate a vagrant box.
  2. In order to manage the AWS EKS cluster, we need to install eksctl manage.
# for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH

curl -sLO "<https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz>"

# (Optional) Verify checksum
curl -sL "<https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt>" | grep $PLATFORM | sha256sum --check

tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz

sudo mv /tmp/eksctl /usr/local/bin
  1. We will download the Kubectl to manage Kubernetes cluster.
curl -LO "<https://dl.k8s.io/release/$>(curl -L -s <https://dl.k8s.io/release/stable.txt>)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
  1. Let’s initialize the very basic cluster with only 1 worker node. You can use the kubeconfig kubeconfig-eks-test.yaml to manage the cluster with kubectl.
vagrant@vagrant:~$ eksctl create cluster --name=eks-test --nodes=1 --kubeconfig=./kubeconfig-eks-test.yaml --region=ap-southeast-1 --profile=kst-dev
2023-10-20 15:44:01 [ℹ]  eksctl version 0.162.0
2023-10-20 15:44:01 [ℹ]  using region ap-southeast-1
2023-10-20 15:44:03 [ℹ]  setting availability zones to [ap-southeast-1c ap-southeast-1a ap-southeast-1b]
2023-10-20 15:44:03 [ℹ]  subnets for ap-southeast-1c - public:192.168.0.0/19 private:192.168.96.0/19
2023-10-20 15:44:03 [ℹ]  subnets for ap-southeast-1a - public:192.168.32.0/19 private:192.168.128.0/19
2023-10-20 15:44:03 [ℹ]  subnets for ap-southeast-1b - public:192.168.64.0/19 private:192.168.160.0/19
2023-10-20 15:44:03 [ℹ]  nodegroup "ng-4853f6e5" will use "" [AmazonLinux2/1.27]
2023-10-20 15:44:03 [ℹ]  using Kubernetes version 1.27
2023-10-20 15:44:03 [ℹ]  creating EKS cluster "eks-test" in "ap-southeast-1" region with managed nodes
2023-10-20 15:44:03 [ℹ]  will create 2 separate CloudFormation stacks for cluster itself and the initial managed nodegroup
2023-10-20 15:44:03 [ℹ]  if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-southeast-1 --cluster=eks-test'
2023-10-20 15:44:03 [ℹ]  Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "eks-test" in "ap-southeast-1"
2023-10-20 15:44:03 [ℹ]  CloudWatch logging will not be enabled for cluster "eks-test" in "ap-southeast-1"
2023-10-20 15:44:03 [ℹ]  you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-southeast-1 --cluster=eks-test'
2023-10-20 15:44:03 [ℹ]
2 sequential tasks: { create cluster control plane "eks-test",
    2 sequential sub-tasks: {
        wait for control plane to become ready,
        create managed nodegroup "ng-4853f6e5",
    }
}
2023-10-20 15:44:03 [ℹ]  building cluster stack "eksctl-eks-test-cluster"
2023-10-20 15:44:04 [ℹ]  deploying stack "eksctl-eks-test-cluster"
2023-10-20 15:44:34 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:45:06 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:46:07 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:47:08 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:48:09 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:49:10 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:50:11 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:51:12 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:52:13 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:53:15 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"
2023-10-20 15:54:16 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-cluster"

2023-10-20 15:56:26 [ℹ]  building managed nodegroup stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:56:28 [ℹ]  deploying stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:56:28 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:56:59 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:57:43 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:58:22 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:59:19 [ℹ]  waiting for CloudFormation stack "eksctl-eks-test-nodegroup-ng-4853f6e5"
2023-10-20 15:59:20 [ℹ]  waiting for the control plane to become ready
2023-10-20 15:59:20 [✔]  saved kubeconfig as "./kubeconfig-eks-test.yaml"
2023-10-20 15:59:20 [ℹ]  no tasks
2023-10-20 15:59:20 [✔]  all EKS cluster resources for "eks-test" have been created
2023-10-20 15:59:22 [ℹ]  nodegroup "ng-4853f6e5" has 1 node(s)
2023-10-20 15:59:22 [ℹ]  node "ip-192-168-19-209.ap-southeast-1.compute.internal" is ready
2023-10-20 15:59:22 [ℹ]  waiting for at least 1 node(s) to become ready in "ng-4853f6e5"
2023-10-20 15:59:22 [ℹ]  nodegroup "ng-4853f6e5" has 1 node(s)
2023-10-20 15:59:22 [ℹ]  node "ip-192-168-19-209.ap-southeast-1.compute.internal" is ready
2023-10-20 15:59:22 [✖]  kubectl not found, v1.10.0 or newer is required
2023-10-20 15:59:22 [ℹ]  cluster should be functional despite missing (or misconfigured) client binaries
2023-10-20 15:59:22 [✔]  EKS cluster "eks-test" in "ap-southeast-1" region is ready
  1. Lets’ test we can be able to reach cluster.
mkdir -p ~/.kube
cp -rv ./kubeconfig-eks-test.yaml ~/.kube/config

vagrant@vagrant:~$ kubectl get nodes -o wide
NAME                                                STATUS   ROLES    AGE   VERSION               INTERNAL-IP      EXTERNAL-IP      OS-IMAGE         KERNEL-VERSION                  CONTAINER-RUNTIME
ip-192-168-19-209.ap-southeast-1.compute.internal   Ready    <none>   64m   v1.27.5-eks-43840fb   192.168.19.209   13.214.156.225   Amazon Linux 2   5.10.192-183.736.amzn2.x86_64   containerd://1.6.19
vagrant@vagrant:~$

REF: https://eksctl.io/getting-started/

Docker Repository | Configuration

  1. Sign up for the account at https://hub.docker.com/