- Create system level user to access aws account
- Overall eks setup :
Provision an EKS cluster --> Deploy worker nodes --> Connect to EKS --> Run/Deploy Kubernetes app
Step 1
- Create IAM role, refer : https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster
- Get VPC details
- Create EKS cluster
Step 2
Deploy worker node : https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group
- Create IAM role
- Create node groupe
Step 3
aws eks --region <region code > update-kubeconfig --name <eks cluster name>
..
To store terraform statefile at s3 , use backendblock
terraform {
backend "s3" {
bucket = "my-terraform-state-bucket" # Your S3 bucket name
key = "path/to/my/terraform.tfstate"
region = "us-west-2" # Bucket region
encrypt = true # Ensure this is enabled for security -- optional
dynamodb_table = "my-lock-table" # DynamoDB table for state locking -- optional
}
}
# Create po in eks
k run nginx --image=nginx
# expose pod port
k port-forward pod/nginx 8080:80
# to check if nginx web server working , from laptop browser hit
http://localhost:8080/
# To connect/go inside the pod
k exec -it nginx -- /bin/bash
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80
kubectl apply -f deployment.yaml
- Create a directoty/repo to store helm chart helm create nginx-chart
- Helm install - to deploy app helm install nginx-chart .
- Helm upgrade - to change and apply any deployment config helm upgrade nginx-chart .
- Helm uninstall - to delete all deployment stacks helm uninstall nginx-chart .