Skip to content

Commit 23fa7c0

Browse files
Fix selector for shutting down Pods (#7727) (#7731)
* 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]> Co-authored-by: Jintao Zhang <[email protected]>
1 parent 570d0d5 commit 23fa7c0

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
@@ -215,8 +215,21 @@ func (s *statusSync) runningAddresses() ([]string, error) {
215215
}
216216

217217
func (s *statusSync) isRunningMultiplePods() bool {
218+
219+
// As a standard, app.kubernetes.io are "reserved well-known" labels.
220+
// In our case, we add those labels as identifiers of the Ingress
221+
// deployment in this namespace, so we can select it as a set of Ingress instances.
222+
// As those labels are also generated as part of a HELM deployment, we can be "safe" they
223+
// cover 95% of the cases
224+
podLabel := make(map[string]string)
225+
for k, v := range k8s.IngressPodDetails.Labels {
226+
if k != "pod-template-hash" && k != "controller-revision-hash" && k != "pod-template-generation" {
227+
podLabel[k] = v
228+
}
229+
}
230+
218231
pods, err := s.Client.CoreV1().Pods(k8s.IngressPodDetails.Namespace).List(context.TODO(), metav1.ListOptions{
219-
LabelSelector: labels.SelectorFromSet(k8s.IngressPodDetails.Labels).String(),
232+
LabelSelector: labels.SelectorFromSet(podLabel).String(),
220233
})
221234
if err != nil {
222235
return false

0 commit comments

Comments
 (0)