Node management
Updated at:2025-10-27
Create node
Plain Text
1func CreateInstance() {
2 // User’s Access Key ID and Secret Access Key
3 AK, SK := "", ""
4 // User-specified endpoint
5 ENDPOINT := ""
6 // Initialize a CCEClient
7 ccev2Client, err := v2.NewClient(AK, SK, ENDPOINT)
8 if err != nil {
9 panic(err)
10 }
11 resp, err := ccev2Client.CreateInstances(&v2.CreateInstancesArgs{
12 ClusterID: "",
13 Instances: []*v2.InstanceSet{
14 {
15 InstanceSpec: types.InstanceSpec{
16 MachineType: types.MachineTypeBCC,
17 InstanceType: api.InstanceType34,
18 InstanceName: "",
19 VPCConfig: types.VPCConfig{
20 VPCSubnetID: "sbn-xxx",
21 SecurityGroup: types.SecurityGroup{
22 EnableCCERequiredSecurityGroup: true,
23 EnableCCEOptionalSecurityGroup: false,
24 },
25 },
26 InstanceResource: types.InstanceResource{
27 CPU: 2,
28 MEM: 8,
29 RootDiskType: api.StorageTypeHP1,
30 RootDiskSize: 100,
31 LocalDiskSize: 0,
32 CDSList: []types.CDSConfig{},
33 MachineSpec: "bcc.g5.c2m8",
34 },
35 ImageID: "7183d3d0-3e24-464d-9c02-xxxx",
36 InstanceOS: types.InstanceOS{
37 ImageType: api.ImageTypeSystem,
38 },
39 SSHKeyID: "k-xxx",
40 DeployCustomConfig: types.DeployCustomConfig{
41 KubeletRootDir: "/var/lib/kubelet",
42 KubeReserved: map[string]string{
43 "cpu": "50m",
44 "memory": "100Mi",
45 },
46 SystemReserved: map[string]string{
47 "cpu": "50m",
48 "memory": "100Mi",
49 },
50 ContainerdConfig: types.ContainerdConfig{
51 DataRoot: "/home/cce/containerd",
52 },
53 },
54 RelationTag: true,
55 InstanceChargingType: api.PaymentTimingPostPaid,
56 Tags: types.TagList{
57 {
58 TagKey: "tagkey",
59 TagValue: "tagvalue",
60 },
61 },
62 },
63 Count: 1,
64 },
65 },
66 })
67 if err != nil {
68 fmt.Println(err.Error())
69 return
70 }
71 s, _ := json.MarshalIndent(resp, "", "\t")
72 fmt.Println("Response:" + string(s))
73}
Create node and associate tags
Plain Text
1 resp, err := ccev2Client.CreateInstances(&v2.CreateInstancesArgs{
2 ClusterID: "",
3 Instances: []*v2.InstanceSet{
4 {
5 InstanceSpec: types.InstanceSpec{
6 // Other configurations for creating the cluster
7
8 // Tags associated with the node
9 Tags: types.TagList{
10 {
11 TagKey: "tagkey",
12 TagValue: "tagvalue",
13 },
14 },
15 },
16 Count: 1,
17 },
18 },
19 })
Query nodes
Plain Text
1func GetInstance(){
2 // User’s Access Key ID and Secret Access Key
3 AK, SK := "", ""
4 // User-specified endpoint
5 ENDPOINT := ""
6 // Initialize a CCEClient
7 ccev2Client, err := v2.NewClient(AK, SK, ENDPOINT)
8 if err != nil {
9 panic(err)
10 }
11 resp, err := ccev2Client.GetInstance(&v2.GetInstanceArgs{
12 ClusterID: "",
13 InstanceID: "",
14 })
15 if err != nil {
16 fmt.Println(err.Error())
17 return
18 }
19 s, _ := json.MarshalIndent(resp, "", "\t")
20 fmt.Println("Response:" + string(s))
21}
Query node tags
Plain Text
1 instance, err := ccev2Client.GetInstance(&v2.GetInstanceArgs{
2 ClusterID: "",
3 InstanceID: "",
4 })
5 if err != nil {
6 fmt.Println(err.Error())
7 return
8 }
9
10 tags, _ := json.MarshalIndent(instance.Instance.Spec.Tags, "", "\t")
11 fmt.Println("Response:" + string(tags))
