https://github.com/iambotcoder/portfolio-k8s-deployment
AWS EKS-based deployment of a portfolio website using Docker, Kubernetes, and a LoadBalancer Service.
https://github.com/iambotcoder/portfolio-k8s-deployment
Last synced: about 2 months ago
JSON representation
AWS EKS-based deployment of a portfolio website using Docker, Kubernetes, and a LoadBalancer Service.
- Host: GitHub
- URL: https://github.com/iambotcoder/portfolio-k8s-deployment
- Owner: iambotcoder
- Created: 2025-01-14T15:54:02.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-14T16:42:27.000Z (about 1 year ago)
- Last Synced: 2025-02-05T11:51:44.696Z (about 1 year ago)
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Portfolio Website Deployment Using Kubernetes (EKS)
## π Overview
This project demonstrates the deployment of a portfolio website using Kubernetes (EKS), Docker, and Docker Hub. It includes the steps for setting up EKS, building a custom Docker container, and deploying the application using Kubernetes services like LoadBalancer.
---
## π Table of Contents
- [Prerequisites](#prerequisites) π
- [Setup & Installation](#setup-and-installation) π οΈ
- [Docker Setup](#docker-setup) π³
- [Kubernetes Deployment](#kubernetes-deployment) ποΈ
- [Accessing the Application](#accessing-the-application) π
- [Cleaning Up Resources](#cleaning-up-resources) π§Ή
- [Conclusion](#conclusion) β
---
## π Prerequisites
Before you start, ensure you have the following:
- An AWS account π
- **eksctl** and **kubectl** installed for interacting with EKS cluster
- **Docker** installed for building and pushing Docker images
- A Docker Hub account for pushing your Docker images
- Basic knowledge of Kubernetes and Docker π§βπ»
---
## πΊοΈ Architecture
The architecture of the portfolio website deployment involves the following components:
- **AWS EKS Cluster**: A managed Kubernetes cluster that hosts the application.
- **Docker**: Used to build and containerize the website.
- **LoadBalancer Service**: Exposes the website to the internet.
- **Kubernetes Deployment**: Ensures the application is running in pods, with multiple replicas for scalability.
The application follows a microservices architecture, where the frontend service is independently deployed and managed.

---
## π οΈ Setup & Installation
### 1οΈβ£ Install eksctl and kubectl
- Install **eksctl** and **kubectl** following the official documentation.
### 2οΈβ£ Create a Cluster for Your Portfolio Website
```bash
eksctl create cluster --node-type t2.micro --nodes 2
eksctl get cluster
eksctl get nodes
```
---
## π³ Docker Setup
### 1οΈβ£ Install Docker
- Download Docker and Docker Desktop from the official Docker website.
- Create a Docker Hub account.
### 2οΈβ£ Create a Dockerfile
Here is the Dockerfile that configures your website container:
```dockerfile
FROM httpd
COPY assets/ /usr/local/apache2/htdocs/assets
COPY website-demo-image/ /usr/local/apache2/htdocs/website-demo-image
COPY error.html /usr/local/apache2/htdocs/error.html
COPY index.html /usr/local/apache2/htdocs/index.html
```
### 3οΈβ£ Build the Docker Image
Run the following command to build your custom Docker image:
```dockerfile
docker build -t custom-httpd .
docker images
```
### 4οΈβ£ Run the Container Locally
```dockerfile
docker run -d -p 8080:80 custom-httpd
```
(If port 8080 is already in use, run on port 8081 instead.)
To check the locally hosted website, go to:
http://localhost:8080
### 5οΈβ£ Push the Docker Image to Docker Hub
- Login to Docker Hub:
```dockerfile
docker login --username=
```
- Tag and push the Docker image to your Docker Hub repository:
```dockerfile
docker tag imageid //custom-httpd
docker push /repo
```
---
ποΈ ### Kubernetes Deployment
1οΈβ£ Load Balancer and Deployment YAML
Hereβs the manifest file for the LoadBalancer service and deployment:
```yaml
apiVersion: v1
kind: Service
metadata:
name: lb-service
labels:
app: lb-service
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: frontend
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
spec:
replicas: 2
selector:
matchLabels:
app: frontend
minReadySeconds: 30
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend-container
image:
```
2οΈβ£ Deploy the Application
Use the following command to deploy the LoadBalancer service and the frontend application:
```bash
kubectl apply -f loadbalancerservice.yaml
kubectl get all
```
This will create 2 pods for your frontend application.
3οΈβ£ Access the Running Container
To enter the running container:
```bash
kubectl exec -it -- /bin/sh
```
You can verify the files inside the container by using the `ls` command.
4οΈβ£ Access the Website
To get the LoadBalancer URL:
```bash
kubectl get service
```
---
## π» Output
After successful deployment, you can access the portfolio website via the LoadBalancer URL. The website should be available and accessible from the internet, displaying the portfolio content.
Example of access:
- Open the LoadBalancer URL obtained from the `kubectl get service` command in the browser.
- The website will be visible, served from the containerized application.

---
### π§Ή Cleaning Up Resources
To delete the Kubernetes resources (deployment and service), run the following commands:
```bash
kubectl delete deployment
kubectl delete service lb-service
```
This will remove the deployed application and associated resources from your cluster.
---
### β
Conclusion
This project demonstrates how to deploy a portfolio website using Kubernetes on AWS EKS. It covers the steps to set up the environment, build a custom Docker container, push the container to Docker Hub, and deploy it on Kubernetes using LoadBalancer services. This setup enables seamless access to the website via a scalable architecture.
---
## π¨βπ« Instructor
This project was guided by **Rajdeep Saha**, who provided valuable mentorship throughout the process.