Skip to content

Latest commit

 

History

History
120 lines (102 loc) · 4.45 KB

README.md

File metadata and controls

120 lines (102 loc) · 4.45 KB

Codacy Badge Codacy Badge

All k8s manifests lives here

  1. ECS Cluster with Service, Task definitions and Load Balancers

Creating AWS EKS version 1.21 with containerd as CRI:-

EKS_VERSION=1.21
AMI_ID=$(aws ssm get-parameter \
    --name /aws/service/eks/optimized-ami/${EKS_VERSION}/amazon-linux-2/recommended/image_id \
    --query "Parameter.Value" --output text)
AWS_REGION=${AWS_DEFAULT_REGION:-us-east-1}
CLUSTER_NAME=containerd-eks

cat > eksctl-containerd.yaml

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: ${CLUSTER_NAME}
  region: ${AWS_REGION}
  version: "${EKS_VERSION}"
managedNodeGroups:
  - name: containerd
    ami: ${AMI_ID}
    overrideBootstrapCommand: |
      #!/bin/bash
      /etc/eks/bootstrap.sh ${CLUSTER_NAME} --container-runtime containerd
eksctl create cluster -f eksctl-containerd.yaml
eksctl delete nodegroup --cluster=containerd-eks --name=containerd
eksctl create nodegroup --cluster=containerd-eks --spot --instance-types=t3.medium
eksctl utils associate-iam-oidc-provider \
    --region us-east-1 \
    --cluster containerd-eks \
    --approve
eksctl create fargateprofile \
    --cluster containerd-eks \
    --name containerd-fp \
    --namespace game-2048
kubectl annotate serviceaccount -n kube-system alb-ingress-controller \
eks.amazonaws.com/role-arn=arn:aws:iam::195725532069:role/eks-alb-ingress-controller
eksctl create iamserviceaccount \
                --name my-serviceaccount \
                --namespace kube-system \
                --cluster containerd-eks \
                --attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
                --approve
CLUSTER_NAME=eks-fargate-alb-demo

eksctl create cluster --name eks-fargate-alb-demo --region us-east-1 --fargate

eksctl utils associate-iam-oidc-provider --cluster eks-fargate-alb-demo --approve

STACK_NAME=eksctl-eks-fargate-alb-demo-cluster
VPC_ID=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" | jq -r '[.Stacks[0].Outputs[] | {key: .OutputKey, value: .OutputValue}] | from_entries' | jq -r '.VPC')
AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account')

eksctl create iamserviceaccount \
--name alb-ingress-controller \
--namespace kube-system \
--cluster $CLUSTER_NAME \
--attach-policy-arn arn:aws:iam::$AWS_ACCOUNT_ID:policy/ALBIngressControllerIAMPolicy \
--approve

Launch Templates

aws ec2 create-launch-template \
--launch-template-name myeks-cluster-managednodegroup \
--version-description "launch templated for creating and managing managed node groups" \
--launch-template-data '{"InstanceType": "t3.medium","TagSpecifications":[{"ResourceType":"instance","Tags":[{"Key":"purpose","Value":"eks-nodes"}]}] }'

aws eks create-nodegroup \
--cluster-name myeks-cluster \ 
--nodegroup-name myeks-nodegroup \
--subnets subnet-0d145ab4a17fcb368 subnet-01748f5bafb75e7a8 \
--node-role 'arn:aws:iam::195725532069:role/node-instance-role' \
--launch-template name=myeks-cluster-managednodegroup,version=1

aws ec2 create-launch-template-version \
--launch-template-name myeks-cluster-managednodegroup \
--version-description "New template version with the addition of key pair and security group allowing SSH access" \
--source-version 1 \
--launch-template-data '{ "KeyName":"eks-lt-keypair", "SecurityGroupIds":["sg-0e28306934fe7faeb"] }'

aws eks update-nodegroup-version \
--cluster-name my-eks-cluster-launch-template-demo \
--nodegroup-name myeks-nodegroup \
--launch-template name=myeks-cluster-managednodegroup,version=4

aws ec2 create-launch-template-version \
--launch-template-name myeks-cluster-managednodegroup \
--version-description "Changing the instance type to t2.xlarge" \
--source-version 1 \
--launch-template-data '{ "InstanceType":"t2.xlarge" }'

aws eks update-nodegroup-version \
--cluster-name my-eks-cluster-launch-template-demo
--nodegroup-name myeks-nodegroup
--launch-template name=myeks-cluster-managednodegroup,version=4