Edit on GitHub


Deploy with Google's Kubernetes #

Kubernetes is "an open-source system for automating deployment, scaling, and management of containerized applications." It was developed by Google to handle the ops demand for an organization of that scale and the flexibility for running an infrastructure at any size.

First off, make sure you already have a Google Account. Sign in to the Google Cloud Platform and also sign up for a free trail on Google Container Registry and create a new project. Remember your project ID and use it on your command line:

$ export PROJECT_ID="your-project-id"

Install Google Cloud SDK. After this installs, run the following command to install Kubernetes:

$ gcloud components install kubectl

We will use your Docker image from the "Deploy with Docker" section. Navigate to the docker app folder and update the Dockerfile to the following:

FROM node:4.5
RUN npm i -g npm@3
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
RUN /usr/src/app/node_modules/.bin/gulp build
CMD node server

Let's test out your image with Docker. Run the command below:

$ docker run -d -p 3000:3000 docker-awesome-container

Visit your app in the browser at http://localhost:3000. You can stop running the container by using the command below:

$ docker stop docker-awesome-container

We can now push the image to the Google Container Registry. Your Docker images will be stored in a private repo that is accessible from every Google Cloud project as well as from outside the Google Cloud Platform.

$ gcloud docker push gcr.io/$PROJECT_ID/docker-awesome-container:v1

You can explore other Kubernetes capabilities and dig deeper in the the extensive reference documentation.