Browse Source

Add compute node labeling

Change-Id: I64c9b42070e013e23949c5165b471af71036e411
changes/99/741699/3
okozachenko 2 years ago
parent
commit
3f16ae5ab8
  1. 25
      main.go

25
main.go

@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"os"
"strings"
"time"
"github.com/avast/retry-go"
@ -63,6 +64,10 @@ func main() {
"node.vexxhost.com/product": slug.Make(product.Name),
}
if !checkComputeNode() {
labels["node-role.openstack.org"] = "compute"
}
var node *v1.Node
err = retry.Do(
func() error {
@ -86,6 +91,26 @@ func main() {
}
}
// checkComputeNode checks if the current node is a compute node.
func checkComputeNode() bool {
compute_tag := []string{
"kvm",
"compute",
}
hostname, err := os.Hostname()
if err != nil {
log.Fatal(err.Error())
}
for _, sub := range compute_tag {
if strings.Contains(hostname, sub) {
return true
}
}
return false
}
func addLabelToNode(clientset *kubernetes.Clientset, node *v1.Node, key string, value string) error {
log.Info("Applying node label",
zap.String(key, value),

Loading…
Cancel
Save