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


Golang ReplicationControllerModel.CreateReplicationController方法代码示例

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


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

示例1: CreateBoth

func (this *ServiceService) CreateBoth(data []byte) Service {
	var data_format struct {
		Service_name    string            `json:"service_name"`
		Port            string            `json:"port"`
		Container_count string            `json:"container_count"`
		Cpu             string            `json:"cpu"`
		Image           string            `json:"image"`
		Label           map[string]string `json:"label"`
	}
	json.Unmarshal(data, &data_format)

	var _k8s_service k8s_format.Service
	_k8s_service.Kind = "Service"
	_k8s_service.Metadata.Name = data_format.Service_name
	_k8s_service.Metadata.Labels = data_format.Label
	_k8s_service.Metadata.Labels["name"] = data_format.Service_name
	_k8s_service.Spec.Type = "NodePort"
	_k8s_service.Spec.Selector = map[string]string{"name": data_format.Service_name}

	var _k8s_service_ports k8s_format.ServicePort
	_k8s_service_ports.Port, _ = strconv.Atoi(data_format.Port)
	_k8s_service_ports.TargetPort, _ = strconv.Atoi(data_format.Port)
	_k8s_service_ports.Protocol = "TCP"
	_k8s_service.Spec.Ports = append(_k8s_service.Spec.Ports, _k8s_service_ports)

	var k8s_rc k8s_format.ReplicationController
	k8s_rc.Kind = "ReplicationController"
	k8s_rc.Metadata.Name = data_format.Service_name
	k8s_rc.Metadata.Labels = data_format.Label
	k8s_rc.Metadata.Labels["name"] = data_format.Service_name
	k8s_rc.Spec.Replicas, _ = strconv.Atoi(data_format.Container_count)
	k8s_rc.Spec.Selector = map[string]string{"name": data_format.Service_name}
	k8s_rc.Spec.Template.Metadata.Labels = map[string]string{"name": data_format.Service_name}

	var k8s_rc_container_port k8s_format.ContainerPort
	k8s_rc_container_port.ContainerPort, _ = strconv.Atoi(data_format.Port)

	var k8s_rc_container k8s_format.Container
	k8s_rc_container.Name = data_format.Service_name
	k8s_rc_container.Image = data_format.Image
	k8s_rc_container.Ports = append(k8s_rc_container.Ports, k8s_rc_container_port)
	k8s_rc.Spec.Template.Spec.Containers = append(k8s_rc.Spec.Template.Spec.Containers, k8s_rc_container)

	var rc_model k8sModel.ReplicationControllerModel
	var service_model k8sModel.ServiceModel

	rc_model.CreateReplicationController(k8s_rc)
	service_model.CreateService(_k8s_service)
	// _rc_service := data_format

	var service Service
	service.Status = "ok"
	// service.Data = ""
	return service
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:55,代码来源:serviceService.go

示例2: CreateReplicationController

func (this *ReplicationControllerService) CreateReplicationController(data []byte) Cluster {
	type rc_format struct {
		Cluster_name    string            `json:"cluster_name"`
		Port            string            `json:"port"`
		Container_count string            `json:"container_count"`
		Cpu             string            `json:"cpu"`
		Image           string            `json:"image"`
		Label           map[string]string `json:"label"`
	}
	var _rc_format rc_format
	json.Unmarshal(data, &_rc_format)

	var k8s_rc k8s_format.ReplicationController
	var k8s_rc_container k8s_format.Container
	var k8s_rc_container_port k8s_format.ContainerPort

	k8s_rc.Kind = "ReplicationController"
	k8s_rc.Metadata.Name = _rc_format.Cluster_name
	k8s_rc.Metadata.Labels = _rc_format.Label
	k8s_rc.Metadata.Labels["name"] = _rc_format.Cluster_name
	k8s_rc.Spec.Replicas, _ = strconv.Atoi(_rc_format.Container_count)
	k8s_rc.Spec.Selector = map[string]string{"name": _rc_format.Cluster_name}
	k8s_rc.Spec.Template.Metadata.Labels = map[string]string{"name": _rc_format.Cluster_name}
	k8s_rc_container.Name = _rc_format.Cluster_name
	k8s_rc_container.Image = _rc_format.Image
	k8s_rc_container_port.ContainerPort, _ = strconv.Atoi(_rc_format.Port)
	k8s_rc_container.Ports = append(k8s_rc_container.Ports, k8s_rc_container_port)
	k8s_rc.Spec.Template.Spec.Containers = append(k8s_rc.Spec.Template.Spec.Containers, k8s_rc_container)

	_replication_controllerModel := k8sModel.ReplicationControllerModel{}
	_replication_controllerModel.CreateReplicationController(k8s_rc)

	var _cluster Cluster
	_cluster.Status = "ok"

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


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