Create docker file for this application and deploy containers using docker compose:
Nginx official (not plus or any other image) load balancer container that will listen on port 80 and route traffic to applications, do not usee ip_hash in the nginx conf.
the application will run on 3 replica containers. The logs generated by the application are required to be retained so that they can be accessed after the container is stopped. The application will be written using python. Assume you already have code for this application (next task).
DB container. The data and logs of the database container are required to be retained so that they can be accessed after the container is stopped.
push all your source to the github repository.
Write a Python server web app. The application have 2 routes:
Route: “/” :
Adding +1 to a global counter, and saving it to the DB.
Create a cookie for 5 minutes with the value of the internal IP.
Record the date and time, the client’s IP address, and its own internal IP address in a MySQL table named access_log.
Return to the browser: internal IP address of the server.
Route: “/showcount”
Return to the browser: The global counter number
Run this application under app containers (docker).
Create a bash script to change the scale for the container apps to 5. (scale up\down)
Push all your source to the github repository.
Using a cookie from the app, create a stickiness engine in your nginx load balancer (once you get a response from one server, stay on this server for 5 minutes).
Push all your source to the github repository.
How to test your project
open developer toolbar
go to application\storage
go to cookie
see the cookie you created with the internal IP of the container
check that the is is like 172.X.X.3-9 (usually) and it’s the same IP you see in the browser.
Refresh, the IP in the browser stick to you! (do it more than once).
Delete the cookie and refresh – now see that the IP changed.
do 6-7 again.
After home assignment + test, contact me on whatsapp to schedule zoom.