Skip to content

bernardev254/kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Flask Profile App (Docker + Kubernetes + Minikube)

This is a simple Flask app with an HTML template that shows a user profile, serves static images, and is containerized with Docker. It also includes full deployment on Kubernetes via Minikube.


🧪 Run Locally (Optional)

python3 -m venv venv
source venv/bin/activate
pip install Flask
python app.py

🐳 Docker Setup

1. Build Docker Image (for local use)

docker build -t flask-profile-app .

2. Run locally using Docker

docker run -p 5000:5000 flask-profile-app

☁️ Push to Docker Hub

1. Login

ldocker login

2. Tag the image

docker tag flask-profile-app <your-dockerhub-username>/flask-profile-app:latest

3. Push to Docker Hub

docker push <your-dockerhub-username>/flask-profile-app:latest

📦 Kubernetes Setup (Using Minikube)

1. Start Minikube

minikube start

2. Enable Docker environment to use Minikube’s Docker daemon

eval $(minikube docker-env)

3. Build Docker image inside Minikube

docker build -t flask-profile-app .

Skip Docker Hub push if you’re using Minikube’s Docker directly.

4. Create deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app
  template:
    metadata:
      labels:
        app: flask-app
    spec:
      containers:
        - name: flask-container
          image: flask-profile-app
          ports:
            - containerPort: 5000
---
apiVersion: v1
kind: Service
metadata:
  name: flask-service
spec:
  type: NodePort
  selector:
    app: flask-app
  ports:
    - port: 5000
      targetPort: 5000
      nodePort: 30001

5. Apply deployment

kubectl apply -f deployment.yaml

6. Check pods


kubectl get pods

7. Access the app

minikube service flask-service

Or manually get Minikube IP:

minikube ip

Then open in browser:

http://<minikube-ip>:30001

🧑‍💻 Author

Bernard (@bernardev254)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published