-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from qiangzii/master
Optimized for scenarios with unhealthy nodes and no backends
- Loading branch information
Showing
5 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package utils | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/klog" | ||
) | ||
|
||
// check if the node should be backend or not | ||
func NodeConditionCheck(node *corev1.Node) bool { | ||
if _, hasExcludeBalancerLabel := node.Labels[corev1.LabelNodeExcludeBalancers]; hasExcludeBalancerLabel { | ||
return false | ||
} | ||
|
||
// If we have no info, don't accept | ||
if len(node.Status.Conditions) == 0 { | ||
return false | ||
} | ||
for _, cond := range node.Status.Conditions { | ||
// We consider the node for load balancing only when its NodeReady condition status is ConditionTrue | ||
if cond.Type == corev1.NodeReady && cond.Status != corev1.ConditionTrue { | ||
klog.V(4).Infof("Ignoring node %v with %v condition status %v", node.Name, cond.Type, cond.Status) | ||
return false | ||
} | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters