Continuous Deployment of TypeScript Service on Kubernetes using skaffold.dev

Abhishek Kumar Gupta
2 min readApr 11, 2021

--

Skaffold handles the workflow for building, pushing and deploying your application, allowing you to focus on what matters most.

At present concept of Micro-services are increasing day by day. As well as mostly company as well as developer prefer PaaS (Platform as a Services) and SaaS (Software as a services) rather than setting the complete development environment. In the tutorial I will explain you how we can write the Apis in TypeScript, kubernetes setup, Adding Skaffold and ingress-nginx setup after that deploy it on kubernetes.

Let’s start with Api Setup

Firstly let’s create a new folder named as “hello-word” inside this create another folder named as “apis”

  1. Now open the cmd inside the apis folder and run the command “npm init -y”
  2. Now run the command npm install typescript ts-node-dev experess @type/express
  3. Now create new folder “src” inside “apis” folder.
  4. Inside this create the new file named “index.ts”

Now replace the “test” script inside the package.json with the follwoing

"start": "ts-node-dev src/index.ts"

kubernetes setup

Now create new directories “infra/k8s” inside “hello-word”. Inside the k8s create two new files named as 1) auth-depl.yaml 2) ingress-srv.yaml and add the following code in these file:

skaffold Setup

Now create the new file “skaffold.yaml” inside “hello-word” directory

Now open the cmd inside root directory and run the following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/cloud/deploy.yaml

Or visit the following Installation Guide and choose command according to the os and deployment.

Open you hosts file:

# if you are using ubuntu the run the command
# sudo nano \etc\hosts
# and add the following line in bottom
127.0.0.1 hello-word.com

Now run the following command:

skaffold dev

Now open the “hello-word.dev” in browser.

--

--

Abhishek Kumar Gupta
Abhishek Kumar Gupta

Written by Abhishek Kumar Gupta

Web and Native Mobile App Developer.

No responses yet