Skip to content

bosukeme/k8s-microservices-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Microservice with Flask, Node, and React (Vite)

This project is a Kubernetes-based microservice application consisting of three main components:

  • Frontend: A React Vite application for the user interface.

  • Backend 1: A Flask API for processing timezone-based requests with a health check endpoint.

  • Backend 2: An Express Node.js API for additional timezone-based processing with a health check endpoint.

The microservices are orchestrated using Kubernetes with Ingress routing for easy access.

Demo

Demo

Architecture

Alt Text

Prerequisites

  • Docker Desktop (with Kubernetes enabled)
  • kubectl
  • Helm
  • minikube

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/bosukeme/k8s-microservices-architecture.git
    cd k8s-microservices-architecture
  2. Deploy the Flask API

    cd k8s/api-flask
    kubectl apply -f flask.deployment.yaml
    kubectl apply -f flask.service.yaml
    kubectl apply -f flask.ingress.yaml
    

    Verify if the resources were created successfully:

    kubectl get po,deploy,svc,ingress -l app=api-flask
    

    Alt Text
  3. Setup Minikube Tunnel:
    Open a new terminal and run:

    minikube tunnel --bind-address 0.0.0.0
    
  4. Set up /etc/hosts:

    ```
    # Linux / MacOs
    minikube ip
    
    # Windows (WSL)
    hostname -I
    ```
    Edit `/etc/hosts`  (Linux/MacOS) or `c\windows\system32\drivers\etc\hosts` (Windows). <br/>
    Add `<ipaddress from the above step>   	api-flask.io` <br/>
    * Example
    ```
    172.29.204.16     	api-flask.io
    ```
    <br/>
    

  5. Verify Flask API Setup
    Visit http://api-flask.io in your browser
    Alt Text

  6. Possible troubleshooting:

    If you are unable to access the endpoint:

    • Restart Minikube Tunnel:
    sudo pkill -f "minikube tunnel"
    minikube tunnel --bind-address 0.0.0.0
    
    • Ensure the Ingress Controller IP type is LoadBalancer:
    kubectl patch svc ingress-nginx-controller -n ingress-nginx -p '{"spec": {"type": "LoadBalancer"}}'
    
    • Enable Ingress:
    minikube addons enable ingress
    
    • Use localhost instead. This will return a list of localhost url for a particular service
    minikube service list
    
  7. Deploy the Node API
    Open a new terminal:

    cd k8s/api-node
    kubectl apply -f node.deployment.yaml
    kubectl apply -f node.service.yaml
    kubectl apply -f node.ingress.yaml
    

    Verify:

    kubectl get po,deploy,svc,ingress -l app=api-node
    

    Update /etc/hosts with: Add <ipaddress from the above step> api-node.io

    • Example
    172.29.204.16     	api-node.io
    

    Visit http://api-node.io on the browser

  8. Deploy the React Client

    Open a new terminal:

    cd k8s/client-react
    kubectl apply -f react.deployment.yaml
    kubectl apply -f react.service.yaml
    kubectl apply -f react.ingress.yaml
    

    Verify

    kubectl get po,deploy,svc,ingress -l app=client-react
    

    Update /etc/hosts with: Add <ipaddress from the above step> client-react.io

    • Example
    172.29.204.16     	client-react.io
    

    Visit http://client-react.io on the browser

Cleanup

  • kubectl delete -f k8s/api-flask/
  • kubectl delete -f k8s/api-node/
  • kubectl delete -f k8s/client-react/

Contributing

If you would like to contribute, please follow these steps:

  • Fork the repository.
  • Create a new branch for your feature or bugfix.
  • Submit a pull request.

Authors

Ukeme Wilson

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published