-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the DisableDrain when running one a single node
Signed-off-by: Sebastian Sch <[email protected]>
- Loading branch information
Showing
4 changed files
with
62 additions
and
19 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 ( | ||
"context" | ||
|
||
"github.com/golang/glog" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func IsSingleNodeCluster(c client.Client) (bool, error) { | ||
nodeList := &corev1.NodeList{} | ||
err := c.List(context.TODO(), nodeList) | ||
if err != nil { | ||
glog.Errorf("IsSingleNodeCluster(): Failed to list nodes: %v", err) | ||
return false, err | ||
} | ||
|
||
if len(nodeList.Items) == 1 { | ||
glog.Infof("IsSingleNodeCluster(): one node found in the cluster") | ||
return true, nil | ||
} | ||
|
||
return false, nil | ||
} |