當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。