Skip to content

ComplexNetTSP/net4255-project-2023-2024-Makvola

Repository files navigation

Review Assignment Due Date

TSP logo

NET 4255: High Availability Web Services

Assistant: Gatien Roujanski

Introduction

  • Clone this repository
  • Each challenge must be validated with a professor and then committed and pushed to your own github repository.
  • Before starting a given step, present the sketch of your infrastructure to a professor.
  • We strongly recommend that you use Alpine OS as the base operating system for your docker image.

Challenge 0: Install

On your own computer install the following software:

Challenge 1: Create a Simple Web page and develop a docker file for your website (2 pts)

  • Build a one page Flask application which contains the following elements:
    • Your name
    • Your project name
    • Version of your website (i.e. V1)
    • The server hostname
    • The current date
  • Build a docker container which contains your Flask web page
  • Test your application
  • Send your docker container on DockerHub
  • Draw a schema of your systems (ex. draw.io)
    • Show the system
    • Show the container IP address
    • Show the container ports

Notes about Flask

Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself.

A minimal Flask application looks something like this:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

Now you can run the web serveur you just created

$ flask --app hello run
* Serving Flask app 'hello'
* Running on http://127.0.0.1:5000 (Press CTRL+C to quit)

See the quickstart guide for more information

References

Challenge 2: Create docker compose to deploy a mongodb database server (2pts)

  • Find a already made mongodb docker container (for instance the mongodb community server)
  • Use docker compose to deploy your mongodb database
  • Test your application and add record in your database manually with the mongod command (see the install requirement for mongodb
  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the containers IP address or hostname
    • Show the container ports

References

Why mongodb ?

MongoDB is a database based on nosql. It's easier to create a master/slave database cluster when using nosql.

Challenge 3: Create docker compose file to deploy a simple web service (flask + mongodb) (2pts)

  • Update your Flask application and add the following items:
    • Your name
    • Your project name
    • Version of your website (i.e. V1)
    • The server hostname
    • The current date
  • Flask application should connect to a mongodb database each time a request is served :
    • It connects to the mongodb database through pymongo
    • For each request, it will record in the mongodb database:
      • The IP address of the client
      • The current date
  • Your flask application should display the last 10 records of the database
  • Update Flask app version displayed on the page to V2
  • Finaly deploy your services using a docker compose file with the following elements:
    • Docker service for your website (your flask application)
    • Docker service for your mongodb database
    • Network to connect the previous services
  • Send your docker container on DockerHub with the correct tags.
  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the container IP address
    • Show the container ports

References

Challenge 4: Install a load balancer for your infrastructure (1pts)

Add a NGINX load balancer to your Docker compose file. Update your docker compose file with the following elements:

  • 2 Flask application
    • Deploy 1 Flask app without database connections
    • Deploy 1 Flask app with database connections
  • 1 NGINX load balancer which balances the load between the two web server
  • 1 Mongodb database
  • Network
  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the container IP address and the hostname of each container
    • Show the container ports

References

Challenge 5: Learn Kubernetes with the online tutorial (1pts)

$ gcloud auth login 
...
  • Select net-4255 as the default project
$ gcloud config set project net-4255 
  • Install the kubeconfig file on your computer
$ gcloud container clusters get-credentials net4255-gke --location=us-central1-a

After this command you should have kubeconfig.yml file on your laptop. This file will enable you to get access to the kubernetes cluster.

$ ls $HOME/.kube/
kubeconfig.yml

Export kubeconfig file

$ export KUBECONFIG=$HOME/.kube/kubeconfig.yml

Now, you should be able to connect to the kuberntest cluster. Check the following command in order to check the connection.

$ kubectl cluster-info
...

You should see a namespace with your name !!! with the following command:

$ kubectl get namespace

References

Challenge 6: Launch your first Pod in command line (1pts)

Create your first deployment in command line with the kubectl command:

  • Create a deployment for the webnodb container in your own namespace
    • Without any replicat
    • Without any service
  • Check that your deployment is successful in the google cloud console and with the command line:
$ kubectl get deployments -o wide
...
$ kubectl get pods -o wide
...
  • Test the pod web server id correctly running with port-forwarding
$ kubectl port-forward pods/xxxx your pod name xxxx :xxx pod port xxx --namespace=xxxx your namespace xxxx
Forwarding from 127.0.0.1:54127 -> 5000

Now you can connect with your browser to http://127.0.0.1:54127 to access the webnodb website.

References

Challenge 7: Create your first deployment file with a ClusterIP service (1pts)

  • Create a Deployment file for your container webnodb (the one without database)
  • Be careful, create your Deployment and the ClusterIP service in your on namespace !!!!
  • Show on a new schema how a request is served from the service to the pods:
    • The schema should explain which port is used at each step and what IP address is used by each component (nodes, pods, services)
  • Request the following resources per pod:
    • cpu resource: 1/10 CPU per pod
    • memory: 100 Mo per pod
  • Limit your pod resources as the following:
    • cpu resourse: 1/5 of CPU per pod
    • memory: 200 Mo per pod
  • Connect to the cluster through a proxy with the following command or use port-forwarding to test your application:
$ kubectl proxy
Starting to serve on 127.0.0.1:8001 

Now should be able to access to the webnodb web page at the following url http://127.0.0.1:8001/api/v1/namespaces/__your_namespace_name__/services/__your_service_name__/proxy/

  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the container IP address and the hostname of each container
    • Show the container ports

References

Challenge 8: Deploy on the Kubernetes cluster your website (webdb) and the respective mongodb database (2pts)

  • Deploy the webdb web service with 3 replica and its related service (NodePort)
  • Deploy the mongodb database and its related service (ClusterIP)
  • Connect the web service to the database using kubernetes DNS hostname
  • Explain the difference between a NodePort Service and a ClusterIP service
  • Validate your deployment (webdb, mongodb) by using port-forwarding
  • Request the following resources per pod:
    • cpu resource: 1/10 CPU per pod
    • memory: 100 Mo per pod
  • Limit your pod resources as the following:
    • cpu resourse: 1/5 of CPU per pod
    • memory: 200 Mo per pod
  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the container IP address and the hostname of each container
    • Show the container ports

References

Challenge 9: Expose your services (1pts)

  • Create a Ingress in order to expose your web application (webnodb and webdb)
    • GKE has some custom-made feature in order to deploy Ingress, be sure to read carefully to Ingress documentation of GKE
    • Don't forget to deploy your ingress in your own namespace !!!
  • The kubenetes cluster has a public IP address with the hostname: "net4255.luxbulb.org" create a service that redirects http traffic of the following url to your respective deployment:
  • Test your Ingress
  • Update the schema of your infrastructure (ex. draw.io)
    • Show the system
    • Show the container IP address and the hostname of each container
    • Show the container ports

Warning, please call the teacher before applying your Ingress.

References

Challenge 10: Automate your deployment with HELM (1pts)

  • Create a HELM Chart to deploy the whole infrastructure
  • Use ConfigMaps to store database hostname and port information

References

Challenge 11: Update the mongodb database Deployment with a StatefulSet (1pts)

  • Instead of a traditional deployment use a StafulSet to deploy your mongodb database
  • Use a Persistant Volume to store the database content
    • Stockage ressource : 0.1 Go
  • Update the previous mongodb service with a headless service
  • There should be only one replicat for the mongodb database
  • Explain what is a StatefulSet and in which case it is usefull
  • Explain what is a headless service, how pods are named with headless service
  • Update your previous Helm chart accordinly
  • Your first database in the statefulSet (example: mongo-0) should have a valid DNS hostname

References

Challenge 12: Rolling update (1pts)

  • Update the version number in each of the HTML page of the respective website (webdb and webnodb) and rebuild their repective docker container (and bump up their version humber)
  • Deploy your new container as a rolling update

References

Challenge 13: Automatic scaling (1pts)

  • Create a deployment that spin a new pod when the CPU utilization of a pod cross a certain threasold (e.g.: 60% Utilization)
  • Limit to maximum number of pods to be deploy to 10 pods

References

Challenge 14: Liveness Probes (1pts)

  • Define Liveness Probe for each container in your Chart
  • Becareful each application might need a specific type of probe
  • Explain you choose a spefic type of probe for a given application

References

Challenge 15: Create a Network policies (1pts)

  • Create a Network policy that restrict access to the database only to IP address corresponding to your Web Pods
  • Test your network policy

References

Challenge 16: Create a distributed database system (I) (2pts)

  • Create a master-slave architecture with mongodb
  • Don't use already made Helm chart to achive this challenge
  • Manualy configure each instance of the mongodb database to be part of a Replica Set (meaning that a given master database is replicated to all the slaves in the cluster)

References

Challenge 17: Create a distributed database system (II) (1pts)

  • Create a Helm Chart that deploy a master-slave architecture with mongodb

Challenge 18: Deploy a Redis cache in your infrastructure (1pts)

  • Explain what is the advantage of updating your infrastructure with a redis cache ?
  • Define your new infrastructure

References

Challenge 19: Implement Hooks on Helm

  • Use Hooks to configure your ConfigMaps before and after the deployment of your helm chart
  • (Optional) Use hooks to save your database before updating helm chart

References

About

net4255-project-2023-2024-Makvola created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published