Steps To Create Your First POD In Google Kubernetes

Steps to create your First POD in Google Kubernetes

In this blog, we will show you the steps to create your first POD in Google Kubernetes Environment.

REQUIREMENTS

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

INFRASTRUCTURE OVERVIEW

WORKING WITH PODS

  • The smallest unit of scheduling in the kubernetes world is POD.
  • POD’s can contain one or more containers.
  • We deploy a POD in a cluster using the manifest file.
  • We provide the manifest file to the API server. It will schedule to deploy in a node. Based on the manifest file, the POD will have one (or) more containers.
  • irrespective how many containers inside a POD, the POD will get only a single IP. It’s like one IP to one POD relationship.
  • Every container inside a POD shares single Network Namespace.
  • All the containers inside a POD shares same CGROUP Limits, Volumes, Network and IPC namespaces.

INTER-POD COMMUNICATION

  • All the POD addresses are fully routable on the POD Network.
  • Every POD gets own IP and it’s routable to that Network.
  • POD’s can communicate each other without any port mapping.

INTRA-POD COMMUNICATION

  • Inside the POD, the multiple containers will communicate through a shared local network interface.
  • The containers will be available outside the POD by exposing them through ports.
  • Two containers cannot use the same port.
  • Pods will either run as fully functional (or) its down completely.

POD LIFECYCLE

  • First, we will create a manifest file (YAML or JSON) about POD and container information.
  • Provide the manifest file to the API server and it will get scheduled to a node.
  • Once its schedule, it goes into Pending state. During this time it will be downloading the images and files.
  • It will be in pending state till all the containers are up and running.
  • After the containers are up and running, It changes to running state.
  • Once it’s completed its job, its change the status to succeed.
  • If it’s holding on pending state (or) Crashed for a long time, then it will be changed to a failed state.
  • We cannot bring back the death POD. Need to replace them with a new one.

CREATING A MANIFEST FILE

  • Log in to the Kubernetes master server through putty.
Steps to create your First POD in Google Kubernetes
  • Create a new manifest file using vi editor.

Note: We are using YAML type to create the manifest files

Steps to create your First POD in Google Kubernetes
  • We are using the ngnix image for this demo purpose. Add the below code in the YAML file.

apiVersion: v1
kind: Pod
metadata:
   name: hello-pod
   labels:
      zone: pod
      version: v1
spec:
   containers:
      - name: hello-ctr
        image: nginx:latest

Steps to create your First POD in Google Kubernetes
  • Save and close the file.

Note: Make sure that manifest will be on right YAML format. Or else, it will show the error during POD deployment.

DEPLOYING THE POD

  • From the shell, use the below command to create a pod.

kubectl create -f pod.yml

Steps to create your First POD in Google Kubernetes
  • A new POD will be created in few seconds.
Steps to create your First POD in Google Kubernetes
  • We can get the pods status using the below command.

kubectl get pods

Steps to create your First POD in Google Kubernetes
  • You can also get the POD events information through describe command.

kubectl describe pods <pod name>

Steps to create your First POD in Google Kubernetes
Steps to create your First POD in Google Kubernetes
  • You can find the POD IP using wide option.

kubectl get pods -o wide

  • We can able to browse the container using the POD IP inside the cluster.

curl -v http://<Pod IP>

Steps to create your First POD in Google Kubernetes

EXTERNAL LINKS

https://www.mirantis.com/blog/introduction-to-yaml-creating-a-kubernetes-deployment/ – YAML Introduction.

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn about POD creation on Google Kubernetes Environment.

Loges

Leave a Reply

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