Application deployment on Kubernetes

Deployment on Kubernetes using Kubectl.

        We can deploy containerized applications on that. To do that, we need to create Kubernetes Deployment. This deployment is responsible for the creating/ updating instance. Once deployment has been created, Kubernetes master will schedule the application instances that the deployment creates onto individual nodes in the cluster.

        Once instance are created, Kubernetes Deployment controller will monitor the application instances continuously. If the instance down or deleted, Deployment monitor will replaces it. This is called self healing, which will help to address machine failure or maintenance.

        In some other cloud technology, installation script will be used to start the applications. But, it will help on recovery from the system failure. In kubernetes will provide different approach by creating and running application instance on different nodes.

     We can create and manage deployment by using Kubernetes Command line Interface (Kubectl). Kubectl will use kubernetes API to connect with cluster.

Kubectl basics:

Downloading Kubectl:


Copying kubectl to path:
#chmod +x kubectl
#mv kubectl /usr/local/bin/

client credentials and CA cert:

gcloud compute copy-files node0:~/admin-key.pem .

gcloud compute copy-files node0:~/admin.pem .

gcloud compute copy-files node0:~/ca.pem .

Getting Kubernetes controller external IP:

EXTERNAL_IP=$(gcloud compute ssh node0 --command

  "curl -H 'Metadata-Flavor: Google'")

Creating cluster config:

kubectl config set-cluster workshop




Adding a admin credentials:

kubectl config set-credentials admin




Configuring the cluster context:

kubectl config set-context workshop



kubectl config use-context workshop

kubectl config view

Explore the kubectl CLI

Checking health status of the cluster components:

kubectl get cs

List pods:

kubectl get pods

List nodes:

kubectl get nodes

List services:

kubectl get services

"Kubectl run" command will create new deployment and have to provide deployment name,

application image location and port number.

#kubectl run kubernetes-bootcamp --port=8080

command to display the deployment:
> kubectl get deployments
kubernetes-bootcamp 1 1 1 1

In default case deployed applications are visible inside of kubernetes cluster, before exposing.
To view the application without exposing outside, can add route between our
terminal and kubernetes cluster using proxy.
>kubectl proxy
Started proxy enables access to the API. The applications running inside the pod.
Get the pod name and store it in the POD_NAME environment variable.

>export POD_NAME=$(kubectl get pods -o go-template –template ‘{{range .items}}{{}}{{“n”}}{{end}}’) echo Name of the Pod: $POD_NAME

command to see application output:

>curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/$POD_NAME/

Note: Will see more application related things in future post.

One thought on “Application deployment on Kubernetes”

Leave a Reply

Your email address will not be published. Required fields are marked *