Skip to content

Commit

Permalink
feat(nks): Add nodepool label & taints
Browse files Browse the repository at this point in the history
  • Loading branch information
wonchulee committed Dec 20, 2023
1 parent 0afb3bf commit 435a64b
Show file tree
Hide file tree
Showing 26 changed files with 2,331 additions and 1,629 deletions.
12 changes: 7 additions & 5 deletions docs/data-sources/nks_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ In addition to all arguments above, the following attributes are exported:
* `id` - Cluster uuid.
* `endpoint` - Control Plane API address.
* `lb_private_subnet_no` - Subnet No. for private loadbalancer only.
* `lb_public_subnet_no` - Subnet No. for public loadbalancer only. (Available only `SGN`, `JPN` region)
* `lb_public_subnet_no` - Subnet No. for public loadbalancer only. (Supported on `public`, `gov` site)
* `subnet_no_list` - Subnet No. list.
* `public_network` - Public Subnet Network
* `kube_network_plugin` - Kubernetes network plugin.
* `hypervisor_code` - Hypervisor code.
* `cluster_type` - Cluster type. `Maximum number of nodes`
* 10 ea : `SVR.VNKS.STAND.C002.M008.NET.SSD.B050.G002`
* 50 ea : `SVR.VNKS.STAND.C004.M016.NET.SSD.B050.G002`
* `XEN` / `RHV`
* 10 ea : `SVR.VNKS.STAND.C002.M008.NET.SSD.B050.G002`
* 50 ea : `SVR.VNKS.STAND.C004.M016.NET.SSD.B050.G002`
* `login_key_name` - Login key name.
* `zone` - zone Code.
* `vpc_no` - VPC No.
Expand All @@ -49,8 +51,8 @@ In addition to all arguments above, the following attributes are exported:
* `groups_prefix` - Groups prefix.
* `groups_claim` - Groups claim.
* `required_claim` - Required claim.
* `ip_acl_default_action` - IP ACL default action.(Available only `public`, `gov` site)
* `ip_acl` (Available only `public`, `gov` site)
* `ip_acl_default_action` - IP ACL default action. (Supported on `public`, `gov` site)
* `ip_acl` (Supported on `public`, `gov` site)
* `action` - `allow`, `deny`
* `address` - CIDR
* `comment` - Comment
9 changes: 8 additions & 1 deletion docs/data-sources/nks_node_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ In addition to all arguments above, the following attributes are exported:
* `node_status` - Node Status.
* `container_version` - Container version of node.
* `kernel_version` - kernel version of node.
* `k8s_version` - Kubenretes version .
* `k8s_version` - Kubenretes version.
* `label` - NodePool label.
* `key` - Label key.
* `value` - Label value.
* `taint` - NodePool taint.
* `key` - Taint key.
* `value` - Taint value.
* `effect` - Taint effect.
2 changes: 1 addition & 1 deletion docs/data-sources/nks_server_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data "ncloud_nks_server_images" "images" {}
data "ncloud_nks_server_images" "ubuntu20" {
filter {
name = "label"
values = ["ubuntu-20.04-64-server"]
values = ["ubuntu-20.04"]
regex = true
}
}
Expand Down
41 changes: 31 additions & 10 deletions docs/data-sources/nks_server_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ data "ncloud_nks_server_products" "products" {}
data "ncloud_nks_server_images" "images"{
filter {
name = "label"
values = ["ubuntu-20.04-64-server"]
values = ["ubuntu-20.04"]
regex = true
}
}
Expand All @@ -26,6 +27,27 @@ data "ncloud_nks_server_products" "product" {
}
}
data "ncloud_nks_server_products" "product_detail_filter" {
software_code = data.ncloud_nks_server_images.images.images[0].value
zone = "KR-1"
filter {
name = "product_type"
values = [ "STAND"]
}
filter {
name = "cpu_count"
values = [ "2"]
}
filter {
name = "memory_size"
values = [ "8GB" ]
}
}
```

## Argument Reference
Expand All @@ -45,12 +67,11 @@ The following arguments are supported:
* `products` - A list of ServerProduct
* `label` - ServerProduct spec korean description
* `value` - ServerProduct code
* `detail`
* `cpu_count` - Number of cpu
* `gpu_count` - Number of gpu
* `gpu_memory_size` - Size of GPU memory(GB)
* `memory_size` - Size of memory(GB)
* `product_code` - ServerProduct code
* `product_english_desc` - ServerProduct spec english description
* `product_korean_desc` - ServerProduct spec korean description
* `product_type` - ServerProduct Type
* `cpu_count` - Number of cpu
* `gpu_count` - Number of gpu
* `gpu_memory_size` - Size of GPU memory(GB)
* `memory_size` - Size of memory(GB)
* `product_code` - ServerProduct code
* `product_english_desc` - ServerProduct spec english description
* `product_korean_desc` - ServerProduct spec korean description
* `product_type` - ServerProduct Type
21 changes: 12 additions & 9 deletions docs/resources/nks_cluster.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Resource: ncloud_nks_cluster

Provides a Kubernetes Service cluster resource.
Provides a Kubernetes Service Cluster resource.

## Example Usage

Expand All @@ -25,7 +25,7 @@ resource "ncloud_subnet" "subnet_lb" {
subnet = "10.0.100.0/24"
zone = "KR-1"
network_acl_no = ncloud_vpc.vpc.default_network_acl_no
subnet_type = "PUBLIC"
subnet_type = "PRIVATE"
name = "subnet-lb"
usage_type = "LOADB"
}
Expand All @@ -34,7 +34,7 @@ resource "ncloud_subnet" "subnet_lb" {
data "ncloud_nks_versions" "version" {
filter {
name = "value"
values = ["1.20"]
values = ["1.25"]
regex = true
}
}
Expand Down Expand Up @@ -67,16 +67,19 @@ resource "ncloud_nks_cluster" "cluster" {
The following arguments are supported:

* `name` - (Required) Cluster name.
* `hypervisor_code` - (Optional) Hypervisor code. `XEN`(Default), `RHV`
* `cluster_type` -(Required) Cluster type. `Maximum number of nodes`
* 10 ea : `SVR.VNKS.STAND.C002.M008.NET.SSD.B050.G002`
* 50 ea : `SVR.VNKS.STAND.C004.M016.NET.SSD.B050.G002`
* `XEN` / `RHV`
* 10 ea : `SVR.VNKS.STAND.C002.M008.NET.SSD.B050.G002`
* 50 ea : `SVR.VNKS.STAND.C004.M016.NET.SSD.B050.G002`
* `login_key_name` - (Required) Login key name.
* `zone` - (Required) zone Code.
* `vpc_no` - (Required) VPC No.
* `subnet_no_list` - (Required) Subnet No. list.
* `public_network` - (Optional) Public Subnet Network (`boolean`)
* `lb_private_subnet_no` - (Required) Subnet No. for private loadbalancer only.
* `lb_public_subnet_no` - (Optional) Subnet No. for public loadbalancer only. (Available only `SGN`, `JPN` region)
* `lb_public_subnet_no` - (Optional) Subnet No. for public loadbalancer only. (Required in `KR`, `SG`, `JP` regions in public site)
* `kube_network_plugin` - (Optional) Specifies the network plugin. Only Cilium is supported.
* `log` - (Optional)
* `audit` - (Required) Audit log availability. (`boolean`)
* `k8s_version` - (Optional) Kubenretes version. Only upgrade is supported.
Expand All @@ -88,11 +91,12 @@ The following arguments are supported:
* `groups_prefix` - (Optional) Groups prefix.
* `groups_claim` - (Optional) Groups claim.
* `required_claim` - (Optional) Required claim.
* `ip_acl_default_action` - (Optional) IP ACL default action.`allow`(default), `deny`
* `ip_acl` (Optional)
* `ip_acl_default_action` - (Optional) IP ACL default action. `allow`, `deny` (Supported on `public`, `gov` site)
* `ip_acl` (Optional) (Supported on `public`, `gov` site)
* `action` - (Required) `allow`, `deny`
* `address` - (Required) CIDR
* `comment` - (Optional) Comment

## Attributes Reference

In addition to all arguments above, the following attributes are exported:
Expand All @@ -107,4 +111,3 @@ In addition to all arguments above, the following attributes are exported:
Kubernetes Service Cluster can be imported using the name, e.g.,

$ terraform import ncloud_nks_cluster.my_cluster uuid

45 changes: 24 additions & 21 deletions docs/resources/nks_node_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "ncloud_subnet" "subnet_lb" {
data "ncloud_nks_versions" "version" {
filter {
name = "value"
values = ["1.23"]
values = ["1.25"]
regex = true
}
}
Expand All @@ -55,43 +55,41 @@ resource "ncloud_nks_cluster" "cluster" {
}
data "ncloud_server_image" "image" {
data "ncloud_nks_server_images" "image"{
hypervisor_code = "XEN"
filter {
name = "product_name"
name = "label"
values = ["ubuntu-20.04"]
regex = true
}
}
data "ncloud_server_product" "product" {
server_image_product_code = data.ncloud_server_image.image.product_code
data "ncloud_nks_server_products" "product"{
software_code = data.ncloud_nks_server_images.image.images[0].value
zone = "KR-1"
filter {
name = "product_type"
values = [ "STAND" ]
values = [ "STAND"]
}
filter {
name = "cpu_count"
values = [ 2 ]
values = [ "2"]
}
filter {
name = "memory_size"
values = [ "8GB" ]
}
filter {
name = "product_code"
values = [ "SSD" ]
regex = true
}
}
resource "ncloud_nks_node_pool" "node_pool" {
cluster_uuid = ncloud_nks_cluster.cluster.uuid
node_pool_name = "sample-node-pool"
node_count = 1
product_code = data.ncloud_server_product_code.product.product_code
software_code = data.ncloud_nks_server_images.image.images[0].value
product_code = data.ncloud_nks_server_products.product[0].value
subnet_no = ncloud_subnet.subnet.id
autoscale {
enabled = true
Expand All @@ -108,21 +106,27 @@ The following arguments are supported:
* `node_pool_name` - (Required) Nodepool name.
* `cluster_uuid` - (Required) Cluster uuid.
* `node_count` - (Required) Number of nodes.
* `product_code` - (Required) Product code.
* `product_code` - (Optional) Product code. Required for `XEN`/`RHV` cluster nodepool.
* `software_code` - (Optional) Server image code.
* `autoscale`- (Optional)
* `enable` - (Required) Auto scaling availability.
* `max` - (Required) Maximum number of nodes available for auto scaling.
* `min` - (Required) Minimum number of nodes available for auto scaling.
* `subnet_no` - (Deprecated) Subnet No.
* `subnet_no_list` - Subnet no list.
* `subnet_no_list` - (Optional) Subnet no list.
* `k8s_version` - (Optional) Kubenretes version. Only upgrade is supported.

* `label` - (Optional) NodePool label.
* `key` - (Required) Label key.
* `value` - (Required) Label value.
* `taint` - (Optional) NodePool taint.
* `key` - (Required) Taint key.
* `value` - (Required) Taint value.
* `effect` - (Required) Taint effect.
## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - The ID of nodepool.`CusterUuid:NodePoolName`
* `id` - The ID of nodepool.`cluster_uuid:node_pool_name`
* `instance_no` - Instance No.
* `nodes`- Running nodes in nodepool.
* `name` - The name of Server instance.
Expand All @@ -138,4 +142,3 @@ In addition to all arguments above, the following attributes are exported:
NKS Node Pools can be imported using the cluster_name and node_pool_name separated by a colon (:), e.g.,

$ terraform import ncloud_nks_node_pool.my_node_pool uuid:my_node_pool

36 changes: 20 additions & 16 deletions examples/nks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,50 +60,54 @@ resource "ncloud_nks_cluster" "cluster" {
}
}

data "ncloud_nks_server_images" "images"{
data "ncloud_nks_server_images" "image"{
hypervisor_code = "XEN"
filter {
name = "label"
values = ["ubuntu-20.04-64-server"]
values = ["ubuntu-20.04"]
regex = true
}
}

data "ncloud_nks_server_products" "products" {

software_code = data.ncloud_nks_server_images.images.images[0].value
data "ncloud_nks_server_products" "nks_products"{
software_code = data.ncloud_nks_server_images.image.images[0].value
zone = "KR-1"

filter {
name = "product_type"
values = [ "STAND" ]
values = [ "STAND"]
}

filter {
name = "cpu_count"
values = [ 2 ]
values = [ "2"]
}

filter {
name = "memory_size"
values = [ "8GB" ]
}

filter {
name = "product_code"
values = [ "SSD" ]
regex = true
}
}

resource "ncloud_nks_node_pool" "node_pool" {
cluster_uuid = ncloud_nks_cluster.cluster.uuid
node_pool_name = "pool1"
node_count = 1
product_code = data.ncloud_nks_server_products.products.products[0].value
software_code = data.ncloud_nks_server_images.images.images[0].value
subnet_no = ncloud_subnet.node_subnet.id
software_code = data.ncloud_nks_server_images.image.images[0].value
product_code = data.ncloud_nks_server_products.nks_products.products[0].value
subnet_no_list = [ncloud_subnet.node_subnet.id]
autoscale {
enabled = true
min = 1
max = 2
}
label {
key = "foo"
value = "bar"
}
taint {
key = "foo"
value = "bar"
effect = "NoExecute"
}
}
2 changes: 1 addition & 1 deletion examples/nks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable name {
}

variable nks_version {
default = "1.23"
default = "1.25"
}

variable client_ip {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-ncloud
go 1.19

require (
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.6.4
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.6.7
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -47,10 +47,10 @@ require (
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.50.1 // indirect
Expand Down
Loading

0 comments on commit 435a64b

Please sign in to comment.