Skip to content

Commit db6ece3

Browse files
rikatztao12345666333
authored andcommitted
Fix selector for shutting down Pods (kubernetes#7727)
* Fix selector for shutting down Pods * Add autogenerated labels for daemonset in exception Co-authored-by: Jintao Zhang <[email protected]> Co-authored-by: Jintao Zhang <[email protected]>
1 parent 0255cf2 commit db6ece3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

internal/ingress/status/status.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,21 @@ func (s *statusSync) runningAddresses() ([]apiv1.LoadBalancerIngress, error) {
226226
}
227227

228228
func (s *statusSync) isRunningMultiplePods() bool {
229+
230+
// As a standard, app.kubernetes.io are "reserved well-known" labels.
231+
// In our case, we add those labels as identifiers of the Ingress
232+
// deployment in this namespace, so we can select it as a set of Ingress instances.
233+
// As those labels are also generated as part of a HELM deployment, we can be "safe" they
234+
// cover 95% of the cases
235+
podLabel := make(map[string]string)
236+
for k, v := range k8s.IngressPodDetails.Labels {
237+
if k != "pod-template-hash" && k != "controller-revision-hash" && k != "pod-template-generation" {
238+
podLabel[k] = v
239+
}
240+
}
241+
229242
pods, err := s.Client.CoreV1().Pods(k8s.IngressPodDetails.Namespace).List(context.TODO(), metav1.ListOptions{
230-
LabelSelector: labels.SelectorFromSet(k8s.IngressPodDetails.Labels).String(),
243+
LabelSelector: labels.SelectorFromSet(podLabel).String(),
231244
})
232245
if err != nil {
233246
return false

0 commit comments

Comments
 (0)