当前位置: 首页>>代码示例>>Golang>>正文


Golang ReplicationControllerModel.GetReplicationControllerList方法代码示例

本文整理汇总了Golang中models/k8sModel.ReplicationControllerModel.GetReplicationControllerList方法的典型用法代码示例。如果您正苦于以下问题:Golang ReplicationControllerModel.GetReplicationControllerList方法的具体用法?Golang ReplicationControllerModel.GetReplicationControllerList怎么用?Golang ReplicationControllerModel.GetReplicationControllerList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models/k8sModel.ReplicationControllerModel的用法示例。


在下文中一共展示了ReplicationControllerModel.GetReplicationControllerList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:51,代码来源:bubbleService.go

示例2: GetReplicationControllerCount

func (this *OverviewService) GetReplicationControllerCount() OverviewList {
	_replication_controllerModel := k8sModel.ReplicationControllerModel{}
	data := _replication_controllerModel.GetReplicationControllerList()

	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-v3" {
			continue
		}
		i = i + 1
	}
	_overview_list.Data.ReplicationController_count = i
	return _overview_list
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:19,代码来源:overviewService.go

示例3: GetReplicationControllerList

func (this *ReplicationControllerService) GetReplicationControllerList() ClusterList {
	_replication_controllerModel := k8sModel.ReplicationControllerModel{}
	data := _replication_controllerModel.GetReplicationControllerList()

	_podModel := k8sModel.PodModel{}
	_pod_data := _podModel.GetPodList()

	var _cluster_list ClusterList

	for _, data_items := range data.Items {
		metadata_name := data_items.Metadata.Name
		if metadata_name == "kube-dns-v3" {
			continue
		}

		var _cluster Cluster_format
		_cluster = this.RcByName(data_items)

		replicas := strconv.Itoa(data_items.Status.Replicas)
		_cluster.Status = replicas + "/" + replicas

		var herd_service herd_format.Data
		herd_service.Clusters = append(herd_service.Clusters, metadata_name)

		var scale_herd herdModel.ScaleHerdModel
		scale_herd_data := scale_herd.GetScale(herd_service)

		if len(scale_herd_data.Clusters) > 0 {
			_cluster.Auto_scale = scale_herd_data.Clusters[0].Enable_auto_scale
		}

		for _, _pod_data_item := range _pod_data.Items {
			_metadata_name_arr := strings.Split(_pod_data_item.Metadata.Name, "-")
			_metadata_name := strings.Join(_metadata_name_arr[:len(_metadata_name_arr)-1], "-")
			if metadata_name != _metadata_name {
				continue
			}
			var _pod pod
			_pod.Container_name = _pod_data_item.Metadata.Name
			_pod.Label = _pod_data_item.Metadata.Labels
			_pod.Public_ip = _pod_data_item.Status.PodIP
			_pod.Host_ip = _pod_data_item.Status.HostIP
			_pod.Status = _pod_data_item.Status.Phase

			var getHerd herdModel.GetHerdModel
			getHerd_data := getHerd.PostData(herd_service)

			for _, cluster := range getHerd_data.Clusters {
				if len(cluster.Containers) > 0 {
					for _, _container := range cluster.Containers {
						_cluster.Cpu += _container.Cpu
						_cluster.Mem += _container.Mem
						if _pod_data_item.Metadata.Name == _container.Container_name {
							_pod.Cpu = _container.Cpu
							_pod.Mem = _container.Mem
						}
					}
				}
			}
			var _image_file image_file
			_image_file.Name = _pod_data_item.Spec.Containers[0].Name
			_image_file.Image = _pod_data_item.Spec.Containers[0].Image
			_pod.Image_file = append(_pod.Image_file, _image_file)

			_cluster.Pods = append(_cluster.Pods, _pod)
		}

		_cluster_list.Status = "ok"
		_cluster_list.Data = append(_cluster_list.Data, _cluster)
	}

	return _cluster_list
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:73,代码来源:replication_controllerService.go

示例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
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:62,代码来源:overviewService.go


注:本文中的models/k8sModel.ReplicationControllerModel.GetReplicationControllerList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。