How to Deploy MongoDB on Google Kubernetes Engine (GKE)

Grigor Khachatryan
devgorilla
Published in
4 min readMar 11, 2019

--

This tutorial created form this source for educational purposes and for pre-tutorial for another tutorial.

To set up the MongoDB, you need three things: A StorageClass, a Headless Service, and a StatefulSet.

Create the storage class

The storage class tells Kubernetes what kind of storage to use for the database nodes. On Google Cloud Platform, your storage choices are SSDs and hard disks.

The configuration for the StorageClass looks like this:

This configuration creates a new StorageClass called “fast” that is backed by SSD volumes. The StatefulSet can now request a volume, and the StorageClass will automatically create it.

Deploy this StorageClass:

kubectl apply -f googlecloud_ssd.yaml

Deploying the Headless Service and StatefulSet

Headless Service

--

--