當前位置: 首頁>>代碼示例>>Golang>>正文


Golang PetSet.Labels方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/apis/apps.PetSet.Labels方法的典型用法代碼示例。如果您正苦於以下問題:Golang PetSet.Labels方法的具體用法?Golang PetSet.Labels怎麽用?Golang PetSet.Labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/apis/apps.PetSet的用法示例。


在下文中一共展示了PetSet.Labels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CreatePetSet

// PetSet - available only in kubernetes v1.3+
// big advantage: it allow create persistentVolume template
// this template can create persistent volumeClaim for each POD automatically
//
// create petSet for couchdb cluster
// init all necessary struct for petSet and then via kube client creates it
// @ param cluster - struct CouchdbCluster - required:
// @return extensions.Deployment - created kube deployment
// @return error - errors that occur during creation
//
func (cluster *CouchdbCluster) CreatePetSet() (*apps.PetSet, error) {
	/*
		PET SET, included in kube 1.3+
		http://kubernetes-v1-3.github.io/docs/user-guide/petset/
		// TESTING - ALPHA
	*/
	// pod template with volumes
	podTemplate := *cluster.CouchdbPodTemplate(true, CLUSTER_PREFIX+cluster.Tag)
	// pet set spec label selector
	lSelector := unversioned.LabelSelector{MatchLabels: cluster.Labels}

	// pvc claim
	pvc := api.PersistentVolumeClaim{}
	pvc.Name = CLUSTER_PREFIX + cluster.Tag
	pvc.Annotations = make(map[string]string)
	pvc.Annotations["volume.alpha.kubernetes.io/storage-class"] = "anything"

	// resource list for pvc claim template
	rsList := make(api.ResourceList)
	// SIZE
	rsList[api.ResourceStorage] = *(resource.NewQuantity(5*1024*1024*1024, resource.BinarySI))
	// pvc SPEC
	pvcSpec := api.PersistentVolumeClaimSpec{}
	pvcSpec.Resources.Requests = api.ResourceList(rsList)

	pvc.Spec = pvcSpec
	// pet set specs
	petSetSPec := apps.PetSetSpec{Replicas: int(cluster.Replicas), Template: podTemplate,
		Selector: &lSelector, VolumeClaimTemplates: []api.PersistentVolumeClaim{pvc}}

	// pet set
	petSet := apps.PetSet{Spec: petSetSPec}
	petSet.Name = CLUSTER_PREFIX + cluster.Tag
	petSet.Labels = cluster.Labels

	// get a new kube extensions client
	c, err := KubeClientApps(KUBE_API)
	// check for errors
	if err != nil {
		ErrorLog("kube_control: createPetSet: Cannot connect to Kubernetes api ")
		ErrorLog(err)
		return nil, err
	} else {
		// create deployment
		return c.PetSets(cluster.Namespace).Create(&petSet)
	}
}
開發者ID:calvix,項目名稱:kanto,代碼行數:57,代碼來源:spawner_petset.go


注:本文中的k8s/io/kubernetes/pkg/apis/apps.PetSet.Labels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。