52
52
52
=============================
-------------------------------------------------------------
Cluster
==> Master
apiserver ( runs on 6443 port number)
etcd
scheduler
controller
ie:
Master node
WN1
WN2
Xmachine
Kubectl
Cluster1
Cluster3
Cluster2
When we are connecting with these clusters using kubectl how will it authenticate?
There is something called certificate (similar to private key)
In certificate there are all the details, which port number it needs to send and
which port number
------------------------------------------------------------
Whenever is cluster is created there are 4 Namespaces, There are virtual rooms
The cluster is internally divided into 4 namespaces
We can create our own name spaces depending on the requirement
1)default
2)kube-node-lease
3)kube-public
4)kube-system
------------------------------------------------------------
Ultimately the purpose of K8S is to create pods
The contain is inside Pod and the image is inside the container
The container has to be given a name unlike docker where the names were
automatically assigned
"kubectl get pods" - gives you the details of the pods in the machine
In the above command the name space is not given so it will search in default and
if there are no pods then shows empty
"kube get pods -n kube-system" (-n will allow you to use a name space, can be used
to check any names space)
"kube get pods -n kube-system -o wide" (-o wide will give additional information
like pod ip and node in which pods are running)
"kubectl -run --help" (run is to create a pod and --help gives more details of how
run can be used in many ways)
"kubectl -run pd1 --image=nginx" (Creating a pod names pd1 using nginx image)
----------------------------------
DEPLOYMENT
----------
Deployment ensures that your pod is in running condition, If a pod dies then it
will automatically create another one
so deployment ensures that desired no of pods are in running condition
hierarchy
will create
Deployments=======>Replicaset==>Pods==>containers==>images
run command is only used for creating a pod, everything else will use create
command
Now 2 pods will be created inside the deployment and if one of the pod is deleted
or died then automatically another will be created
-----------------------------
Service
--------
To access POD application we need to create a service and 2nd thing it will do the
load balancing activity
Types of services
1)Cluster IP = If service type is cluster IP then pod app is only accessable only
within a cluster not from outside
2)Nodeport
3)Loadbalancer
The important thing is if you want to access PODS from within the cluster or
outside the cluster
"kubectl expose"
simillarly
---------------------
Labels
---------------------
Assume there are 2 deployments and 6 pods
dep1
dep2
PD1
.
.
.
PD6
how will kubernetes know hich pods belong to which deployments?
We use labels.
***Assume you have 4 replicas running and now you remove label of 1 pod then
immediately another pod will be created
Kuberneted will identify it's pods using labels
If the unlabeled pod is labeled again with the same label then according to
Kubernetes only 4 replicas are requires and this new one makes it 5 do it will
automatically delete 1 POD
------------------------------
Few more commands
------------------------------
-------------
Errors
-------------
1)Crahloopbackoff
Pd1=>
C1
=> Image
Here When container is creater then Entry point or CMD is executed and if there is
something wrong with it then we will get error
So check for errors in Images, K8s responsibility is only to orchestrate it
So to check further details like Image inside the pod and nodes use
Kubernetes always tries to run containers and if a container dies then another will
be created again and again
This is crash back loop error : Container is started then it dies and kubernetes
tried to create another one again
The problem is with the image and not kubernetes so check the dockerimage
This request goes into API server in master and stored in etcd
so this can be edited using