Deploying to Google Kubernetes Engine

Previously we looked at building a Spring Cloud Data Flow on Kubernetes. As a follow up, we’re now looking at deploying to Google Kubernetes Engine. The great thing about Kubernetes you use exactly the same commands to manage a cluster on your laptop as on a server or cloud compute platform. Google has first class support for Kubernetes on the Google Kubernetes Engine so deploying the Primer application was very straightforward.

Download the tools

Google Kubernetes Engine has an excellent Quickstart tutorial that helps you download and configure the gcloud shell. Once you’ve downloaded the shell, run a couple of commands to point it at your GKE project:

I skipped the step to Create a GKE Cluster – I preferred to set this up through the GKE console so that I had more control over how the cluster and nodes were configured.

Then use gcloud to configure your kubectl to point at your GKE project. If you’ve followed along with the previous tutorial, your kubectl is currently pointing at your local Minikube instance. Do this to have your commands run against your GKE instance instead:

Setup an ingress

In order to route traffic from the internet into the application, we’ll need to set up an ingress. This is a static IP address that points to an exposed port on your application.

Then add the ingress to your stack by creating a Kubernetes definition:

This routes the newly created primer-ip ingress to our primer-display-v1 service.

Deploy!

I want to deploy the Primer application described in the previous article. One of the great things about Kubernetes is that you can use the same deployment descriptor for any environment. So we’ll use the descriptors from the previous article with just a couple of changes.

First, we need to push the locally built Docker images to the Google Docker Registry, tagged with your GCE project.

Update the deployment descriptors with the tagged images and deploy!

Last time we ran this it deployed to our local Minikube. Now we’re deploying to GKE. All being well your application will start up and be available on your ingress port.

Check status using the kubectl get pods command:

kubectl get pods

or the Google Kubernetes Engine console:

GKE Workloads screen

Finally, check the Ingress IP and view in a browser:

GKE Ingress screen

Configure a DNS

If you want this available on a named domain rather than simply an IP, add an ‘A’ record to your DNS pointing to your ingress IP.

Dreamhost DNS

Hey presto! That’s the app up onĀ http://primer.dontpanicblog.co.uk/

Leave a Reply

Your email address will not be published. Required fields are marked *