Docker: Deploying to production with Kubernetes

This is quickstart guide on how to deploy a docker application with kubernetes.

You will need the following

Your first step is to create your project here []

You will need to authenticate yourself and also setup your project on the cli with the following:

gcloud config set project <PROJECTID>

Assuming you have your production Dockerfile(s) prepared we now need to build our image (After this you may wish to run it to test it locally via Docker run)

docker build -t${PROJECT_ID}/reactnodedemo:v1 .

Next we will push our Docker image to google cloud.

gcloud docker -- push${PROJECT_ID}/reactnodedemo:v1

We’ll now create our cluster ( We can either set the zone before or in the create with the –zone flag)

gcloud container clusters create readnodedemo-cluster --zone us-central1-a 

Once that is finished we can run the following to see if it created successfully

gcloud container clusters list

Now we need to create our deployment file. The purpose of the deployment file is to tell kubernetes how want the state of our application/resources to be. It is then it’s job to maintain that state.

apiVersion: apps/v1beta1
kind: Deployment
  name: reactnodedemo-deployment
  replicas: 1
        app: reactnodedemo 
      - name: reactnodedemo
        image: reactnodedemo:v1 
        - containerPort: 3000
kubectl create -f deployment.yml --save-config
kubectl get pods

Finally we will expose our cluster and also provision a load balancer

kubectl expose deployment reactnodedemo-deployment --type="LoadBalancer"

We can then run the following to see our exposed IP’s and ports

kubectl get services

And with that you should now be able to go to the exposed IP/port and see your application running