package priorities import ( "os" client "github.com/influxdata/influxdb1-client/v2" "gopkg.in/yaml.v2" "k8s.io/klog" ) type scorerInput struct { metricName string metrics map[string]float64 } type Config struct { Server struct { Port string `yaml:"port"` Host string `yaml:"host"` } `yaml:"server"` Database struct { Type string `yaml:"type"` Name string `yaml:"name"` Username string `yaml:"username"` Password string `yaml:"password"` } `yaml:"database"` MonitoringSpecs struct { TimeInterval float32 `yaml:"interval"` } `yaml:"monitoring"` } var nodes = map[string]string{ "kube-01": "e77467ad-636e-4e7e-8bc9-53e46ae51da1", "kube-02": "e77467ad-636e-4e7e-8bc9-53e46ae51da1", "kube-03": "e77467ad-636e-4e7e-8bc9-53e46ae51da1", "kube-04": "e77467ad-636e-4e7e-8bc9-53e46ae51da1", "kube-05": "c4766d29-4dc1-11ea-9d98-0242ac110002", "kube-06": "c4766d29-4dc1-11ea-9d98-0242ac110002", "kube-07": "c4766d29-4dc1-11ea-9d98-0242ac110002", "kube-08": "c4766d29-4dc1-11ea-9d98-0242ac110002", } var sockets = map[string]int{ "kube-01": 1, "kube-02": 0, "kube-03": 0, "kube-04": 1, "kube-05": 0, "kube-06": 1, "kube-07": 0, "kube-08": 1, } var cores = map[string][]int{ "kube-01": []int{20, 21, 22, 23}, "kube-02": []int{2, 3, 4, 5, 6, 7, 8, 9}, "kube-03": []int{40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55}, "kube-04": []int{24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75}, "kube-05": []int{0, 1, 2, 3}, "kube-06": []int{12, 13, 14, 15, 16, 17, 18, 19}, "kube-07": []int{4, 5, 6, 7, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31}, "kube-08": []int{20, 21, 22, 23, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}, } func readFile(cfg *Config, file string) error { f, err := os.Open(file) if err != nil { klog.Infof("Config file for scheduler not found. Error: %v", err) return err } defer f.Close() decoder := yaml.NewDecoder(f) err = decoder.Decode(&cfg) if err != nil { klog.Infof("Unable to decode the config file. Error: %v", err) return err } return nil } func connectToInfluxDB(cfg Config) (client.Client, error) { c, err := client.NewHTTPClient(client.HTTPConfig{ Addr: "http://" + cfg.Server.Host + ":" + cfg.Server.Port + "", }) if err != nil { klog.Infof("Error while connecting to InfluxDB: %v ", err.Error()) return nil, err } klog.Infof("Connected Successfully to InfluxDB") return c, nil }