Skip to content

Commit

Permalink
[CCE] Resource opentelekomcloud_cce_node_pool_v3 (#825)
Browse files Browse the repository at this point in the history
[CCE] Resource opentelekomcloud_cce_node_pool_v3

Summary of the Pull Request
Resolve #806
Based on #807
Co-authored-by: Philipp Eckel philipp.eckel@coyoapp.com
PR Checklist

 Refers to: #806, #807
 Tests added/passed.
 Documentation updated.
 Schema updated.

Acceptance Steps Performed
=== RUN   TestAccCCENodePoolsV3_basic
--- PASS: TestAccCCENodePoolsV3_basic (924.48s)
PASS

Process finished with exit code 0

Reviewed-by: Anton Kachurin <katchuring@gmail.com>
Reviewed-by: Rodion Gyrbu <fpsoff@outlook.com>
Reviewed-by: Anton Sidelnikov <None>
Reviewed-by: None <None>
  • Loading branch information
anton-sidelnikov committed Feb 5, 2021
1 parent cbf3a86 commit 42a2b94
Show file tree
Hide file tree
Showing 7 changed files with 883 additions and 0 deletions.
120 changes: 120 additions & 0 deletions docs/resources/cce_node_pool_v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
subcategory: "Cloud Container Engine (CCE)"
---

# opentelekomcloud_cce_node_pool_v3

Add a node pool to a container cluster.

## Example Usage

```hcl
variable "cluster_id" {}
variable "ssh_key" {}
variable "availability_zone" {}
resource "opentelekomcloud_cce_node_pool_v3" "node_pool_1" {
cluster_id = var.cluster_id
name = "opentelekomcloud-cce-node-pool_test"
os = "EulerOS 2.5"
flavor = "s2.xlarge.2"
initial_node_count = 2
availability_zone = var.availability_zone
key_pair = var.ssh_key
scale_enable = true
min_node_count = 2
max_node_count = 9
scale_down_cooldown_time = 100
priority = 1
root_volume {
size = 40
volumetype = "SSD"
}
data_volumes {
size = 100
volumetype = "SSD"
}
}
```

## Argument Reference
The following arguments are supported:

* `cluster_id` - (Required) ID of the cluster. Changing this parameter will create a new resource.

* `flavor` - (Required) Specifies the flavor id. Changing this parameter will create a new resource.

* `availability_zone` - (Required) specify the name of the available partition (AZ). Changing this parameter will create a new resource.

* `key_pair` - (Optional) Key pair name when logging in to select the key pair mode. This parameter and password are alternative. Changing this parameter will create a new resource.

* `password` - (Optional) Key pair name when logging in to select the key pair mode. This parameter and password are alternative. Changing this parameter will create a new resource.

* `os` - (Optional) Node OS. Changing this parameter will create a new resource.

Supported OS depends on kubernetes version of the cluster.
* Clusters of Kubernetes `v1.13` or later support `EulerOS 2.5`.
* Clusters of Kubernetes `v1.17` or later support `EulerOS 2.5` and `CentOS 7.7`.

* `name` - (Required) Node Pool Name.

* `initial_node_count` - (Required) Initial number of expected nodes in the node pool.

* `subnet_id` - (Optional) The ID of the subnet to which the NIC belongs. Changing this parameter will create a new resource.

* `preinstall` - (Optional) Script required before installation. The input value can be a Base64 encoded string or not.
Changing this parameter will create a new resource.

* `postinstall` - (Optional) Script required after installation. The input value can be a Base64 encoded string or not.
Changing this parameter will create a new resource.

* `scale_enable` - (Optional) Whether to enable auto scaling. If Autoscaler is enabled, install the autoscaler add-on to use the auto scaling feature.

* `min_node_count` - (Optional) Minimum number of nodes allowed if auto scaling is enabled.

* `max_node_count` - (Optional) Maximum number of nodes allowed if auto scaling is enabled.

* `scale_down_cooldown_time` - (Optional) Interval between two scaling operations, in minutes.

* `server_group_reference` - (Optional) ECS group ID. If this parameter is specified, all nodes in the node pool will be created in this ECS group.

* `priority` - (Optional) Weight of a node pool. A node pool with a higher weight has a higher priority during scaling.

* `user_tags` - (Optional) Tag of a VM, key/value pair format. Changing this parameter will create a new resource.

* `k8s_tags` - (Optional) Tags of a Kubernetes node, key/value pair format. Changing this parameter will create a new resource.

* `taints` - (Optional) Taints to created nodes to configure anti-affinity. Changing this parameter will create a new resource.
* `key` - (Required) A key must contain 1 to 63 characters starting with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. A DNS subdomain name can be used as the prefix of a key.
* `value` - (Required) A value must start with a letter or digit and can contain a maximum of 63 characters, including letters, digits, hyphens (-), underscores (_), and periods (.).
* `effect` - (Optional) Available options are `NoSchedule`, `PreferNoSchedule`, and `NoExecute`.

* `root_volume` - (Required) It corresponds to the system disk related configuration. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.

* `data_volumes` - (Required) Represents the data disk to be created. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.

## Attributes Reference

All above argument parameters can be exported as attribute parameters along with attribute reference.

* `status` - Node status information.

* `id` - Specifies a resource ID in UUID format.

* `billing_mode ` - Billing mode of a node.

## Timeouts

This resource provides the following timeouts configuration options:

- `create` - Default is 20 minutes.

- `delete` - Default is 20 minutes.
9 changes: 9 additions & 0 deletions opentelekomcloud/custom_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ func firstOneSet(res map[string]interface{}, k1, k2 string) (interface{}, error)
}
return v2, nil
}

func getHashOrEmpty(v interface{}) string {
switch v.(type) {
case string:
return installScriptHashSum(v.(string))
default:
return ""
}
}
21 changes: 21 additions & 0 deletions opentelekomcloud/customize_diffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,27 @@ func validateVPC(argName string) schema.CustomizeDiffFunc {
}
}

func validateSubnet(argName string) schema.CustomizeDiffFunc {
return func(d *schema.ResourceDiff, meta interface{}) error {
subnetId := d.Get(argName)
if subnetId == nil {
return fmt.Errorf(argMissingMsg, argName)
}
if subnetId == "" {
return nil
}
config := meta.(*Config)
subnetClient, err := config.networkingV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("error creating opentelekomcloud CCE Client: %s", err)
}
if err := subnets.Get(subnetClient, subnetId.(string)).Err; err != nil {
return fmt.Errorf("can't find Subnet `%s`: %s", subnetId, err)
}
return nil
}
}

func multipleCustomizeDiffs(funcs ...schema.CustomizeDiffFunc) schema.CustomizeDiffFunc {
return func(d *schema.ResourceDiff, meta interface{}) error {
mErr := &multierror.Error{}
Expand Down
1 change: 1 addition & 0 deletions opentelekomcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func Provider() terraform.ResourceProvider {
"opentelekomcloud_cce_addon_v3": resourceCCEAddonV3(),
"opentelekomcloud_cce_cluster_v3": resourceCCEClusterV3(),
"opentelekomcloud_cce_node_v3": resourceCCENodeV3(),
"opentelekomcloud_cce_node_pool_v3": resourceCCENodePoolV3(),
"opentelekomcloud_ces_alarmrule": resourceAlarmRule(),
"opentelekomcloud_compute_bms_server_v2": resourceComputeBMSInstanceV2(),
"opentelekomcloud_compute_bms_tags_v2": resourceBMSTagsV2(),
Expand Down
Loading

0 comments on commit 42a2b94

Please sign in to comment.