Skip to content

Pods

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes. They are groups of one or more containers.

Requirements

To deploy a Kubernetes Pod the following requirements must be met:

  1. A namespace must be specified, and the user must be a member of the project to which the specified namespace is bound.
  2. Both resource and request limits must be specified unless the default values have been set in field.cattle.io/containerDefaultResourceLimit. See the Namespaces section.
  3. The request limit (reservation) cannot be higher than the limit values.
  4. Enough resources must be available in the ICE Connect project quota.

An error message will be generated if any of the requirements above are not met.

Below is an example of a Pod YAML resource file:

testpod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: testpod
  labels:
    app: testapp
spec:
  containers:
    - name: bb
      image: busybox
      command: ["/bin/sh"]
      args: ["-c", "while true; do date && sleep 1; done"]
      resources:
        requests:
          memory: "128Mi"
          cpu: "500m"
        limits:
          memory: "128Mi"

Remember to set your default namespace before continuing.

Deploy pod

This is also used to install other Kubernetes objects using YAML files

kubectl create -f testpod.yaml

Show running

kubectl get pods
NAME      READY   STATUS    RESTARTS   AGE
testpod   1/1     Running   0          56s

Logging

Read the standard output of the pod. The -f option follows any new output.

kubectl logs testpod -f
Thu Jan  5 04:30:58 UTC 2023
Thu Jan  5 04:30:59 UTC 2023
Thu Jan  5 04:31:00 UTC 2023

Access shell

kubectl exec -it testpod -- /bin/sh
/ # uname -a
Linux testpod 4.15.0-193-generic #204-Ubuntu SMP Fri Aug 26 19:20:21 UTC 2022 x86_64 GNU/Linux

Port forward

To access a web server on the pod, running at port 80

kubectl port-forward testpod 8080:80

Then open http://localhost:8080 with your web browser.

Detailed pod specification

kubectl get pods -o=jsonpath='{.items[*].spec}' | jq | less

Delete pod

kubectl delete -f testpod.yaml