# Pod

## [About](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/)

The smallest deployable unit in Kubernetes.

* Represents **one or more containers** that share:
  * Storage volumes
  * Networking (they share the same Pod IP)
  * Lifecycle
* Usually, you run **one container per Pod** (multi-container Pods are rare and usually for sidecars like logging or monitoring agents).

#### Why Pods exist?

Containers by themselves don’t have Kubernetes features (no restart policy, scheduling, scaling).

Pods are the **Kubernetes wrapper around containers**, giving them a lifecycle inside the cluster.

{% hint style="warning" %}
**Not recommended** to manage Pods directly in production, because if a Pod dies, **it won’t come back automatically**.
{% endhint %}

## Commands

To apply and run a Pod configuration:

```bash
kubectl apply -f pod.yaml
```

To list all the Pods:

```bash
kubectl get pods
```

To get a description of a Pod:

```bash
kubectl describe pod <pod-name>
```

To delete a Pod:

```bash
kubectl delete pod <pod-name>
```

Check consumption of a Pod:

```bash
kubectl top pod <pod-name>
```

## Example

{% code title="pod.yaml" %}

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
    - name: myapp-container
      image: nginx:1.25
      ports:
        - containerPort: 80
      env:
        - name: NODE_ENV
          value: "production"
```

{% endcode %}
