Code Monkey home page Code Monkey logo

k8s-sistemicloud's Introduction

Sample 3-Layer Application in Kubernetes

This repository contains a simple 3-layer application deployed in Kubernetes, using Flask for the frontend and backend layers, and PostgreSQL for the database layer.

flowchart LR

  user(((user)))

  feService((Frontend Service))

  subgraph Frontend Layer
    fwNode1(Frontend Pod 1 - Flask)
    fwNode2(Frontend Pod 2 - Flask)
    fwNode3(Frontend Pod 3 - Flask)
  end

  beService((Backend service))

  subgraph Backend Layer
    beNode1(Backend Pod 1 - Flask)
    beNode2(Backend Pod 2 - Flask)
    beNode3(Backend Pod 3 - Flask)
  end

  dbService((Database service))

  subgraph Database Layer
    dbNode[(PostgreSQL Pod - Database)]
  end

  user --> feService

  feService --> fwNode1
  feService --> fwNode2
  feService --> fwNode3

  fwNode1 --> beService
  fwNode2 --> beService
  fwNode3 --> beService

  beService --> beNode1
  beService --> beNode2
  beService --> beNode3

  beNode1 --> dbService
  beNode2 --> dbService
  beNode3 --> dbService

  dbService --> dbNode
Loading

Prerequisites

Before running the application, ensure you have the following installed:

  1. Docker: To build the container images.
  2. Kubernetes: To deploy the application using the provided example.yaml file.
  3. kubectl: The Kubernetes command-line tool to interact with the Kubernetes cluster.

Getting Started

  1. Clone this repository:
git clone https://github.com/codesimo/k8s-SistemiCloud.git
cd k8s-SistemiCloud
  1. Build the Docker images for the frontend and backend layers:
docker build -t myfrontend:latest ./frontend
docker build -t mybackend:latest ./backend
  1. Deploy the application to your Kubernetes cluster:
kubectl apply -f example.yaml

The example.yaml file contains Kubernetes deployment and service configurations for the frontend, backend, and PostgreSQL database layers.

  1. Accessing the Application

Once the application is successfully deployed, you can access it through the Kubernetes services.

  • Frontend: Access the Flask frontend by navigating to http://<frontend-service-ip> in your web browser.
  • Backend: The backend is accessed internally by the frontend service to handle data processing. It is not directly exposed externally.
  • PostgreSQL: The PostgreSQL database is not directly accessible from outside the cluster. The backend service interacts with it internally.

Cleaning Up

To remove the application and associated resources from your Kubernetes cluster, run the following command:

kubectl delete -f example.yaml

run.sh

Alternatively, you can use the provided run.sh script, which automates the build and deployment process. Ensure the script has execution permission:

chmod +x run.sh

Then, you can run the application with a single command:

./run.sh

Customization

You can customize the application by modifying the Flask frontend and backend code in their respective directories. Additionally, you can adjust the example.yaml file to accommodate specific deployment requirements.

k8s-sistemicloud's People

Contributors

codesimo avatar

Stargazers

Giuseppe Pitruzzella avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.