example python microservice project
install in developer mode from source
python setup.py develop
pip install git+ssh://[email protected]/lundybernard/batconf.git@main
start the web server on local host
bat start
run tests against the web server
python -m unittest functional_tests/service_test.py
pytest functional_tests/service_test.py
Install the package
python setup.py install
python setup.py develop
start webserver with cli
bat start
Run functional tests
bat test service
pytest functional_tests/service_test.py
to validate the docker container works properly, and docker-compose works
Run the container with docker-compose and test it with functional_tests
docker-compose build
docker-compose up
pytest functional_tests/service_test.py
container_test will run docker-compose before each test case, and execute the test against the running container
python -m unittest container_tests/container_test.py
pytest container_tests/container_test.py
CLI
bat run_container_tests
sometimes necessary if container tests are failing
docker-compose down --rmi local
docker-compose build
- install Microk8s
sudo snap install microk8s --classic
microk8s.start
- Start a local Docker Registry
docker run -p 5001:5001 registry
- Tag and Push the image to your docker registry
docker build -t bat-app ./
docker tag bat localhost:5001/bat-app
docker push localhost:5001/bat-app
- Run the application and ingress
microk8s.kubectl apply -f k8/ingress.yml
microk8s.kubectl apply -f k8/bat-app-deployment.yml
- enable ingress
microk8s.enable ingress
and verify
microk8s.kubectl get all -A
- expose the application
microk8s.kubectl expose deployment bat-app --type=LoadBalancer --port=8080
- test the endpoint
curl -kL https://127.0.0.1/bat-app