Fix selector for shutting down Pods (#7727)
* Fix selector for shutting down Pods * Add autogenerated labels for daemonset in exception Co-authored-by: Jintao Zhang <tao12345666333@163.com> Co-authored-by: Jintao Zhang <tao12345666333@163.com>
This commit is contained in:
parent
3224e7192f
commit
37ab9991e8
1 changed files with 14 additions and 1 deletions
|
@ -226,8 +226,21 @@ func (s *statusSync) runningAddresses() ([]apiv1.LoadBalancerIngress, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) isRunningMultiplePods() bool {
|
func (s *statusSync) isRunningMultiplePods() bool {
|
||||||
|
|
||||||
|
// As a standard, app.kubernetes.io are "reserved well-known" labels.
|
||||||
|
// In our case, we add those labels as identifiers of the Ingress
|
||||||
|
// deployment in this namespace, so we can select it as a set of Ingress instances.
|
||||||
|
// As those labels are also generated as part of a HELM deployment, we can be "safe" they
|
||||||
|
// cover 95% of the cases
|
||||||
|
podLabel := make(map[string]string)
|
||||||
|
for k, v := range k8s.IngressPodDetails.Labels {
|
||||||
|
if k != "pod-template-hash" && k != "controller-revision-hash" && k != "pod-template-generation" {
|
||||||
|
podLabel[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pods, err := s.Client.CoreV1().Pods(k8s.IngressPodDetails.Namespace).List(context.TODO(), metav1.ListOptions{
|
pods, err := s.Client.CoreV1().Pods(k8s.IngressPodDetails.Namespace).List(context.TODO(), metav1.ListOptions{
|
||||||
LabelSelector: labels.SelectorFromSet(k8s.IngressPodDetails.Labels).String(),
|
LabelSelector: labels.SelectorFromSet(podLabel).String(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue