Coder Social home page Coder Social logo

dit-scalable-app's Introduction

Infinite Scale

Deploying and Scaling Laravel application on Kubernetes (k8s)

A project created for the Cloud-Computing subject (2019-2020) from Theodors Mandilaras (cs2190018)

For more information read the InfiniteScale_project_report.pdf

Setup the environment

Start minikube

minikube start --driver=virtualbox
minikube status
minikube dashboard

kubectl config use-context minikube

Create the docker-image

eval $(minikube docker-env)  # so the image can be created in space viewable from the minikube
cd in/the/project
docker build . -t  teo/scalable-app 

Setup the Application

Deploy on K8s

kubectl apply -f nginx_deployment.yaml 
kubectl apply -f nginx_service.yaml
kubectl apply -f nginx_configMap.yaml
kubectl apply -f php_deployment.yaml 
kubectl apply -f php_service.yaml

Get the application URL:

minikube service nginx  # auto load

minikube service nginx --url  # for manual copy

Error fixing:

Because we are using busybox image in initContainer lifecycle event, this will not copy code from our image to volume because php container or pod is not yet created. So we might get forbidden or NOT FOUND error when we open our nginx service in browser, so we have to copy code manually to the /code/scale-app/ directory

kubectl get pods
# login into the pod
kubectl exec -it scalable-app-<one random pod name> -- /bin/bash
# copy the app in the correct destination
cp -r /var/www/. /code/scalable-app
# fix some permissions
chown -R $USER:www-data storage/
chown -R $USER:www-data bootstrap/cache/
chmod -R 775 storage/
chmod -R 775 bootstrap/cache/

Set the ingress

minikube addons enable ingress
kubectl apply -f ingress.yaml
kubectl describe ingress

Now the app can be found in the given

Set the horizontal app

minikube addons enable metrics-server
kubectl apply -f autoscaling.yaml

we can also do kubectl apply -f ./ to set all the .yaml files simultaneously


Clean up:

kubectl delete deployment scalable-app
kubectl delete service scalable-app
kubectl delete deployment nginx
kubectl delete service nginx
kubectl delete configmap nginx-config
kubectl delete ingress scalable-app

Evaluation

Using the SIEGE 4.0.4

sudo apt-get update -y
sudo apt-get install -y siege

siege <url>  # usage

dit-scalable-app's People

Contributors

teomandi avatar

Stargazers

 avatar

Watchers

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