Skip to main content

OverridePrimaryContainerName

Overrides the name of the primary container within a PodSpec. It iterates through the containers in the provided PodSpec and renames the container matching primaryContainerName to defaultContainerName.

def OverridePrimaryContainerName(
podSpec: *v1.PodSpec,
primaryContainerName: string,
defaultContainerName: string
) - > null

Overrides the name of the primary container within a given PodSpec. This is necessary to comply with naming conventions enforced by operators like PyTorch and TensorFlow, which expect specific container names.

Parameters

NameTypeDescription
podSpec*v1.PodSpecThe Kubernetes PodSpec object whose primary container name needs to be overridden. This object is modified in place.
primaryContainerNamestringThe current name of the primary container to be identified and renamed within the PodSpec.
defaultContainerNamestringThe new name to assign to the primary container, typically a name required by an operator (e.g., 'pytorch' or 'tensorflow').

Returns

TypeDescription
nullThis function does not return any value; it modifies the provided PodSpec in place.