Skip to content

Commit 2fa663e

Browse files
AkarshESManiteja-Kurapati
authored andcommitted
Added - Support for Configure backend NSG at OKE cluster level
1 parent fabf484 commit 2fa663e

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

internal/integrationtest/containerengine_cluster_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ var (
129129
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
130130
}
131131
ContainerengineClusterOptionsServiceLbConfigRepresentation = map[string]interface{}{
132-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
133-
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
132+
"backend_nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`backendNsgIds`}, Update: []string{`backendNsgIds2`}},
133+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
134+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
134135
}
135136
ContainerengineClusterOptionsOpenIdConnectTokenAuthenticationConfigRequiredClaimsRepresentation = map[string]interface{}{
136137
"key": acctest.Representation{RepType: acctest.Optional, Create: `key`, Update: `key2`},
@@ -237,6 +238,7 @@ func TestContainerengineClusterResource_basic(t *testing.T) {
237238
resource.TestCheckResourceAttr(resourceName, "options.0.persistent_volume_config.#", "1"),
238239
resource.TestCheckResourceAttr(resourceName, "options.0.persistent_volume_config.0.freeform_tags.%", "1"),
239240
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.#", "1"),
241+
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.0.backend_nsg_ids.#", "1"),
240242
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.0.freeform_tags.%", "1"),
241243
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_subnet_ids.#", "2"),
242244
resource.TestCheckResourceAttr(resourceName, "type", "ENHANCED_CLUSTER"),
@@ -304,6 +306,7 @@ func TestContainerengineClusterResource_basic(t *testing.T) {
304306
resource.TestCheckResourceAttr(resourceName, "options.0.persistent_volume_config.#", "1"),
305307
resource.TestCheckResourceAttr(resourceName, "options.0.persistent_volume_config.0.freeform_tags.%", "1"),
306308
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.#", "1"),
309+
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.0.backend_nsg_ids.#", "1"),
307310
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_config.0.freeform_tags.%", "1"),
308311
resource.TestCheckResourceAttr(resourceName, "options.0.service_lb_subnet_ids.#", "2"),
309312
resource.TestCheckResourceAttr(resourceName, "type", "ENHANCED_CLUSTER"),
@@ -373,6 +376,7 @@ func TestContainerengineClusterResource_basic(t *testing.T) {
373376
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.persistent_volume_config.#", "1"),
374377
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.persistent_volume_config.0.freeform_tags.%", "1"),
375378
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.service_lb_config.#", "1"),
379+
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.service_lb_config.0.backend_nsg_ids.#", "1"),
376380
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.service_lb_config.0.freeform_tags.%", "1"),
377381
resource.TestCheckResourceAttr(datasourceName, "clusters.0.options.0.service_lb_subnet_ids.#", "2"),
378382
resource.TestCheckResourceAttrSet(datasourceName, "clusters.0.state"),
@@ -432,6 +436,7 @@ func TestContainerengineClusterResource_basic(t *testing.T) {
432436
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.persistent_volume_config.#", "1"),
433437
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.persistent_volume_config.0.freeform_tags.%", "1"),
434438
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.service_lb_config.#", "1"),
439+
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.service_lb_config.0.backend_nsg_ids.#", "1"),
435440
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.service_lb_config.0.freeform_tags.%", "1"),
436441
resource.TestCheckResourceAttr(singularDatasourceName, "options.0.service_lb_subnet_ids.#", "2"),
437442
resource.TestCheckResourceAttrSet(resourceName, "open_id_connect_discovery_endpoint"),

internal/service/containerengine/containerengine_cluster_resource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ func ContainerengineClusterResource() *schema.Resource {
416416
// Required
417417

418418
// Optional
419+
"backend_nsg_ids": {
420+
Type: schema.TypeList,
421+
Optional: true,
422+
Computed: true,
423+
Elem: &schema.Schema{
424+
Type: schema.TypeString,
425+
},
426+
},
419427
"defined_tags": {
420428
Type: schema.TypeMap,
421429
Optional: true,
@@ -2034,6 +2042,19 @@ func PersistentVolumeConfigDetailsToMap(obj *oci_containerengine.PersistentVolum
20342042
func (s *ContainerengineClusterResourceCrud) mapToServiceLbConfigDetails(fieldKeyFormat string) (oci_containerengine.ServiceLbConfigDetails, error) {
20352043
result := oci_containerengine.ServiceLbConfigDetails{}
20362044

2045+
if backendNsgIds, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backend_nsg_ids")); ok {
2046+
interfaces := backendNsgIds.([]interface{})
2047+
tmp := make([]string, len(interfaces))
2048+
for i := range interfaces {
2049+
if interfaces[i] != nil {
2050+
tmp[i] = interfaces[i].(string)
2051+
}
2052+
}
2053+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "backend_nsg_ids")) {
2054+
result.BackendNsgIds = tmp
2055+
}
2056+
}
2057+
20372058
if definedTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "defined_tags")); ok {
20382059
tmp, err := tfresource.MapToDefinedTags(definedTags.(map[string]interface{}))
20392060
if err != nil {
@@ -2052,6 +2073,8 @@ func (s *ContainerengineClusterResourceCrud) mapToServiceLbConfigDetails(fieldKe
20522073
func ServiceLbConfigDetailsToMap(obj *oci_containerengine.ServiceLbConfigDetails) map[string]interface{} {
20532074
result := map[string]interface{}{}
20542075

2076+
result["backend_nsg_ids"] = obj.BackendNsgIds
2077+
20552078
if obj.DefinedTags != nil {
20562079
result["defined_tags"] = tfresource.DefinedTagsToMap(obj.DefinedTags)
20572080
}

website/docs/d/containerengine_cluster.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ The following attributes are exported:
104104
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
105105
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
106106
* `service_lb_config` - Configuration to be applied to load balancers created by Kubernetes services
107+
* `backend_nsg_ids` - A list of the OCIDs of the network security groups (NSGs) associated to backends to LBs (pods/nodes/virtual pods, etc.). Rules necessary for LB to backend communication would be added when rule management mode is set to NSG via annotations. see [NetworkSecurityGroup](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/NetworkSecurityGroup/).
107108
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
108109
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
109110
* `service_lb_subnet_ids` - The OCIDs of the subnets used for Kubernetes services load balancers.

website/docs/d/containerengine_clusters.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ The following attributes are exported:
112112
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
113113
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
114114
* `service_lb_config` - Configuration to be applied to load balancers created by Kubernetes services
115+
* `backend_nsg_ids` - A list of the OCIDs of the network security groups (NSGs) associated to backends to LBs (pods/nodes/virtual pods, etc.). Rules necessary for LB to backend communication would be added when rule management mode is set to NSG via annotations. see [NetworkSecurityGroup](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/NetworkSecurityGroup/).
115116
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
116117
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
117118
* `service_lb_subnet_ids` - The OCIDs of the subnets used for Kubernetes services load balancers.

website/docs/r/containerengine_cluster.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ resource "oci_containerengine_cluster" "test_cluster" {
106106
service_lb_config {
107107
108108
#Optional
109+
backend_nsg_ids = var.cluster_options_service_lb_config_backend_nsg_ids
109110
defined_tags = {"Operations.CostCenter"= "42"}
110111
freeform_tags = {"Department"= "Finance"}
111112
}
@@ -165,6 +166,7 @@ The following arguments are supported:
165166
* `defined_tags` - (Optional) (Updatable) Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
166167
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
167168
* `service_lb_config` - (Optional) (Updatable) Configuration to be applied to load balancers created by Kubernetes services
169+
* `backend_nsg_ids` - (Optional) (Updatable) A list of the OCIDs of the network security groups (NSGs) associated to backends to LBs (pods/nodes/virtual pods, etc.). Rules necessary for LB to backend communication would be added when rule management mode is set to NSG via annotations. see [NetworkSecurityGroup](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/NetworkSecurityGroup/).
168170
* `defined_tags` - (Optional) (Updatable) Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
169171
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
170172
* `service_lb_subnet_ids` - (Optional) The OCIDs of the subnets used for Kubernetes services load balancers.
@@ -247,6 +249,7 @@ The following attributes are exported:
247249
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
248250
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
249251
* `service_lb_config` - Configuration to be applied to load balancers created by Kubernetes services
252+
* `backend_nsg_ids` - A list of the OCIDs of the network security groups (NSGs) associated to backends to LBs (pods/nodes/virtual pods, etc.). Rules necessary for LB to backend communication would be added when rule management mode is set to NSG via annotations. see [NetworkSecurityGroup](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/NetworkSecurityGroup/).
250253
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
251254
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
252255
* `service_lb_subnet_ids` - The OCIDs of the subnets used for Kubernetes services load balancers.

0 commit comments

Comments
 (0)