Quickly try out Kubernetes with two Pods–web app and database

Lucas Jellema
0 0
Read Time:2 Minute, 35 Second

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.

image

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:

wget https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/azure-vote-all-in-one-redis.yaml

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:

image

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.image

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.

Resources

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

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next Post

Gitpod for Oracle Cloud Infrastructure development

Gidpod provides ephemeral development environments. Run a Gitpod workspace and get a clean environment with precisely those components that have been configured for the use case or context you need to work in. Everytime a workspace is initialized and everyone who does that, the environment will be exactly the same. […]
%d bloggers like this: