Launch an App to a Kubernetes Cluster in 8 Steps

Raymundo Martinez
Sep 23 · 6 min read
Photo by Callum Galloway on Unsplash


Link to Repo:

Step 1: Create an App

For this part, we’ll create a basic app using express to generate a simple web server without a view engine.

You should end up with the following file structure:

Let's make a few changes to the app. First, we’ll change the port that the server is listening to.

Navigate to bin/www

change this:

to this:

All we did is change the port number from 3000 to 8080.

Next, we’ll edit the response of the /users route

Navigate to routes/users.js

change this:

to this:

Now run your server

and test your service on Postman.

We now have a working service!

Step 2: Create a Docker Image

First, we’ll add a Dockerfile to the root directory.

Your Dockerfile should look like this:

Note that the CMD [“node”, “./bin/www”] is the command that runs the application. Alter the command if you have a different one (e.g node server.js).

Next run:

in the root directory to build and tag the docker image.

You should end up with something like this:

View your images by running

you should be able to see a list of the built images.

Now let's run the container!!

here we map the port of the server 8080 to the container port 49160.

Let’s test our container on Postman:


Now we are communicating with a service inside a docker container!

Step 3: Push Image to a Registry

Let’s Create a new project in the Google Cloud Platform.

Login to gcloud:

Now authorize your gcloud account to connect with docker:

You should see this:

Now let’s tag and push the image to the gcloud repository:

Check the container registry to make sure your image was pushed successfully.


Step 4: Create a Cluster

Go to the gcloud platform and create a new cluster.

Rename the cluster to store-cluster and change the location type to regional.

Now make sure that you enable the istio setting!!

We will use this feature to communicate with the cluster.

Step 5: Configure Settings to Connect Kubernetes with Your New Cluster

Connect to the project you created in Step 3:

Now connect to the cluster created in Step 4:

Check that kubernetes is communicating with your gcloud cluster:


Almost there!!!

Step 6: Create a Yaml File Defining Your Service

Create a new file in the root directory called store-service.yaml

There will be 3 parts in this file:

  • Service
  • ServiceAcount
  • Deployment


make sure to include the “ — -” at the end of the section.



Replace “URL_TO_DOCKER_IMAGE” with the url of the image pushed to the registry in Step 3.

You can find the url in the Container Registry section

Click the store repository.

Now copy the ‘full image name’ and add it to the Deployment section above.

Let’s deploy our container!

Check that the service was deployed successfully:

You should see:

Check the status of the deployed container:

You should see:

Great now let's open a gateway to our service!!

Step 7: Create a Gateway Yaml File

Add a new file to the root directory called store-gateway.yaml.

There are 2 sections to this file:

  • Gateway
  • VirtualService


Virtual Service:

Deploy the gateway:

Check that it deployed successfully.

You should see:

Now its time to test! :D

Step 8: Test Your Service

Let’s get the IP address of the gateway we created above.


you should see:


Now go to Postman and test your service by calling:



Now you are free to explore the limits of docker, gcloud and kubernetes.

Enjoy your journey!!

JavaScript in Plain English

Learn the web's most important programming language.

Raymundo Martinez

Written by

Software developer. Philosophy and psychology enthusiast.

JavaScript in Plain English

Learn the web's most important programming language.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade