Skip to content

Erodotos/any-paste

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Any Paste: A simple web application build with Fiber

Table of contents

  1. Introduction
  2. Prerequisites
  3. Installation
  4. Project architecture exmplation and Demo

Introduction

This project is about creating and deploying a web application comprising a backend and frontend microservices on a Kubernetes cluster. When looking over the internet for similar projects endeavouring to understand the whole development and deployment picture, I could not find a particular example expanding on networking between microservices while using a frontend, backend and a database to store data. Thus, after assembling information from different sources, I created a simple web application using Fiber (a Go web framework).

The application is called Any Paste, and it is a cheap clone of Pastebin.com. In other words, a user can submit any text, and Any Paste will store it in a database. Afterwards, the users can retrieve a specific piece of posted text, providing its identification number.

Prerequisites

You need access to a local or remote Kubernetes cluster, such as Minikube or AKS. You also need the kubectl cli tool, which will allow you to connect to the desired Kubernetes cluster.

Installation

The current installation does not include automation tools such as helm or kustomize to automatically package and install our Kubernetes manifest files.

  1. Connect to your Kubernetes cluster via kubectl - for each Kubernetes provider there is a different way to get on your cluster. Please ask Google or ChatGPT to show you the way :)

  2. Create a new namespace for the application

    kubectl create namespace any-paste

  3. Install the mysql instance using the following commands (note that in general it is a bad idea to deploy databases on Kubernetes. Make sure you watch my full video for more details):

    kubectl apply -f .k8s/database/volume.yaml --namespace any-paste

    kubectl apply -f .k8s/database/secret.yaml --namespace any-paste

    kubectl apply -f .k8s/database/config-map.yaml --namespace any-paste

    kubectl apply -f .k8s/database/deployment.yaml --namespace any-paste

    kubectl apply -f .k8s/database/service.yaml --namespace any-paste

  4. Install the backend of our application using the following commands:

    kubectl apply -f .k8s/api/deployment.yaml --namespace any-paste

    kubectl apply -f .k8s/api/service.yaml --namespace any-paste

  5. Install the frontend of our application using the following commands:

    kubectl apply -f .k8s/website/deployment.yaml --namespace any-paste

    kubectl apply -f .k8s/website/service.yaml --namespace any-paste

  6. Enable the Ingress Contrller for your cluster. If you are on Docker Desktop you can use kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml, while for Minikube you can use minikube addons enable ingress. Essentially, an Ingress Controller is a loadbalancer which takes as input an Ingress Resource that describes how we want to perform loadbalancing.

  7. Finally, we need to deploy an Ingress Resource to describe how we want to manage the incoming traffic. Note that all deployed services (database, frontend and backend) are all deployed on a private virtual network and are not accessible from the outside world. Hence, we need to deploy ingress, which will route incoming traffic to our application. For this, use the following command:

    kubectl apply -f .k8s/ingress.yaml --namespace any-paste

Project architecture explanation and Demo

Demo Video

About

Any Paste is a simple web application build with Go Fiber. The aim of this project is to show how to create a Kubernetes-ready microservice app.

Topics

Resources

Stars

Watchers

Forks