From 29aa80079712706db2021b14132378b34a8ac665 Mon Sep 17 00:00:00 2001 From: Abhishek Veeramalla Date: Thu, 3 Aug 2023 20:00:58 +0530 Subject: [PATCH] eks demo --- day-22/2048-app-deploy-ingress.md | 18 ++++++++ day-22/alb-controller-add-on.md | 62 +++++++++++++++++++++++++ day-22/configure-oidc-connector.md | 19 ++++++++ day-22/installing-eks.md | 18 ++++++++ day-22/prerequisites.md | 7 +++ day-22/sample-app.md | 72 ++++++++++++++++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 day-22/2048-app-deploy-ingress.md create mode 100644 day-22/alb-controller-add-on.md create mode 100644 day-22/configure-oidc-connector.md create mode 100644 day-22/installing-eks.md create mode 100644 day-22/prerequisites.md create mode 100644 day-22/sample-app.md diff --git a/day-22/2048-app-deploy-ingress.md b/day-22/2048-app-deploy-ingress.md new file mode 100644 index 00000000..06696968 --- /dev/null +++ b/day-22/2048-app-deploy-ingress.md @@ -0,0 +1,18 @@ +# 2048 App + +## Create Fargate profile + +``` +eksctl create fargateprofile \ + --cluster demo-cluster \ + --region us-east-1 \ + --name alb-sample-app \ + --namespace game-2048 +``` + +## Deploy the deployment, service and Ingress + +``` +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/examples/2048/2048_full.yaml +``` + diff --git a/day-22/alb-controller-add-on.md b/day-22/alb-controller-add-on.md new file mode 100644 index 00000000..e70a1bd7 --- /dev/null +++ b/day-22/alb-controller-add-on.md @@ -0,0 +1,62 @@ +# How to setup alb add on + +Download IAM policy + +``` +curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json +``` + +Create IAM Policy + +``` +aws iam create-policy \ + --policy-name AWSLoadBalancerControllerIAMPolicy \ + --policy-document file://iam_policy.json +``` + +Create IAM Role + +``` +eksctl create iamserviceaccount \ + --cluster= \ + --namespace=kube-system \ + --name=aws-load-balancer-controller \ + --role-name AmazonEKSLoadBalancerControllerRole \ + --attach-policy-arn=arn:aws:iam:::policy/AWSLoadBalancerControllerIAMPolicy \ + --approve +``` + +## Deploy ALB controller + +Add helm repo + +``` +helm repo add eks https://aws.github.io/eks-charts +``` + +Update the repo + +``` +helm repo update eks +``` + +Install + +``` +helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ + -n kube-system \ + --set clusterName= \ + --set serviceAccount.create=false \ + --set serviceAccount.name=aws-load-balancer-controller \ + --set region= \ + --set vpcId= +``` + +Verify that the deployments are running. + +``` +kubectl get deployment -n kube-system aws-load-balancer-controller +``` + + + diff --git a/day-22/configure-oidc-connector.md b/day-22/configure-oidc-connector.md new file mode 100644 index 00000000..aecac225 --- /dev/null +++ b/day-22/configure-oidc-connector.md @@ -0,0 +1,19 @@ +# commands to configure IAM OIDC provider + +``` +export cluster_name=demo-cluster +``` + +``` +oidc_id=$(aws eks describe-cluster --name $cluster_name --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5) +``` + +## Check if there is an IAM OIDC provider configured already + +- aws iam list-open-id-connect-providers | grep $oidc_id | cut -d "/" -f4\n + +If not, run the below command + +``` +eksctl utils associate-iam-oidc-provider --cluster $cluster_name --approve +``` \ No newline at end of file diff --git a/day-22/installing-eks.md b/day-22/installing-eks.md new file mode 100644 index 00000000..00f3322a --- /dev/null +++ b/day-22/installing-eks.md @@ -0,0 +1,18 @@ +# Install EKS + +Please follow the prerequisites doc before this. + +## Install using Fargate + +``` +eksctl create cluster --name demo-cluster --region us-east-1 --fargate +``` + +## Delete the cluster + +``` +eksctl delete cluster --name demo-cluster --region us-east-1 +``` + + + diff --git a/day-22/prerequisites.md b/day-22/prerequisites.md new file mode 100644 index 00000000..8fcde161 --- /dev/null +++ b/day-22/prerequisites.md @@ -0,0 +1,7 @@ +# prerequisites + +kubectl – A command line tool for working with Kubernetes clusters. For more information, see [Installing or updating kubectl]("https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html"). + +eksctl – A command line tool for working with EKS clusters that automates many individual tasks. For more information, see [Installing or updating]("https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html"). + +AWS CLI – A command line tool for working with AWS services, including Amazon EKS. For more information, see [Installing, updating, and uninstalling the AWS CLI]("https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html") in the AWS Command Line Interface User Guide. After installing the AWS CLI, we recommend that you also configure it. For more information, see [Quick configuration]("https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config") with aws configure in the AWS Command Line Interface User Guide. diff --git a/day-22/sample-app.md b/day-22/sample-app.md new file mode 100644 index 00000000..7c82800d --- /dev/null +++ b/day-22/sample-app.md @@ -0,0 +1,72 @@ +# Sample App deployment + +## Copy the deploy.yml to your local and save it with name deploy.yml + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: eks-sample-linux-deployment + labels: + app: eks-sample-linux-app +spec: + replicas: 3 + selector: + matchLabels: + app: eks-sample-linux-app + template: + metadata: + labels: + app: eks-sample-linux-app + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - amd64 + - arm64 + containers: + - name: nginx + image: public.ecr.aws/nginx/nginx:1.23 + ports: + - name: http + containerPort: 80 + imagePullPolicy: IfNotPresent + nodeSelector: + kubernetes.io/os: linux +``` + +## Deploy the app + +``` +kubectl apply -f deploy.yaml +``` + + +## Copy the below file as service.yml + +``` +apiVersion: v1 +kind: Service +metadata: + name: eks-sample-linux-service + labels: + app: eks-sample-linux-app +spec: + selector: + app: eks-sample-linux-app + ports: + - protocol: TCP + port: 80 + targetPort: 80 +``` + +## Deploy the service + +``` +kubectl apply -f service.yaml +``` \ No newline at end of file