I need each pod created by a StatefulSet to have a specific Linux host ID, similar to the hostid value configured on a virtual machine. Is there a Kubernetes-native way to assign or control that value for StatefulSet pods without manually hardcoding it in the workload definition?
1 Answer
Kubernetes does not provide a StatefulSet field for assigning Linux host IDs. A pod normally gets its own container filesystem, while the underlying node provides the kernel and other host-level behavior. If the application only needs a stable unique identifier, use the StatefulSet pod hostname or ordinal and derive an ID from it. If it specifically reads /etc/hostid, you could create that file with an init container or mount a per-pod configuration, but make sure every replica receives a unique and persistent value rather than relying on the node's host ID.

I mean the numeric hostid value used inside a Linux VM. I was wondering whether Kubernetes can assign a different value automatically to each pod created by the StatefulSet, without listing every value explicitly.