A short peek into Google’s container offerings

Google is the inventor of Kubernetes and, to this date, the driving force behind it. One would thus expect that Google has a compelling offering around hosted Kubernetes. Let's have a peek into it. To continue, you need to either have an existing account with Google Cloud or you can create a test account here at https://console.cloud.google.com/freetrial. Proceed with the following steps:

  1. In the main menu, select Kubernetes Engine. The first time you do that, it will take a few moments until the Kubernetes engine is initialized.
  2. Once this is ready, we can create a cluster by clicking on CREATE CLUSTER.
  3. Name the cluster as pets-cluster and leave all other settings in the Create a Kubernetes Cluster form with their default values and click on Create.

It will again take a few moments to provision the cluster for us. Once the cluster has been created, we can open the Cloud Shell. This should look similar to the following screenshot:

First Kubernetes cluster ready and Cloud Shell open in GCE

We can now clone our labs GitHub repository to this environment with the following command:

$ git clone https://github.com/fundamentalsofdocker/labs
$ cd labs/ch14/gce

We should now find a pets.yaml file in the current folder, which we can use to deploy the pets application into our Kubernetes cluster. Have a look at the file:

$ less pets.yaml

It has pretty much the same content as the same file we used in the previous chapter. The two differences are:

Before we can continue, we need to first set up gcloud and kubectl credentials:

$ gcloud container clusters get-credentials pets-cluster \
--zone us-central1-a

Having done that, it's time to deploy the application:

$ kubectl create -f pets.yaml

Once the objects have been created, we can observe the LoadBalancer service web until it is assigned a public IP address:

$ kubectl get svc/web --watch

This should look similar to the following screenshot:

Retrieving the public IP address of the service web

We can then use this IP address and navigate to http://<IP address>:3000/pet and we should be greeted by the familiar cat image.

To clean up and delete all resources, run this script:

kubectl delete deploy/web
kubectl delete deploy/db
kubectl delete svc/web
kubectl delete svc/db

We have created a hosted Kubernetes cluster in GCE. We have then used the Cloud Shell provided through the GCE portal to first clone our labs GitHub repository and then the kubectl tool to deploy the pets application into the Kubernetes cluster. 

When looking into a hosted Kubernetes solution, GCE is a compelling solution. It makes it very easy to start and since Google is the main driving force behind Kubernetes, we can rest assured that we will always be able to leverage the full uncrippled functionality of Kubernetes.