Skip to content

Commit 49e3d91

Browse files
authored
azurerm_kubernetes_cluster data source - support for the outbound_type and bootstrap_profile (#30983)
[ENHANCEMENT] Data Source: `azurerm_kubernetes_cluster` - export the `bootstrap_profile` and `network_profile.outbound_type` attributes
1 parent 3beb88a commit 49e3d91

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

internal/services/containers/kubernetes_cluster_data_source.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource {
186186
Computed: true,
187187
},
188188

189+
"bootstrap_profile": {
190+
Type: pluginsdk.TypeList,
191+
Computed: true,
192+
Elem: &pluginsdk.Resource{
193+
Schema: map[string]*pluginsdk.Schema{
194+
"artifact_source": {
195+
Type: pluginsdk.TypeString,
196+
Computed: true,
197+
},
198+
199+
"container_registry_id": {
200+
Type: pluginsdk.TypeString,
201+
Computed: true,
202+
},
203+
},
204+
},
205+
},
206+
189207
"current_kubernetes_version": {
190208
Type: pluginsdk.TypeString,
191209
Computed: true,
@@ -590,6 +608,11 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource {
590608
Type: pluginsdk.TypeString,
591609
Computed: true,
592610
},
611+
612+
"outbound_type": {
613+
Type: pluginsdk.TypeString,
614+
Computed: true,
615+
},
593616
},
594617
},
595618
},
@@ -791,6 +814,14 @@ func dataSourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}
791814
return fmt.Errorf("setting `agent_pool_profile`: %+v", err)
792815
}
793816

817+
bootstrapProfile, err := flattenBootstrapProfile(props.BootstrapProfile)
818+
if err != nil {
819+
return fmt.Errorf("flattening `bootstrap_profile`: %+v", err)
820+
}
821+
if err := d.Set("bootstrap_profile", bootstrapProfile); err != nil {
822+
return fmt.Errorf("setting `bootstrap_profile`: %+v", err)
823+
}
824+
794825
azureKeyVaultKms := flattenKubernetesClusterDataSourceKeyVaultKms(props.SecurityProfile)
795826
if err := d.Set("key_management_service", azureKeyVaultKms); err != nil {
796827
return fmt.Errorf("setting `key_management_service`: %+v", err)
@@ -1370,6 +1401,8 @@ func flattenKubernetesClusterDataSourceNetworkProfile(profile *managedclusters.C
13701401
values["load_balancer_sku"] = string(*profile.LoadBalancerSku)
13711402
}
13721403

1404+
values["outbound_type"] = pointer.From(profile.OutboundType)
1405+
13731406
return []interface{}{values}
13741407
}
13751408

internal/services/containers/kubernetes_cluster_data_source_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func TestAccDataSourceKubernetesCluster_advancedNetworkingAzure(t *testing.T) {
157157
check.That(data.ResourceName).Key("network_profile.0.network_plugin").Exists(),
158158
check.That(data.ResourceName).Key("network_profile.0.dns_service_ip").Exists(),
159159
check.That(data.ResourceName).Key("network_profile.0.service_cidr").Exists(),
160+
check.That(data.ResourceName).Key("network_profile.0.outbound_type").Exists(),
160161
),
161162
},
162163
})
@@ -650,6 +651,22 @@ func TestAccDataSourceKubernetesCluster_serviceMeshRevisions(t *testing.T) {
650651
})
651652
}
652653

654+
func TestAccDataSourceKubernetesCluster_bootstrapProfile(t *testing.T) {
655+
data := acceptance.BuildTestData(t, "data.azurerm_kubernetes_cluster", "test")
656+
r := KubernetesClusterDataSource{}
657+
658+
data.DataSourceTest(t, []acceptance.TestStep{
659+
{
660+
Config: r.bootstrapProfile(data),
661+
Check: acceptance.ComposeTestCheckFunc(
662+
check.That(data.ResourceName).Key("bootstrap_profile.#").HasValue("1"),
663+
check.That(data.ResourceName).Key("bootstrap_profile.0.artifact_source").HasValue("Cache"),
664+
check.That(data.ResourceName).Key("bootstrap_profile.0.container_registry_id").Exists(),
665+
),
666+
},
667+
})
668+
}
669+
653670
func (KubernetesClusterDataSource) basicConfig(data acceptance.TestData) string {
654671
return fmt.Sprintf(`
655672
%s
@@ -996,3 +1013,13 @@ data "azurerm_kubernetes_cluster" "test" {
9961013
}
9971014
`, KubernetesClusterResource{}.addonProfileServiceMeshProfileRevisionsConfig(data, revisions))
9981015
}
1016+
1017+
func (KubernetesClusterDataSource) bootstrapProfile(data acceptance.TestData) string {
1018+
return fmt.Sprintf(`
1019+
%s
1020+
data "azurerm_kubernetes_cluster" "test" {
1021+
name = azurerm_kubernetes_cluster.test.name
1022+
resource_group_name = azurerm_kubernetes_cluster.test.resource_group_name
1023+
}
1024+
`, KubernetesClusterResource{}.networkIsolatedBootstrapProfileArtifactSourceCache(data))
1025+
}

website/docs/d/kubernetes_cluster.html.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ The following attributes are exported:
4444

4545
* `azure_policy_enabled` - Is Azure Policy enabled on this managed Kubernetes Cluster?
4646

47+
* `bootstrap_profile` - A `bootstrap_profile` block as documented below.
48+
4749
* `agent_pool_profile` - An `agent_pool_profile` block as documented below.
4850

4951
* `current_kubernetes_version` - Contains the current version of Kubernetes running on the Cluster.
@@ -172,6 +174,14 @@ An `azure_active_directory_role_based_access_control` block exports the followin
172174

173175
---
174176

177+
A `bootstrap_profile` block exports the following:
178+
179+
* `artifact_source` - The source from which artifacts are pulled during bootstrap.
180+
181+
* `container_registry_id` - The ID of the Azure Container Registry used for caching artifacts during bootstrap.
182+
183+
---
184+
175185
A `upgrade_settings` block exports the following:
176186

177187
* `drain_timeout_in_minutes` - The amount of time in minutes to wait on eviction of pods and graceful termination per node. This eviction wait time honors waiting on pod disruption budgets. If this time is exceeded, the upgrade fails.
@@ -263,6 +273,8 @@ A `network_profile` block exports the following:
263273

264274
* `network_mode` - Network mode to be used with Azure CNI. e.g. `bridge` or `transparent`
265275

276+
* `outbound_type` - The outbound (egress) routing method which is used for cluster egress traffic.
277+
266278
* `pod_cidr` - The CIDR used for pod IP addresses.
267279

268280
* `service_cidr` - Network range used by the Kubernetes service.

0 commit comments

Comments
 (0)