KodeCloud Kubernetes Pods
Links: 111 KodeCloud Index
Basics/Pods¶
- Nodes were also known as minions in the past.
- Scheduler - Placement. Where to put containers in a node.
- Controller - Brain. Responds when something goes down.
- Get k8s version:
k version --short
kubeadm
is used to bootstrap and manage production grade k8s cluster.- Pod is the smallest component you can create in k8s.
Multiple containers in a pod can communicate with each other directly by referring to each other as localhost since they share the same network space.
They can also easily share the same storage space.
- Command for getting resources:
k get <resource-name>
k get pods
- Creating and running a pod:
k run <pod-name> --image=<image>
- Describing things:
k describe <resource-type>/<resource-name>
Using k describe pod/<pod-name>
can give a lot of additional information about the pod
- Node to which it belongs,
- Image name
- Events that occurred in the pod.
- We can see the different containers that are present in the pod and their states.
- Pod IP
- Any configuration file must have these properties:
apiVersion
kind
metadata
spec
Difference between create
and apply
There is a subtle difference between kubectl create
and kubectl apply
commands.
- The kubectl create
command creates a new resource. So, if the command is run again it will throw an error as resource names should be unique in a namespace.
- The kubectl apply
command applies the configuration to a resource. If the resource is not there then it will be created.
- The kubectl apply
command can be run the second time even if the configuration hasn't changed.
- In the kubectl create
, we specify a certain action, in this case create
and so it is imperative. In the kubectl apply
command we specify the target state of the system and don't specify a certain action and so declarative. We let the system decide what action to take. If the resource is not there it will create it, if the resource is there then it will apply the configuration to the existing resource.
- From an execution perspective, there is no difference when a resource is created for the first time between kubectl create
and kubectl apply
.
- Creating a pod using a YAML file
Use only spaces and NOT TABS.
Last updated: 2023-05-03