PodSpec Customization
PodSpec Customization refers to the process of specifying and configuring the attributes and settings of a pod in Kubernetes through its PodSpec.
A PodSpec defines the characteristics of a pod, including the containers it contains, the volumes it uses, the networking settings, resource requests and limits, environment variables, and more.
PodSpec Customization in Zeet
You can provide custom YAML to be applied to the PodSpec in the Kubernetes tab of your project settings.
Example: Specifying Instance Type
An example use case would be to specify the particular instance type you want for your pods. To do so, you can apply the following patch:
- AWS
- GCP
nodeSelector:
aws.instance-type: m5.large
nodeSelector:
cloud.google.com/machine-family: c2
Note that changing your instance type might require us to provision a new node pool for your pod. This might result in some downtime for your service.
Example: Extract container information as envvar
It is sometimes useful for containers to have information about itself such as the podIP
,
nodeName
, or hostIP
. An example use case for pod-spec customization would be to extract this
information for your container as an environment variable. To do so, you can apply the following
patch:
containers:
- name: container
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
This example extracts the hostIP
as an environment variable. But you can follow this example to
expose any of the available fields via the Kubernetes Downward
API.
Entrypoint and Command in Docker and Kubernetes
Docker
- Entrypoint: The
ENTRYPOINT
in a Dockerfile specifies the default application to be run when a container is started. It's the primary command the Docker container is built to run. - Command: The
CMD
in a Dockerfile provides default arguments to theENTRYPOINT
. These arguments can be overridden when the container is run.
Kubernetes
- Command: In Kubernetes,
command
overrides the defaultENTRYPOINT
of the Docker container. - Args: In Kubernetes,
args
overrides the defaultCMD
specified in the Docker container.
In summary, in Docker, ENTRYPOINT
sets the executable to be called when the container runs, and
CMD
sets default arguments for the ENTRYPOINT
. In Kubernetes, command
and args
correspond to
Docker's ENTRYPOINT
and CMD
, respectively.
Example: Customizing Entrypoint in Zeet
In Zeet, to customize the PodSpec for the Docker entrypoint, you can use the
KubernetesCustomizationInput.podSpecPatch
as a workaround. You can inject your desired entrypoint
like this:
containers:
- name: container
command: ["/new-entrypoint.sh"]
args: ["arg1", "arg2"]
This YAML snippet sets a new entrypoint /new-entrypoint.sh
and arguments for the container in
your Kubernetes pod.