This entry describes the steps provided by multiple chatGPT and tested by a human (me). It demonstrates connecting two systems and touches on
- AWS IAM
- AWS EKS and Cloudformation
- Git Action
- AWS Cli
Pre-requisite
- AWS Account
- GitHub Account
Steps
- Create an AWS User and get an API key
- Create Git Repo (say https://github.com/jess1sd/infra)
- Add a GitAction to create EKS
- Deploy via GitAction
Create AWS User
- Go to IAM, Create User (just default setting), then add Credentials
- User -> Credentials -> Create API Secrets
- Select AWS Cli (I did not try other options)
Set up Git Access
- Go to Git, create a person token (User->Settings->DeveloperSettings->Personal Access Tokens)
- Keep this access token to use as the git password later at the git clone command
Create Git Repo and Git Action
- Create a Git Repo, and add Git Secrets by going to settings->Secrets and Variables
- create two secrets, one for the aws_key_id, and another for the aws_secret_key
- Create a
.github/workflowsfolder - In the
.github/workflowsfolder, create aeks-deployment.ymlfile which has this content
name: Deploy EKS Cluster
on:
push:
branches:
- main # or any branch you prefer
jobs:
deploy-eks-cluster:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2 # change to your AWS region
- name: Deploy EKS Cluster
run: |
# Install necessary CLI tools
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
# Create EKS Cluster
eksctl create cluster --name my-eks-cluster --region us-west-2 --nodegroup-name my-nodes --node-type t3.medium --nodes 3
# Add additional eksctl options as per your requirements
- name: Configure kubectl
run: |
aws eks --region us-west-2 update-kubeconfig --name my-eks-cluster
While deploying, go to AWS Cloudmation or AWS EKS console to monitor progress.
Once done, to view the new EKS, set up aws on your local machine
In ~/.aws/credential, add a section for your profile (you can name the profile to anything, such as my-profile)
... [my-profile] aws_access_key_id = <aws-access-key-id-val> aws_secret_access_key = <aws-secret-access-key-val> ...
Then list the new EKS cluster
$ aws eks list-clusters --profile my-profile --region us-west-2
{
"clusters": [
"my-eks-cluster"
]
}