github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cce/v3/nodepools/doc.go (about)

     1  /*
     2  Package node pools enables management and retrieval of node pools
     3  CCE service.
     4  
     5  Example to List node pools
     6  
     7      clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
     8  
     9  	listNodePools := nodepools.ListOpts{}
    10      allNodePools, err := nodepools.List(client,clusterID).ExtractNodePool(listNodePools)
    11  
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	for _, nodepool := range allNodePools {
    17  		fmt.Printf("%+v\n", nodepool)
    18  	}
    19  
    20  Example to Create a node pool
    21  
    22      createOpts := nodepools.CreateOpts{Kind:"NodePool",
    23  	   					   ApiVersion:"v3",
    24  	   					   Metadata:nodepools.CreateMetaData{Name:"nodepool_1"},
    25  	   					   Spec: nodepools.CreateSpec{
    26  								NodeTemplate: :nodes.Spec{Flavor:"s1.medium",
    27  	   					                   Az:"az1.dc1",
    28  	   					                   Login:nodes.LoginSpec{"myKeypair"},
    29  	   					                   Count:1,
    30  	   					                   RootVolume:nodes.VolumeSpec{Size:10,VolumeType:"SATA"},
    31  	   					                   DataVolumes:[]nodes.VolumeSpec{{Size:10,VolumeType:"SATA"}},
    32  								},
    33  								Autoscaling: nodepools.AutoscalingSpec{Enable:true,MinNodeCount:1,MaxNodeCount:3},
    34  								InitialNodeCount:1,
    35  							}
    36  		}
    37   	nodepool, err := nodepools.Create(client,clusterID,createOpts).Extract()
    38  	if err != nil {
    39  		panic(err)
    40  	}
    41  
    42  Example to Update a node pool
    43  
    44      clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    45  
    46  	nodeID := "3c8e5957-649f-477b-9e5b-f1f75b21c011"
    47  
    48  	updateOpts := nodepools.UpdateOpts{
    49  		Kind:       "NodePool",
    50  		ApiVersion: "v3",
    51  		Metadata: nodepools.UpdateMetaData{Name:"nodepool_1"},
    52  		Spec: nodepools.UpdateSpec{
    53  			InitialNodeCount: d.Get("initial_node_count").(int),
    54  			Autoscaling: nodepools.AutoscalingSpec{Enable:true,MinNodeCount:2,MaxNodeCount:9},
    55  		},
    56  	}
    57  	nodepool,err := nodepools.Update(client,clusterID,nodeID,updateOpts).Extract()
    58  	if err != nil {
    59  		panic(err)
    60  	}
    61  
    62  Example to Delete a node pool
    63  
    64  	clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    65  
    66  	nodePoolID := "3c8e5957-649f-477b-9e5b-f1f75b21c011"
    67  
    68  	err := nodepools.Delete(client,clusterID,nodePoolID).Extract()
    69  	if err != nil {
    70  		panic(err)
    71  	}
    72  */
    73  
    74  package nodepools