Let’s understand the file first. The file contains the following:

  • apiVersion: This defines the resource version we are trying to define. In this case, as it is a pod and a generally available (GA) resource, the version we will use is v1.
  • kind: This defines the kind of resource we want to create – a pod.
  • metadata: The metadata section defines the name and labels surrounding this resource. It helps in uniquely identifying the resource and grouping multiple resources using labels.
  • spec: This is the main section where we define the actual specifications for the resource.
  • spec.containers: This section defines one or more containers that form the pod.
  • spec.containers.name: This is the container’s name, which isnginx-container in this case.
  • spec.containers.image: This is the container image, which isnginx in this case.
  • spec.containers.imagePullPolicy: This can beAlways, IfNotPresent, or Never. If set to Always, Kubernetes always pulls the image from the registry. If set to IfNotPresent, Kubernetes pulls the image only if the image is not found on the node where the pod is scheduled. If set to Never, Kubernetes will never attempt to pull images from the registry and will rely completely on local images.
  • spec.containers.resources: This defines the resource requests and limits.
  • spec.containers.resources.limit: This defines the resource limits. This is the maximum amount of resources that the pod can allocate, and if the resource consumption increases beyond it, the pod is evicted.
  • spec.containers.resources.limit.memory: This defines the memory limit.
  • spec.containers.resources.limit.cpu: This defines the CPU limit.
  • spec.containers.resources.requests: This defines the resource requests. This is the minimum amount of resources the pod would request during scheduling and will not be scheduled on a node that cannot allocate it.
  • spec.containers.resources.requests.memory: This defines the amount of memory to be requested.
  • spec.containers.resources.requests.cpu: This defines the number of CPU cores to be requested.
  • spec.restartPolicy: This defines the restart policy of containers –Always, OnFailure, or Never. This is similar to the restart policy on Docker.

There are other settings on the pod manifest, but we will explore these as and when we progress.

Leave a Reply

Your email address will not be published. Required fields are marked *