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:
- A namespace must be specified, and the user must be a member of the project to which the specified namespace is bound.
- It is required that both Pod resources.requests and resources.limits is specified.
- requests.memory and limits.memory must be set and must be equal.
- requests.cpu must be set. limits.cpu is optional (when not specified, pods will use all free CPU cores available. However, in some circumstances, it might be appropriate to use it).
- Enough resources must be available in the namespace quota, see Namespaces section.
An error message will be generated if any of the requirements above are not met.
Below is an example of a Pod yaml specification reserving 0.5 CPUs and 128MiB memory:
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
Show running
Logging
Read the standard output of the pod. The -f
option follows any new output.
Access shell
/ # 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
Then open http://localhost:8080 with your web browser.