A simple microservices deployment using Docker, Kubernetes, Terraform, and GitHub Actions.
- Python app containerized using Docker
- Deployed and exposed externally using Kubernetes
- Terraform to deploy an AWS EKS Cluster
- CI/CD using GitHub Actions to automate building and deploying to DockerHub
# Build the image
docker build -t microservice-app .
# Run locally
docker run -p 5000:5000 microservice-appThe app should be accessible at http://IP-or-localhost:5000. Test endpoints like /products.
Terraform needs AWS permissions to deploy the EKS cluster:
# Option 1: AWS CLI. Simplest.
aws configure
# Option 2: Environment variables
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_REGION="us-east-1"Deploy the cluster:
cd terraform
terraform init
terraform applyConfigure kubectl with the output command from Terraform:
aws eks update-kubeconfig --region us-east-1 --name microservice-clusterDeploy the application:
kubectl apply -f kubernetes/deployment.yaml
kubectl apply -f kubernetes/service.yaml
# Get the external URL
kubectl get service microservice-app -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'Set up these repository secrets:
DOCKERHUB_USERNAME- Your DockerHub usernameDOCKERHUB_TOKEN- Your DockerHub access tokenAWS_ACCESS_KEY_ID- AWS access keyAWS_SECRET_ACCESS_KEY- AWS secret key
To get a DockerHub token:
- Log in to DockerHub
- Account Settings → Security → Access Tokens
- Create a new token with "Read & Write" permissions
- Copy the token (shown only once)
The workflow automatically builds the Docker image, pushes it to DockerHub, and deploys to your Kubernetes cluster. It also outputs the external URL to test the application.