https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
https://learn.hashicorp.com/tutorials/terraform/install-cli
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04
https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
1.1 Ensure aws-cli is installed and configured in your linux machine with full access to AWS by running below command,
aws s3 ls
Go to S3. Click create bucket. Use a custom name
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.23.0"
}
}
backend "s3" {
bucket = "sk-capstone-tf"
key = "terraform.tfstate"
region = "us-east-1"
}
}
provider "aws" {
# Configuration options
region = "us-east-1"
}
Run below command to initiate terraform
terraform init
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "sk-capstone-vpc"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]
enable_nat_gateway = true
enable_vpn_gateway = true
tags = {
Terraform = "true"
Environment = "dev"
}
}
terraform plan
1.4 Create a file outputs.tf to get the vpc and subnet IDs(you can get these IDs from console as well)
output "vpc_id" {
description = "ID of project VPC"
value = module.vpc.vpc_id
}
output "privateSubnet1_id" {
description = "ID of privateSubnet1"
value = module.vpc.private_subnets[0]
}
output "privateSubnet2_id" {
description = "ID of privateSubnet2"
value = module.vpc.private_subnets[1]
}
output "publicSubnet1_id" {
description = "ID of publicSubnet1"
value = module.vpc.public_subnets[0]
}
output "publicSubnet2_id" {
description = "ID of publicSubnet2"
value = module.vpc.public_subnets[1]
}
terraform apply
1.6 Update the VPC and subnet IDs in eks-conf.yaml file from stub siles. Add the file in Cluster directory.
Run below command to create an eks cluster
eksctl create cluster -f sk-eks-config.yaml
kubectl get nodes
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Verify the installation
kubectl top nodes
kubectl apply -f autoscalar.yaml
2.2 Write a Dockerfile to dockerise the upg-loadme nodejs application in same folder where app files are located.
FROM node:12.18.1
LABEL maintainer="swapnilkhot36@gmail.com"
ENV NODE_ENV=production
WORKDIR /app
COPY ["package.json", "./"]
RUN npm install --production
COPY . .
EXPOSE 8081
CMD [ "node", "server.js" ]
docker images
docker run -itd -p 8081:8081 <image ID>
The image id should be displayed after docket images command. Make sure you are using the latest image ID.
Use the last public node config and update taint config and a new name for the ng
- name: pub-201-a-2
labels: { role: workers }
tags:
k8s.io/cluster-autoscaler/enabled: "true"
k8s.io/cluster-autoscaler/my-eks-201: "shared"
taints:
- key: "critical"
value: "true"
effect: NoSchedule
instancesDistribution:
instanceTypes:
- t2.medium
desiredCapacity: 0
minSize: 0
maxSize: 1
subnets:
- sk-capstone-cluster-pub-a
eksctl create nodegroup --config-file=sk-eks-config.yaml
kubectl create ns demo
kubectl create -f upg-loadme.yaml --namespace=demo
kubectl create -f upg-loadme-ingress.yaml --namespace=demo
kubectl get pods --namespace=demo
kubectl describe node describe ip-10-0-101-198.ec2.internal
resources:
limits:
cpu: "200m"
memory: "200Mi"
auth:
enabled: false
https://helm.sh/docs/intro/install/
helm repo add bitnami https://charts.bitnami.com/bitnami
helm search repo redis
helm install my-release bitnami/redis -f redis.yaml -n demo
kubectl get pods -n demo
cluster$ kubectl run redis --image redis -n demo
kubectl get services -n demo
kubectl run redis --image redis -n demo
redis-cli -h my-release-redis-master -p 6379
SET foo 1
kubectl get pods -n demo
kubectl delete pod my-release-redis-master-0 -n demo
GET foo
kubectl create -f upg-loadme-hpa.yaml --namespace=demo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install capstone-prom prometheus-commun