// NewNodeGroup builds a theoretical node group based on the node definition provided. The node group is not automatically
// created on the cloud provider side. The node group is not returned by NodeGroups() until it is created.
NewNodeGroup builds a theoretical node group based on the node definition provided. The node group is not automatically
created on the cloud provider side. The node group is not returned by NodeGroups() until it is created.
// NewNodeGroup builds a theoretical node group based on the node definition provided . The node group is not automatically // created on the cloud provider side . The node group is not returned by NodeGroups () until it is created .
func (gke *GkeCloudProvider) NewNodeGroup(machineType string, labels map[string]string, systemLabels map[string]string,
	taints []apiv1.Taint, extraResources map[string]resource.Quantity) (cloudprovider.NodeGroup, error) {
	nodePoolName := fmt.Sprintf("%s-%s-%d", nodeAutoprovisioningPrefix, machineType, time.Now().Unix())
	zone, found := systemLabels[kubeletapis.LabelZoneFailureDomain]
	if !found {
		return nil, cloudprovider.ErrIllegalConfiguration
	}
	if gpuRequest, found := extraResources[gpu.ResourceNvidiaGPU]; found {
		gpuType, found := systemLabels[gpu.GPULabel]
		if !found {
			return nil, cloudprovider.ErrIllegalConfiguration
		}
		gpuCount, err := getNormalizedGpuCount(gpuRequest.Value())
		if err != nil {
			return nil, err
		}
		extraResources[gpu.ResourceNvidiaGPU] = *resource.NewQuantity(gpuCount, resource.DecimalSI)
		err = validateGpuConfig(gpuType, gpuCount, zone, machineType)
		if err != nil {
			return nil, err
		}
		nodePoolName = fmt.Sprintf("%s-%s-gpu-%d", nodeAutoprovisioningPrefix, machineType, time.Now().Unix())
		labels[gpu.GPULabel] = gpuType
		taint := apiv1.Taint{
			Effect: apiv1.TaintEffectNoSchedule,
			Key:    gpu.ResourceNvidiaGPU,
			Value:  "present",
		}
		taints = append(taints, taint)
	}
	mig := &GkeMig{
		gceRef: gce.GceRef{
			Project: gke.gkeManager.GetProjectId(),
			Zone:    zone,
			Name:    nodePoolName + "-temporary-mig",
		},
		gkeManager:      gke.gkeManager,
		autoprovisioned: true,
		exist:           false,
		nodePoolName:    nodePoolName,
		minSize:         minAutoprovisionedSize,
		maxSize:         maxAutoprovisionedSize,
		spec: &MigSpec{
			MachineType:    machineType,
			Labels:         labels,
			Taints:         taints,
			ExtraResources: extraResources,
		},
	}
	if _, err := gke.gkeManager.GetMigTemplateNode(mig); err != nil {
		return nil, fmt.Errorf("Failed to build node from spec: %v", err)
	}
	return mig, nil
}
func ( gke * GkeCloudProvider ) NewNodeGroup ( machineType string , labels map [ string ] string , systemLabels map [ string ] string , taints [ ] apiv1 . Taint , extraResources map [ string ] resource . Quantity ) ( cloudprovider . NodeGroup , error ) { nodePoolName := fmt . Sprintf ( " " , nodeAutoprovisioningPrefix , machineType , time . Now ( ) . Unix ( ) ) zone , found := systemLabels [ kubeletapis . LabelZoneFailureDomain ] if ! found { return nil , cloudprovider . ErrIllegalConfiguration } if gpuRequest , found := extraResources [ gpu . ResourceNvidiaGPU ] ; found { gpuType , found := systemLabels [ gpu . GPULabel ] if ! found { return nil , cloudprovider . ErrIllegalConfiguration } gpuCount , err := getNormalizedGpuCount ( gpuRequest . Value ( ) ) if err != nil { return nil , err } extraResources [ gpu . ResourceNvidiaGPU ] = * resource . NewQuantity ( gpuCount , resource . DecimalSI ) err = validateGpuConfig ( gpuType , gpuCount , zone , machineType ) if err != nil { return nil , err } nodePoolName = fmt . Sprintf ( " " , nodeAutoprovisioningPrefix , machineType , time . Now ( ) . Unix ( ) ) labels [ gpu . GPULabel ] = gpuType taint := apiv1 . Taint { Effect : apiv1 . TaintEffectNoSchedule , Key : gpu . ResourceNvidiaGPU , Value : " " , } taints = append ( taints , taint ) } mig := & GkeMig { gceRef : gce . GceRef { Project : gke . gkeManager . GetProjectId ( ) , Zone : zone , Name : nodePoolName + " " , } , gkeManager : gke . gkeManager , autoprovisioned : true , exist : false , nodePoolName : nodePoolName , minSize : minAutoprovisionedSize , maxSize : maxAutoprovisionedSize , spec : & MigSpec { MachineType : machineType , Labels : labels , Taints : taints , ExtraResources : extraResources , } , } if _ , err := gke . gkeManager . GetMigTemplateNode ( mig ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } return mig , nil }
NewNodeGroup builds a theoretical node group based on the node definition provided.
NewNodeGroup builds a theoretical node group based on the node definition provided .
// Try to build a node from autoprovisioning spec. We don't need one right now, // but if it fails later, we'd end up with a node group we can't scale anyway, // so there's no point creating it.