EKS Deployment Explanation
EKS Deployment Explanation
2. **Subnets**
```yaml
PublicSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.0.1.0/24
AvailabilityZone: !Select [0, !GetAZs '']
MapPublicIpOnLaunch: true
```
- Creates 4 subnets: 2 public and 2 private
- Each subnet is in a different availability zone for high availability
- Public subnets automatically assign public IPs to instances
- Each subnet has a /24 CIDR block (256 IP addresses)
3. **Internet Gateway**
```yaml
InternetGateway:
Type: AWS::EC2::InternetGateway
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
```
- Creates and attaches an Internet Gateway to the VPC
- Enables internet connectivity for public subnets
### Prerequisites
1. **IAM Roles Setup**
- Create EKS Cluster Role:
- Go to IAM → Roles → Create Role
- Select EKS service
- Attach `AWSEKSClusterPolicy`
# System updates
sudo apt update -y
sudo apt install awscli -y
- This script:
* Updates the system
* Installs AWS CLI
* Sets up AWS IAM authenticator for EKS authentication
* Configures the PATH
## Deployment Steps
1. **VPC Setup**
```bash
aws cloudformation create-stack --stack-name eks-vpc --template-body file://eks-
vpc.yaml
```
# Update kubeconfig
aws eks --region us-east-1 update-kubeconfig --name cluster1
```
3. **Deploy Application**
```bash
# Apply configurations
kubectl apply -f deployment.yml
kubectl apply -f service.yml
# Verify deployment
kubectl get pods
kubectl get svc
```
4. **Access Application**
- Get worker node public IP
- Access application: http://<worker-node-ip>:32462
## Security Considerations
1. **Security Groups**
- Ensure inbound rules allow:
* Port 32462 for application access
* Port 22 for SSH access
* Port 80 for HTTP traffic
2. **IAM Roles**
- Use principle of least privilege
- Regularly review and audit permissions
- Use AWS managed policies when possible
1. **Health Checks**
```bash
# Check node status
kubectl get nodes
# Check services
kubectl get svc
```
2. **Logs**
```bash
# Get pod logs
kubectl logs <pod-name>