Deployment of pod using nginx image on AWS EC2 instance along with Namespace and pod life cycle management: -

Deployment of pod using nginx image on AWS EC2 instance along with Namespace and pod life cycle management: -

Pre-requisite:-

1) AWS EC2 Instance creation

2) Docker & Kubernetes installation in EC2 instance

What is Namespace in K8s:-

Namespace in Kubernetes is different as compared to the docker namespace, Users interacting with one namespace do not see the content in another namespace. it is a Project we can say.

Kubernetes starts with three initial namespaces: default:-The default namespace for objects with no other namespace. kube-system The namespace for objects created by the Kubernetes system. kube-public This namespace is created automatically and is readable by all users, If we create any new pod without giving a namespace then it will go into the default namespace.

Creation of new namespace "sachin"

For every command which we hit in Kubernetes Node, it will go to API via Kubelet for worker nodes for authentication and authorization check and if passes this test then execute the command.

Uses of Namespace:-

1) Team-based separation

2) User access control based on the project

3) Resource allocation

Deployment of Pod using the nginx image -

one pod named test is created with nginx image which is being pulled from the Docker hub, We have not given on which node it should be deployed, at the backend, it is the work of kube-scheduler to check for resource alignment/allocation, test pod is deployed on worker1

Run the pod in Kubernetes and it will go inside the test pod

root@K8s-master:~# kubectl describe pod test

To check the logs of the nginx application in the test pod:

We can deploy the pod in the specific namespace as well as per the command highlighted below

Deletion of test & demo pod

Deletion of namespace named sachin