Files
provider-kairos/internal/role/common.go
mudler 0517b1e766 Add kubeVIP support with p2p hybrid mode
In this way, the p2p API will just run the co-ordination to setup KubeVIP automatically
to the new cluster.

Signed-off-by: Ettore Di Giacinto <mudler@mocaccino.org>
2022-12-05 11:53:33 +01:00

35 lines
740 B
Go

package role
import (
"io/ioutil"
"os"
service "github.com/mudler/edgevpn/api/client/service"
)
type Role func(*service.RoleConfig) error
func SentinelExist() bool {
if _, err := os.Stat("/usr/local/.kairos/deployed"); err == nil {
return true
}
return false
}
func CreateSentinel() error {
return ioutil.WriteFile("/usr/local/.kairos/deployed", []byte{}, os.ModePerm)
}
func getRoles(client *service.Client, nodes []string) ([]string, map[string]string) {
unassignedNodes := []string{}
currentRoles := map[string]string{}
for _, a := range nodes {
role, _ := client.Get("role", a)
currentRoles[a] = role
if role == "" {
unassignedNodes = append(unassignedNodes, a)
}
}
return unassignedNodes, currentRoles
}