VOOZH about

URL: https://thenewstack.io/deploy-a-mean-web-app-with-google-kubernetes-engine-portworx/

⇱ Deploy a MEAN Web App with Google Kubernetes Engine, Portworx - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2019-03-01 09:12:36
Deploy a MEAN Web App with Google Kubernetes Engine, Portworx
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 Janakiram MSV
👁 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.
export PROJECT=’<Your GCP Project ID>’
gcloud container --project $PROJECT clusters create "tns-demo" \
--zone "asia-south1-a" \
--username "admin" \
--cluster-version "1.11.7-gke.4" \
--machine-type "n1-standard-4" \
--image-type "UBUNTU" \
--disk-type "pd-ssd" \
--disk-size "50" \
--scopes "https://www.googleapis.com/auth/compute","https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \
--num-nodes "3" \
--enable-cloud-logging \
--enable-cloud-monitoring \
--network "default" \
--addons HorizontalPodAutoscaling,HttpLoadBalancing,KubernetesDashboard


The below command updates kubeconfig with the credentials and endpoint of the cluster.
gcloud container clusters get-credentials tns-demo \
--zone asia-south1-a \
--project $PROJECT


Let’s add the current user to role cluster-admin
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)

Verify that the cluster is up and running. 👁 Image

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.
kubectl version --short | awk -Fv '/Server Version: / {print $3}'
Portworx relies on etcd to store the metadata and cluster state. For this demo, we will use the built-in etcd cluster. 👁 Image
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. 👁 Image
Choose defaults for the Network tab and click Next. 👁 Image
In the last tab, choose Google Kubernetes Engine and click Finish. 👁 Image
We are ready to install Portworx based on the generated specification. You can either download the spec or copy it. 👁 Image
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. 👁 Image

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.
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
 name: px-sc
provisioner: kubernetes.io/portworx-volume
parameters:
 repl: "3"

kubectl create -f px-sc.yaml
With the StorageClass in place, we will create a Persistent Volume Control (PVC) that will be used by MongoDB Pod.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
 name: px-mongo-pvc
 annotations:
 volume.beta.kubernetes.io/storage-class: px-sc
spec:
 accessModes:
 - ReadWriteOnce
 resources:
 requests:
 storage: 1Gi

kubectl create -f px-mongo-pvc.yaml
The storage backend for MongoDB Pod is now ready. 👁 Image
Let’s go ahead and create the MongoDB Pod.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
 name: db
 labels:
 name: mongo
 app: todoapp 
spec:
 strategy:
 rollingUpdate:
 maxSurge: 1
 maxUnavailable: 1
 type: RollingUpdate
 replicas: 1
 template:
 metadata:
 labels:
 name: mongo
 app: todoapp
 spec:
 schedulerName: stork
 containers:
 - name: mongo
 image: mongo
 imagePullPolicy: "Always"
 ports:
 - containerPort: 27017
 volumeMounts:
 - mountPath: /data/db
 name: mongodb
 volumes:
 - name: mongodb
 persistentVolumeClaim:
 claimName: px-mongo-pvc

kubectl create -f db-pod.yaml
To make the database Pod accessible to the web application, we will expose it through a ClusterIP-based Service.
apiVersion: v1
kind: Service
metadata:
 name: db
 labels:
 name: mongo
 app: todoapp
spec:
 selector:
 name: mongo
 type: ClusterIP
 ports:
 - name: db
 port: 27017
 targetPort: 27017

kubectl create -f db-svc.yaml
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.
apiVersion: apps/v1
kind: Deployment
metadata:
 name: web
 labels:
 name: web
 app: todoapp
spec:
 replicas: 3
 selector:
 matchLabels:
 name: web
 template:
 metadata:
 labels:
 name: web
 spec:
 containers:
 - name: web
 image: janakiramm/todo
 ports:
 - containerPort: 3000

Finally, we will expose the web application through a load balancer.
apiVersion: v1
kind: Service
metadata:
 name: web
 labels:
 name: web
 app: todoapp
spec:
 selector:
 name: web 
 type: LoadBalancer
 ports:
 - name: http
 port: 80
 targetPort: 3000
 protocol: TCP

Check the Service created for the web app to get the IP address of the load balancer. 👁 Image
Accessing the web app shows the below UI. 👁 Image
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.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.