The goal of this project is to run a Python application inside a Docker container (or a container inside a k8s cluster using a docker image) to track a Brazilian post office's order.
This application receives as parameters (reading from environment variables):
- a tracking code of an order of Brazilian post offices
- a method to track or inform the order's status
Also is neeeded to provide (as environment variables) a Twitter's API credentials kit (token, token secret, consumer key and consumer key secret) and a Twitter's username who will receive the status information of the tracked order via Direct Message, informing updates about the order's status. If you choose to monitor the order, keep in mind the last update the application will send is when the order left the post office towards your home :)
[X] Python 3.X
[X] Twitter API
[X] Correios Webservice
[X] Docker
[X] Kubernetes
Example:
$ python3 app.py -c OJ693674304BR -f trackOrder_v2
- -c = tracking code
- -f = consult method
- 'lastStatus': shows in console the latest status of the order
- 'orderHistory': shows in console the history status the order
- 'trackOrder_v2': starts to monitor the tracking code, sending Twitter's Direct Message everytime an update in the order's status appears
$ docker build -t docker-rastreio-correios .
The trick here is: the environment variables! You gonna need to set your Twitter API token and consumer data, your Twitter username (or who you want to receive the DMs), your tracking code and finally the function you wanna to execute. Now 'env.list' will do the trick :)
$ docker run --env-file devops/env.list docker-rastreio-correios
Once the image is created in your enviroment or pushed to a repository, you'll be able to use it to create a Pod to run your application. If you prefer, use my image persisted in Docker Hub.
$ docker pull lyamadadocker/docker-rastreio-correios:v1
I'm using minikube to run my k8s cluster. Feel free to do it wherever you prefer.
This object is very important, because it contains the enviroment variables the application needs.
$ kubectl create -f k8s-config-map.yaml
$ kubectl create -f k8s-pod.yaml
$ kubectl get pods
Using minikube it's easy to monitor things through the dashboard. Such as:
You just need to type:
$ minikube dashboard
I'd like to get the opportunity to say my "Thank you very much" to @rennancockles (https://github.com/rennancockles), who shared his developments about the classes used in this project to grab the data from Brazilian's post office :) You rock, Rennan!
Please feel free to reach me out to asnwer doubts you might have. Enjoy! :)