Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 28, 2021 02:50 am GMT

Deploy an image from IBM Cloud Container Registry to Kubernetes

Welcome back to THINK Tuesdays!

A weekly blog series where I discuss and share my journey with IBM Cloud Services. Before you begin, do checkout my previous blog, Deploy a NodeJS app to IBM Cloud Container Registry. In this THINK tutorial, we will continue our knowledge of IBM Cloud Container Registry and take it a step further by deploying an app in Kubernetes using the container image we put in our registry in the previous tutorial.

Before we get started, let's think about why we need a container management system like Kubernetes. Over time, as applications are written and deployed, they tend to grow and take on new components that are deployed independently. So the one initial container image inevitably becomes many containers. At first, that growth is easy to handle (v1, v2, v3 etc...). But soon it is overwhelming (v1, v2, ..., v125, ..., v355). As your container footprint grows and evolves, a tool for managing the lifecycle of your containers becomes increasingly necessary and that's essentially where Kubernetes comes in.

Prerequistes:

  • A NodeJS App or any app that can be containerized. I have a demo app available on Github for you to follow along:
git clone https://github.com/mrinasugosh/random-cat-facts-nodejs.git
  • kubectl CLI

If you don't already have it, I would start by installing kubectl in your terminal. The quickest way to do this for your local machine is by referring to the Kubectl CLI Docs. Here's the command for a MacOS installation:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"

Now that we have our environment set up. Let's get started!

Steps to Deploy

Within the demo app, you should find a pre-filled deployment.yaml file that we will use to run the image as a Deployment. I would recommend referring to the Kubernetes docs for a detailed explanation on

kubectl apply -f deployment.yaml

Once applied, let's list Pods until the status is "Running".

kubectl get pods

In order to access the application, we have to expose it to the internet and create a service of type ClusterIP via the Kubernetes Service:

kubectl expose deployment/random-cat-facts

Open exposed, let's open a separate terminal window.
Because cluster IPs are only accesible within a cluster, we will create a proxy:

kubectl proxy

Once the proxy is loaded, in the original terminal window, we will ping the application to get a response:

curl -L localhost:8000/api/v1/namespaces/mrinasugosh/services/random-cat-facts/proxy

Oila! You have successfully deployed a NodeJS app to Kubernetes.

Thank you for following along this THINK Tuesday's Tutorial and be sure to look out for my next post, where I will continue sharing my Journey with IBM Cloud Services!!!

==== Follow me on Social Media(@mrinasugosh) ====
Dev.to: @mrinasugosh
Github: @mrinasugosh
Twitter: @mrinasugosh
LinkedIn: @mrinasugosh


Original Link: https://dev.to/ibmdeveloper/deploy-a-nodejs-app-to-kubernetes-4flg

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To