- Introduction and Application Architecture
- Setting up the React Application
- Setting up the Spring WebApplication
- Setting up the Python Application
- Container-ization of the Services
- Container-ization of everything else
- Introduction to Kubernetes
- Kubernetes in Practice – Pods
- Kubernetes in Practice – Services
- Kubernetes in Practice – Deployments
- Kubernetes and everything else in Practice
To start the Python application we need to have Python3 and Pip installed (their environment variables need to be set up as well).
Navigate in the CMD to the directory sa-logic/sa (repo) and type the following command:
$ python -m pip install -r requirements.txt $ python -m textblob.download_corpora
Starting the app
Pip installs the dependencies and we are ready to start the application by executing the following command:
python sentiment_analysis.py * Running on http://localhost:5000/ (Press CTRL+C to quit)
Which means that our application is running and listening for HTTP Requests at the port 5000 on localhost.
Inspecting the Code
Let’s investigate the code to understand what is happening in the SA Logic python application.
- Instantiate a Flask object.
- Defines the path at which a POST request can be made.
- Extract the “sentence” property from the request body.
- Instantiate an anonymous TextBlob object and get the polarity from the first sentence. (We have only one).
- Return the response with the body containing the sentence and the polarity to the caller.
- Run the flask object app to listen for requests on localhost:5000.
The services are set up to communicate with each other, give them a try before continuing on!
Let’s recapitulate what we did; We started all the microservices running in different ports, we configured each to communicate with each other, and this was a tedious process, but it worked, so why Kubernetes you ask? Because our application is not scalable, it’s not resilient and not maintainable. Stay tuned as in the next article, we will go over how to start the services in Docker Containers, as it is a prerequisite to being able to run them in Kubernetes Cluster.If you enjoyed the article, please share and comment below!