1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| err = util.MysqlConnetion.Transaction(func(tx *gorm.DB) error { if err = tx.Create(&hosts).Error; err != nil { return err } if len(clusterList) > 0 && isBatch { if err = tx.Exec(buffer.String()).Error; err != nil { return err } } flagOperator := gjson.Get(util.GetConfig(), "monitor.enableOperator").Bool() if flagOperator { if _, ok := nodeIp[ip]; ok { addresses := []v1.EndpointAddress{} for ip = range nodeIp { addr := v1.EndpointAddress{} addr.IP = ip addresses = append(addresses, addr) } kubeletEpName := "kubelet" re, err := serviceDiscovery.CreateKubernetesEndpoints("monitoring", kubeletEpName, "kubernetes-kubelet", 10250, "https-metrics", v1.ProtocolTCP, addresses, true) if !re { if err != nil { util.Logger.Error(fmt.Sprintf("create Endpoints error is %v", err.Error())) } else { util.Logger.Infof(fmt.Sprintf("Endpoints %v 已存在,退出", kubeletEpName)) } } } } return nil }) return err
|