A simple web service responds HTTP GET requests and returns a JSON containing:
-
Timestamp
-
hostname
Example response
{ "Timestamp": "Sat, 10 Sep 2022 14:22:49 GMT", "hostname": "29ef7d9092cb" }
- Alpine 3.16
- Python 3.10.7
- Flask 2.2.2
- Docker 20.10.17
- Minikube v1.26.1
- Kubernetes v1.24.3
- Prometheus v2.31.1
- Run the script using the example below:
./.CICD/local/NIX/bootstrap.sh
- Run the command below to connect LoadBalancer services
minikube --log_file tunnel.log tunnel
- This script might ask you for
sudo
password if enabled in the system, please enter your user password and continue - This command will display an output like the example below:
Status: machine: minikube pid: 46831 route: 10.96.0.0/12 -> 192.168.39.81 minikube: Running services: [] errors: minikube: no errors router: no errors loadbalancer emulator: no errors
- This script might ask you for
- Application responds to requests using the simple.info domain.
Use the IP address in step2.2
,192.168.39.81
in the example, to punch a name record in/etc/hosts
file192.168.39.81 simple.info
Docker is used to develop and test the application
- Simply build the docker image
docker build --tag simple-python-web-app:development -f .CICD/docker/development.Dockerfile .
- Run the built image
docker run --name simple-web-app -p 5000:5000 simple-python-web-app:development
- Application will start to serve on port
5000
and can be accessed using this URL: http://127.0.0.1:5000
-
Build the docker image
docker build --tag simple-python-web-app:production -f .CICD/docker/production.Dockerfile .
-
Tag the production image for docker registry
docker tag simple-python-web-app:production localhost:5000/simple-python-web-app
-
Push the image
docker push localhost:5000/simple-python-web-app
Note
You can use the deployment script
./.CICD/deploy.k8s.sh
-
Visit http://simple.info address in your favourite browser