xxxxxxxxxx
A Kubernetes pod is a collection of one or more Linux® containers,
and is the smallest unit of a Kubernetes application.
Any given pod can be composed of multiple,
tightly coupled containers (an advanced use case) or
just a single container (a more common use case).
xxxxxxxxxx
# Get Pods in all namespaces
kubectl get po -A
# Get pods in default namespace
kubectl get po
xxxxxxxxxx
apiVersion: v1
kind: Pod
metadata:
name: nginxpod
labels:
name: nginxpod
spec:
containers:
- name: webservertest
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
protocol: TCP
- containerPort: 433
protocol: TCP
resources:
limits:
cpu: '2'
memory: 1024Mi
requests:
cpu: '1'
memory: 512Mi
livenessProbe:
httpGet:
path: /liveness
host: '0.0.0.0'
port: 8080
scheme: HTTP
httpHeaders:
- name: 'Accept'
value: 'application/json'
- name: 'Content-Type'
value: 'application/json'
periodSeconds: 5
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /readiness
host: '0.0.0.0'
port: 8080
scheme: HTTP
httpHeaders:
- name: 'Accept'
value: 'application/json'
- name: 'Content-Type'
value: 'application/json'
periodSeconds: 5
timeoutSeconds: 10
env:
- name: USER
value: JohnDoe
volumeMounts:
- name: nginx
mountPath: /etc/nginx
restartPolicy: Always
volumes:
- name: nginx
hostPath:
path: /usr/share/nginx
type: Directory
In Kubernetes, a pod is the basic unit of deployment. It is the smallest deployable unit in the Kubernetes object model.
A pod consists of one or more containers, such as Docker containers, and is used to host the containers that make up an application. The containers in a pod share the same network namespace and can communicate with each other using localhost. Pods are also co-located and co-scheduled, which means that they are scheduled to run on the same node and they share the same resources (e.g. CPU, memory).
Pods are intended to be ephemeral, meaning that they are expected to be terminated and replaced over time. This allows for easy scaling and rolling updates of applications.
Pods are created and managed by the Kubernetes control plane, which is responsible for ensuring that the desired number of replicas of a pod are running at any given time.
xxxxxxxxxx
apiVersion: batch/v1
kind: Job
metadata:
name: hello
spec:
template:
# This is the pod template
spec:
containers:
- name: hello
image: busybox:1.28
command: ['sh', '-c', 'echo "Hello, Kubernetes!" && sleep 3600']
restartPolicy: OnFailure
# The pod template ends here
xxxxxxxxxx
A Kubernetes pod is a collection of one or more Linux® containers,
and is the smallest unit of a Kubernetes application.
Any given pod can be composed of multiple,
tightly coupled containers (an advanced use case) or
just a single container (a more common use case).