Create docker files 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.
1 application – 3 replicas 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.
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 from question 1.
Create a bash script to change the scale for the container apps to 10. (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), do not use hash or hash_ip.
Push to the git all your files\changes.
how to test you work:
Scale containers to 10 containers.
Open browser developer toolbar on storage\applications
Go to your site
See the ip of the server\container you got + see it in the cookie
Refresh – see that this is the same ip as 1- sec ago
Delete cookie and refresh – make sure the ip changed to new server