

To create a Kubernetes 1.5 cluster, run the following command: gcloud container clusters create "test-cluster" Once you have a Google Cloud project created and have your Google Cloud SDK setup (hint: gcloud init), we can create our cluster. If you want to follow along with this tutorial and use Google Cloud Platform, you also need the Google Cloud SDK. The sidecar container used for auto-configuration is also unsupported.īefore we get started, you’ll need a Kubernetes 1.5+ and the Kubernetes command line tool. Note: StatefulSets are currently a beta resource. You can create and manage your MongoDB replica set natively in Kubernetes, without the need for scripts and Makefiles. With StatefulSets, these headaches finally go away. Scaling the set up and down meant managing all of these resources manually, which is an opportunity for error, and would put your stateful application at risk In the previous example, we created a Makefile to ease the management of these resources, but it would have been great if Kubernetes could just take care of all of this for us. You had to manually create a disk, a ReplicationController, and a service for each replica.

While the replica set in my previous blog post worked, there were some annoying steps that you needed to follow. If you’ve followed my previous posts, you know how to create a MEAN Stack app with Docker, then migrate it to Kubernetes to provide easier management and reliability, and create a MongoDB replica set to provide redundancy and high availability. With StatefulSets, Kubernetes makes it much easier to run stateful workloads such as databases. Kubernetes 1.5 includes the new StatefulSet API object (in previous versions, StatefulSet was known as PetSet). At Google, everything runs in a container, including databases. “Containers are stateless!” they say, and “databases are pointless without state!” The code examples need changes to work on a current Kubernetes cluster.Ĭonventional wisdom says you can’t run a database in a container.
