TNS
VOXPOP
What news from AWS re:Invent last week will have the most impact on you?
Amazon Q, an AI chatbot for explaining how AWS works.
0%
Super-fast S3 Express storage.
0%
New Graviton 4 processor instances.
0%
Emily Freeman leaving AWS.
0%
I don't use AWS, so none of this will affect me.
0%
Cloud Native Ecosystem / Cloud Services

Deploy a MEAN Web App with Google Kubernetes Engine, Portworx

In this tutorial, we will deploy and manage a Node.js web application and a MongoDB database in Google Kubernetes Engine. To achieve high availability for MongoDB, we will use a Portworx storage cluster deployed on GKE.
Mar 1st, 2019 9:12am by
Featued image for: Deploy a MEAN Web App with Google Kubernetes Engine, Portworx

In one of my previous articles, I introduced Portworx as the container-native storage platform. In this tutorial, we will deploy and manage a Node.js web application and a MongoDB database in Google Kubernetes Engine. To achieve high availability for MongoDB, we will use a Portworx storage cluster deployed on GKE.

Launching a GKE Cluster

Let’s launch a three node GKE cluster based on Ubuntu OS with an SSD-based disk of 50GB attached to each node. Replace the PROJECT with your own GCP project id.


The below command updates kubeconfig with the credentials and endpoint of the cluster.


Let’s add the current user to role cluster-admin


Verify that the cluster is up and running.

Installing Portworx Storage Cluster

Portworx is installed as a DaemonSet on each node of GKE. We can install it by generating the YAML spec through an online tool. Visit the Portworx documentation page to get started.

Get the version of Kubernetes with the following command. The installation tool needs to know the exact version of the distribution.


Portworx relies on etcd to store the metadata and cluster state. For this demo, we will use the built-in etcd cluster.

Under the Storage tab, choose GKE and populate the information for the spec. We are choosing an SSD disk with 20GB as dedicated block storage for Portworx. Since we have three nodes, we will get aggregate storage of 60GB.

Choose defaults for the Network tab and click Next.

In the last tab, choose Google Kubernetes Engine and click Finish.

We are ready to install Portworx based on the generated specification. You can either download the spec or copy it.

Switch to the terminal and run the command copied from the spec generator. It will take a few minutes for Portworx cluster to get installed.

Verify the cluster by checking the Portworx Pods running in kube-system namespace. All the Pods should be running.

Deploying MongoDB

We will create a StorageClass for Portworx with a replication factor of 3. This ensures that the data is redundantly available on multiple nodes.



With the StorageClass in place, we will create a Persistent Volume Control (PVC) that will be used by MongoDB Pod.



The storage backend for MongoDB Pod is now ready.

Let’s go ahead and create the MongoDB Pod.



To make the database Pod accessible to the web application, we will expose it through a ClusterIP-based Service.



The database backend is now ready. It’s time to deploy the web application.

Deploying Node.js Web Application

The web application is a simple todo task list that persists changes to MongoDB. Create the Deployment for the web app with replicas.


Finally, we will expose the web application through a load balancer.


Check the Service created for the web app to get the IP address of the load balancer.

Accessing the web app shows the below UI.

In the next part of this series, I will show you how to perform failover of MongoDB database running within GKE.

Portworx is a sponsor of The New Stack.

Feature image via Pixabay.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: The New Stack.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.