mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Add StatefulSet pod index as pod label (#119232)
* add statefulset pod index as pod label * change statefulset pod index label name * check 3 pods * change label variable name
This commit is contained in:
committed by
GitHub
parent
56f6030125
commit
7698fe7639
@@ -390,12 +390,16 @@ func initIdentity(set *apps.StatefulSet, pod *v1.Pod) {
|
||||
// updateIdentity updates pod's name, hostname, and subdomain, and StatefulSetPodNameLabel to conform to set's name
|
||||
// and headless service.
|
||||
func updateIdentity(set *apps.StatefulSet, pod *v1.Pod) {
|
||||
pod.Name = getPodName(set, getOrdinal(pod))
|
||||
ordinal := getOrdinal(pod)
|
||||
pod.Name = getPodName(set, ordinal)
|
||||
pod.Namespace = set.Namespace
|
||||
if pod.Labels == nil {
|
||||
pod.Labels = make(map[string]string)
|
||||
}
|
||||
pod.Labels[apps.StatefulSetPodNameLabel] = pod.Name
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.PodIndexLabel) {
|
||||
pod.Labels[apps.PodIndexLabel] = strconv.Itoa(ordinal)
|
||||
}
|
||||
}
|
||||
|
||||
// isRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady.
|
||||
|
||||
Reference in New Issue
Block a user