Git Product home page Git Product logo

http_server's Introduction

http_server

A dead simple Ruby web server. Serves on port 80. /healthcheck path returns "OK" All other paths return "Well, hello there!"

$ ruby webserver.rb

Deploy a dead simple web server in minikube using ruby and ansible

A dead simple Ruby web server. Serves on port 80. /healthcheck path returns "OK". All other paths return "Well, hello there!"

Overall Architecture of the deployment

  • The deployment can either use kubernetes yaml file or helm chart
  • Code move from GitHub to Jenkins which is deposited in the Ubuntu Virtual Machine I spinned up
  • Code get into Jenkins automatically by setting up webhook in Jenkins and notifying GitHub to activate webhook
  • To setup webhook in GitHub, go to (url of the repo)/settings/hooks then add webhook.

Overview of GitHub to Server Architecture

Screenshot of store Architecture GitHub to Server

CI/CD Pipeline Architecture with Jenkins

Screenshot of CI/CD pipeline

Docker Level Architecture

$ docker build -t adjusttest .   # To build docker image with the docker image name "adjusttest 
#Login to dockerhub on the server and provide the neccessary credentials
$ docker push danielademeso/adjusttest:${BUILD_NUMBER} #Jenkins will provide the build number that will be used her per build done
$ docker rmi danielademeso/adjusttest:${BUILD_NUMBER}  #To remove the image from the server to reduce memory usage of the server
$ docker system prune -f  #To remove any possible dangling Image 

Kubernetes Level Architecture

  • Namespace: Development, Staging and Production
  • Loadbalancer in front of the application
  • Two pods were stated in the deployment file for high availability
# A namesapce for developement, staging and production differented with different port where port 80 is for the production namespace among other service
#Production Layer
$ kubectl -n production get deployment
$ kubectl -n production get pods
$ kubectl -n production get svc #To get url of the load balancer 

#Staging Layer
$ kubectl -n staging get deployment
$ kubectl -n staging get pods
$ kubectl -n staging get svc #To get url of the load balancer

#Development Layer
$ kubectl -n development get deployment
$ kubectl -n development get pods
$ kubectl -n development get svc #To get url of the load balancer

For manual deployment, Once the installation is done, clone the repo as below.

$ git clone https://github.com/danade002/http_server
$ kubectl apply -f deploytodev.yaml #For dev environment
$ kubectl apply -f deploytostaging.yaml #For staging environment
$ kubectl apply -f deploytoprod.yaml #For Production environment

Minikube Snippet

  • Checks existing minikube status and starts a single node minikube cluster if none exists.
  • Switches docker environment to minikube.
  • Deletes old images of the application, remove dangling image and rebuilds a new docker image.
  • Gets the minikube's IP address to add it as an External IP to the application loadbalancer service by using minikube tunnel .
  • Creates a Kubernetes Application Deployment for our Ruby WebServer using the docker image pushed to dockerhub.
  • Creates a Kubernetes LoadBalancer Service for our application.
  • Exposes the Application LoadBalancer service to the host via minikube tunnel.
  • Tests the application endpoints response by accessing the published url via curl or can be accessible on the browser if need be using portforwarding due to minikube.

Testing Application

Due to the restriant of minikube on the loadbalancer, Minikube has a way of getting loadbalancer External IP which is via minikube tunnel in a detach mode

$ minikube tunnel #To get loadbalancer external IP
#production ip
$ curl http://localhost:80/healthcheck
OK 
$ curl http://localhost:80/
Well, hello there 
$ curl http://localhost:80/anything
Well, hello there 

#staging
$ curl http://localhost:90/healthcheck
OK 
$ curl http://localhost:90/
Well, hello there 
$ curl http://localhost:90/anything
Well, hello there

#development ip
$ curl http://localhost:85/healthcheck
OK 
$ curl http://localhost:85/
Well, hello there 
$ curl http://localhost:85/anything
Well, hello there 

http_server's People

Contributors

artemyevav avatar danade002 avatar sawasy avatar

Stargazers

 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.