Code Monkey home page Code Monkey logo

any-paste's Introduction

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

any-paste's People

Contributors

erodotos 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.