Steps to create your First POD in Google KubernetesIn this blog, we will show you the steps to create your first POD in Google Kubernetes Environment.
- 2 Node Cluster ( 1 Master VM with 2 Nodes)
- Kubernetes Components
- We have already installed and configured the 2 Node cluster in our demo environment.
- Please check the URL https://www.assistanz.com/steps-to-install-kubernetes-cluster-manually-using-centos-7/ for more information.
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.
- 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.
- 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.
- 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.
- Create a new manifest file using vi editor.
Note: We are using YAML type to create the manifest files
- We are using the ngnix image for this demo purpose. Add the below code in the YAML file.
- name: hello-ctr
- 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
- A new POD will be created in few seconds.
- We can get the pods status using the below command.
kubectl get pods
- You can also get the POD events information through describe command.
kubectl describe pods
- 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>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.