In general, To deploy a Microservice in Kubernetes you have to perform the following tasks:
- Build a Docker Image of a Microservice
- Push that Docker Image into an Image Registry
- Create a YAML’s for different Kubernetes objects such as Deployment, Service, Secret, etc.
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.
III. Add an Image Registry in your gopaddle account.
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.
gpctl CLI using the below commands:
chmod +x gpctl
cp gpctl /usr/local/bin/
Note: Refer Official Documentation for more details.
Gear up yourself to deploy a Microservice in Kubernetes
Follow the below steps along with me.
I. Clone node-hello git repository using the following command:
git clone https://github.com/developersthought/node-hello.git
II. Go to the node-hello directory using the following command:
III. Install dependencies using the following command:
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.
Hope you like this blog and find it useful, If Yes then do consider buying me a coffee.