Skip to content

nmvuong92/nodejs_k8s

Repository files navigation

build image

docker build -t charlie/nodejs_k8s .

Re-build the image and notice Docker re-using previous layers:

docker run --rm -d -p 3000:3000 charlie/nodejs_k8s

Stop the container:

docker stop CONTAINER_ID

Push the image to DockerHub:

docker push charlie/nodejs_k8s

ref: https://www.digitalocean.com/community/tech-talks/how-to-deploy-a-resilient-node-js-application-on-kubernetes-from-scratch

Kubernetes

Get worker nodes:

kubectl get nodes

Create a deployment:

kubectl create deployment --image charlie/nodejs_k8s node-app

Scale up to 3 replicas:

kubectl scale deployment node-app --replicas 3

Expose the deployment as a NodePort replica:

 kubectl expose deployment node-app --type=NodePort --port 3000

Look at the newly created service (and the assigned port):

kubectl get services

Grab the public IP of one of the worker nodes:

kubectl get nodes -o wide

Browse to IP:port to test the service Edit the service:

kubectl edit service node-app

Replace port: 3000 with port: 80

Replace type: NodePort with type: LoadBalancer

Verify that the service was updated:

kubectl get service

Run the above command every few seconds until you get the external IP address of the Load Balancer Browse to the IP of the Load Balancer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published