Two colleagues wanted to try out Kubernetes and more specifically deployment of an application on Kubernetes that was not entirely trivial. One that consists of at least two Pods – one running a database and one running an application.
A little internet browsing brought me to a single YAML file that defined the situation outline in the diagram below: two pods – one running a (Python based) web application and a MongoDB database respectively. Both pods expose a service on a specific port. The service for the front end pod is of type LoadBalancer – and is therefore assigned a public IP.
The steps to get this to run on a Kubernetes cluster instance are very straightforward. Since they were working on Oracle Cloud Infrastructure, with the OKE (Oracle Kubernetes Engine), that is where they applied the manifest file to deploy the Kubernetes resources as shown in the picture.
First, run the OKE cluster using the OKE quick start wizard as described in this article – technology.amis.nl/cloud/getting-started-again-with-kubernetes-on-oracle-cloud/ for example on an OCI free trial account.
Then get access to the K8S cluster through kubectl, either running locally or – simpler yet – in the OCI Cloud Shell. Download the YAML file that defines the pods (or rather deployments) and services:
And apply the resource definitions:
kubectl apply -f azure-vote-all-in-one-redis.yaml
Four resources are created. Two container images are downloaded – one for MongoDB and one for the web application.
It will take a little while – 30 seconds to 2 minutes – for the external IP to be assigned to the service of type Load Balancer. With
kubectl get service azure-vote-front –watch
we can inspect the status of the service and see when the IP address is assigned:
When the service has its address awarded, we can access the application on the public IP address.
It is a Cats and Dogs voting system – from an Azure Tutorials series. The MongoDB database is used to store the state for the application. Note however that it is ephemeral itself: once the backend pod is stopped, the state is lost. No great loss it would seem.
The original tutorial provides instructions on scaling the frontend pod: https://learn.microsoft.com/en-us/azure/aks/tutorial-kubernetes-scale?tabs=azure-cli – a nice further exploration.
Thanks to the definitions prepared and shared by the good folks over at Azure, we could quickly get some Kubernetes resources to run on our own Kubernetes cluster instances and play around a little.
Quickly get started with Oracle Kubernetes Engine on Oracle Cloud Infrastructure – https://technology.amis.nl/cloud/getting-started-again-with-kubernetes-on-oracle-cloud/
One comprehensive Kubernetes manifest with two deployments and two services – spinning up a web application with separate MongoDB backend: https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/azure-vote-all-in-one-redis.yaml
Original Azure Tutorial: https://learn.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-application?tabs=azure-cli