Deploy a Microservice in Kubernetes with zero lines of code

22 Sep 2021 » kubernetes

In general, To deploy a Microservice in Kubernetes you have to perform the following tasks:

Import a Google Kubernetes Engine

  1. Build a Docker Image of a Microservice
  2. Push that Docker Image into an Image Registry
  3. Create a YAML’s for different Kubernetes objects such as Deployment, Service, Secret, etc.
  4. Apply those YAMLs using the following command:

    kubectl apply -f <FILE_NAME>
    

All the above tasks require you to write a lot of code. What If I do all this in a single command?

Yes, It is possible. Using gopaddle you can deploy a Microservice in Kubernetes without writing any extra code in just one command.

Let me show you How?

Before you start deploying, finish the below prerequisites:

I. Sign up for a free trial account in gopaddle

II. Import a Google Kubernetes Engine (GKE) into your gopaddle account.

Import a Google Kubernetes Engine

III. Add an Image Registry in your gopaddle account.

Add an Image Registry

IV. Add a source code repository in your gopaddle account that will have a source code of a Microservice that you want to deploy in Kubernetes. For this blog, I have used node-hello repository.

Add a source code repository

V. Install gpctl CLI using the below commands:

wget https://gpctl.s3-ap-southeast-1.amazonaws.com/gpctl
chmod +x gpctl
cp gpctl /usr/local/bin/

Note: Refer Official Documentation for more details.

Gear up yourself to deploy a Microservice in Kubernetes

Gear Up

Follow the below steps along with me.

I. Clone node-hello git repository using the following command:

git clone https://github.com/sagar-jadhav/node-hello.git

II. Go to the node-hello directory using the following command:

cd <path_to_node_hello_repo>/

III. Install dependencies using the following command:

sh buildScript.sh

IV. log in to gopaddle account using the following command:

gpctl login -emailID=<EMAIL> --password=<PASSWORD> --endPoint=https://portal.gopaddle.io
  • EMAIL: Email to connect to gopaddle account
  • PASSWORD: Password to connect to gopaddle account

V. Deploy Microservice in Kubernetes using the following command:

gpctl init --startScript=./runScript.sh --buildScript=./buildScript.sh --buildImage=node:8

The above command will prompt you to select the Cluster, Registry, and Policy. Please select appropriately to proceed further.

That’s it !! with this, you have deployed a Microservice in Kubernetes without writing any deployment code.