Kubernetes Objects
- Are persistent entities of K8s system
- Every object has
- Object Spec:
- Object Status:
Basic Workflow
- Write an Specification in YAML format and save in a file
- To Create/modify
kubectl apply -f <pathofyaml>
- To delete
kubectl delete -f <pathofyml>
- To get status
kubectl get <object-kind>
Pod
-
Atomic unit of creation in k8s
-
Pod contains container(s)
-
Each pod gets an ip address
-
When we have more than one container in the pod all the containers inside pod can be accessed over pod ip. For inter container communication with in pod the containers have to use localhost
-
In k8s scaling is number of pods will be increased not containers
-
When you multi container pod
- one container would be main car container
- others would be side car containers
-
Lets try to create Pod Specification. Refer to pod specification from here
-
Refer to
- metadata
- spec
- kind
- apiVersion
-
From the reference try to fill the values in a yaml file (learning)
---
apiVersion: v1
kind: Pod
metadata:
name: learning
spec:
containers:
- image: jenkins:1.609.2
name: jenkins
- Login into kubeadm master and execute
kubectl apply -f learning.yml
- wath for status with changes
kubectl get pods -w
- Get full info of pods
kubectl get pods -o wide
- Delete the pods
kubectl delete -f learning.yml