GetPrimaryContainerName
Retrieves the name of the primary container for a given Kubernetes Pod. It first checks for annotations 'kubectl.kubernetes.io/default-container' or 'PrimaryContainerKey', then looks for a container matching the pod's name, and finally defaults to the first container if no other primary container is identified.
def GetPrimaryContainerName(
pod: *v1.Pod
) - > string
Retrieves the name of the primary container for a given Kubernetes Pod. This function determines the primary container by checking specific annotations first, then by matching the container name to the pod name, and finally defaults to the first container if no other primary container is identified.
Parameters
| Name | Type | Description |
|---|---|---|
| pod | *v1.Pod | The Kubernetes Pod object for which to determine the primary container name. |
Returns
| Type | Description |
|---|---|
string | The name of the primary container, or an empty string if no containers are found. |