The app is my recruitment assignment for junior DevOps position at PCSS. It is supposed to return IP of the requesting client. It should return content type based on HTTP request header (not sure i understood correctly) and also return a full list of returned IP addresses. The app is supposed to be written in Python and run as a Docker container. Errors are handled by Flask, request frequency as well. Docker image contains Python-alpine image which is only ~40MB. The app also contains Kubernetes YAML file which allows for app and service deployment, and also monitoring app's health and restarting it when it returns HTTP error code.
To get a local copy up and running follow these simple example steps.
- Docker
Go to https://docs.docker.com/get-docker/, choose suitable version and install it.
- kubectl
Go to https://kubernetes.io/docs/tasks/tools/, click link corresponding to your os version and follow the instructions/
-
Open CMD/Terminal
-
Navigate to a directory containing downloaded repository
-
Create Docker image out of the repository
docker build -t pcss-zad-rek-jf .
Very important to name the image exactly like in the example above!!! If You won't name the image like that, You will need to change the image name in .yaml file needed for Kubernetes deployment!
-
Deploy app in Kubernetes
kubectl apply -f api-k8.yaml
-
The app is running! YEY!
- App uses port 80 so remeber to check if there is no app already listening on this port!
- To check your IP address go to http://server_ip_address/
- To see list of all registered addresses go to http://server_ip_address/history
- The app won't return external client's IP address (from outside of the Kubernetes LAN) but I'm unsure if it's even possible with the way Kubernetes and Docker proxy their requests.