Introduction
This post will cover how to dockerize a Node.js server to deploy on a Kubernetes cluster using Google Kubernetes Engine (GKE). We will be setting up a Node.js server, creating a Dockerfile to define the container configuration, create Kubernetes service files to define our required Kubernetes resources and setting up Google Cloud Build for automated continuous integration (CI). I uploaded my own code to GitHub here in case you run into any issues along the way, so make sure to keep it handy!
If you’ve completed my tutorial on dockerizing and deploying Node.js using Google Compute Engine, or you already have a dockerized Node.js app, you can skim through the first few steps of this tutorial as they are mostly repeats.
If you have your own Node.js app you’d like to use that’s fine too, although it may be easier to complete this tutorial with a simple application to avoid any unnecessary errors. For the purpose of this tutorial, I’m going to use a Node boilerplate script I’ve written — https://github.com/francescov1/node-boilerplate-script.
Note: if you are using your own Node.js code, ensure it is setup to run on port 3000 as I will be using that port for all Docker and Google Cloud configuration.
Read the rest here.