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 enterprise organization with the flexibility to run an infrastructure at any size.
To start, make sure you already have a Google Account. Sign in to the Google Cloud Platform and also sign up for a free trial 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"
$ 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.5RUN npm i -g npm@3EXPOSE 3000RUN mkdir -p /usr/src/appWORKDIR /usr/src/appCOPY . /usr/src/appRUN npm installRUN /usr/src/app/node_modules/.bin/clap buildCMD 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