本文整理匯總了Golang中models/k8sModel.ServiceModel.GetServiceList方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceModel.GetServiceList方法的具體用法?Golang ServiceModel.GetServiceList怎麽用?Golang ServiceModel.GetServiceList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models/k8sModel.ServiceModel
的用法示例。
在下文中一共展示了ServiceModel.GetServiceList方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetServiceList
func (this *ServiceService) GetServiceList() ServiceList {
service_model := k8sModel.ServiceModel{}
data := service_model.GetServiceList()
var _service_list ServiceList
_service_list.Status = "ok"
for _, data_items := range data.Items {
metadata_name := data_items.Metadata.Name
if metadata_name == "kube-dns" || metadata_name == "kubernetes" {
continue
}
data := service_model.GetService(metadata_name)
_service := this.ServiceByName(metadata_name, data)
_service_list.Data = append(_service_list.Data, _service)
}
return _service_list
// response, _ := ioutil.ReadAll(_service_list)
// response, _ := ioutil.ReadAll(js)
// fmt.Println(data.Items[0].Status.Replicas)
// fmt.Println(data.ApiVersion)
}
示例2: GetRelate
func (this *BubbleService) GetRelate() bubble {
fmt.Println("[Get] Relate Service")
var _bubble bubble
var _item item
var service_model k8sModel.ServiceModel
service_data := service_model.GetServiceList()
// cluster_to_service := map[string]string{}
for _, service := range service_data.Items {
_item.Services = append(_item.Services, service.Metadata.Name)
}
var pod_model k8sModel.PodModel
pod_data := pod_model.GetPodList()
// Test(pod_data)
for _, pod := range pod_data.Items {
// Test(pod)
_item.Containers = append(_item.Containers, pod.Metadata.Name)
}
var rc_model k8sModel.ReplicationControllerModel
rc_data := rc_model.GetReplicationControllerList()
for _, rc := range rc_data.Items {
_item.Clusters = append(_item.Clusters, rc.Metadata.Name)
var _relate relate
_relate.Cluster_name = rc.Metadata.Name
for _, service := range service_data.Items {
// _item.Services = append(_item.Services, service.Metadata.Name)
if service.Spec.Selector != nil &&
service.Spec.Selector["name"] != "" &&
rc.Spec.Selector["name"] == service.Spec.Selector["name"] {
_relate.Service = append(_relate.Service, service.Metadata.Name)
}
}
for _, pod := range pod_data.Items {
if pod.Metadata.Labels != nil &&
pod.Metadata.Labels["name"] != "" &&
rc.Spec.Selector["name"] == pod.Metadata.Labels["name"] {
_relate.Container = append(_relate.Container, pod.Metadata.Name)
}
}
_bubble.Data.Relates = append(_bubble.Data.Relates, _relate)
}
_bubble.Data.Items = _item
_bubble.Status = "ok"
return _bubble
}
示例3: GetServiceCount
func (this *OverviewService) GetServiceCount() OverviewList {
service_model := k8sModel.ServiceModel{}
data := service_model.GetServiceList()
var _overview_list OverviewList
_overview_list.Status = "ok"
var i int = 0
for _, data_items := range data.Items {
metadata_name := data_items.Metadata.Name
if metadata_name == "kube-dns" || metadata_name == "kubernetes" {
continue
}
i = i + 1
}
_overview_list.Data.Service_count = i
return _overview_list
}
示例4: GetServiceInfo
//未完成
func (this *OverviewService) GetServiceInfo() OverviewList {
service_model := k8sModel.ServiceModel{}
data := service_model.GetServiceList()
rc_model := k8sModel.ReplicationControllerModel{}
rc_data := rc_model.GetReplicationControllerList()
machine_data := this.GetMachineInfo()
var total_mem float64 = 0
for _, _machine_data := range machine_data.Data.Machine_info {
total_mem += _machine_data.Mem
}
var _overview_list OverviewList
_overview_list.Status = "ok"
for _, data_items := range data.Items {
metadata_name := data_items.Metadata.Name
if metadata_name == "kube-dns" || metadata_name == "kubernetes" {
continue
}
var _service_info service_info
_service_info.Name = metadata_name
var herd_service herd_format.Data
herd_service.Services = append(herd_service.Services, metadata_name)
var getHerd herdModel.GetHerdModel
getHerd_data := getHerd.PostData(herd_service)
var cpu int = 0
var mem int = 0
for _, service_herd := range getHerd_data.Services {
if len(service_herd.Clusters) > 0 {
for _, cluster_herd := range service_herd.Clusters {
if len(cluster_herd.Containers) > 0 {
for _, container_herd := range cluster_herd.Containers {
cpu += container_herd.Cpu
mem += container_herd.Mem
}
}
}
}
}
_service_info.Cpu = cpu
_service_info.Mem = (float64(mem) / total_mem) * 100
for _, _rc_data_itme := range rc_data.Items {
if data_items.Spec.Selector != nil {
if data_items.Spec.Selector["name"] == _rc_data_itme.Spec.Selector["name"] {
_service_info.Container_total += _rc_data_itme.Spec.Replicas
_service_info.Container_run += _rc_data_itme.Spec.Replicas
}
}
}
_overview_list.Data.Service_info = append(_overview_list.Data.Service_info, _service_info)
}
return _overview_list
}