Continuous Deployment of TypeScript Service on Kubernetes using skaffold.dev
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”
- Now open the cmd inside the apis folder and run the command “npm init -y”
- Now run the command npm install typescript ts-node-dev experess @type/express
- Now create new folder “src” inside “apis” folder.
- 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.