Feat: add egress_address_ranges attribute to ske resource (#672)

* feat: add egress_address_ranges attribute to ske resource

* docs: generate new docs for ske
This commit is contained in:
Mauritz Uphoff 2025-02-10 10:14:11 +01:00 committed by GitHub
parent 170041f807
commit c4e25f560b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 5 deletions

View file

@ -32,6 +32,7 @@ data "stackit_ske_cluster" "example" {
- `allow_privileged_containers` (Boolean, Deprecated) DEPRECATED as of Kubernetes 1.25+ - `allow_privileged_containers` (Boolean, Deprecated) DEPRECATED as of Kubernetes 1.25+
Flag to specify if privileged mode for containers is enabled or not. Flag to specify if privileged mode for containers is enabled or not.
This should be used with care since it also disables a couple of other features like the use of some volume type (e.g. PVCs). This should be used with care since it also disables a couple of other features like the use of some volume type (e.g. PVCs).
- `egress_address_ranges` (List of String) The outgoing network ranges (in CIDR notation) of traffic originating from workload on the cluster.
- `extensions` (Attributes) A single extensions block as defined below (see [below for nested schema](#nestedatt--extensions)) - `extensions` (Attributes) A single extensions block as defined below (see [below for nested schema](#nestedatt--extensions))
- `hibernations` (Attributes List) One or more hibernation block as defined below. (see [below for nested schema](#nestedatt--hibernations)) - `hibernations` (Attributes List) One or more hibernation block as defined below. (see [below for nested schema](#nestedatt--hibernations))
- `id` (String) Terraform's internal data source. ID. It is structured as "`project_id`,`name`". - `id` (String) Terraform's internal data source. ID. It is structured as "`project_id`,`name`".

View file

@ -62,6 +62,7 @@ Deprecated as of Kubernetes 1.25 and later
### Read-Only ### Read-Only
- `egress_address_ranges` (List of String) The outgoing network ranges (in CIDR notation) of traffic originating from workload on the cluster.
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`name`". - `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`name`".
- `kubernetes_version_used` (String) Full Kubernetes version used. For example, if 1.22 was set in `kubernetes_version_min`, this value may result to 1.22.15. SKE automatically updates the cluster Kubernetes version if you have set `maintenance.enable_kubernetes_version_updates` to true or if there is a mandatory update, as described in [Updates for Kubernetes versions and Operating System versions in SKE](https://docs.stackit.cloud/stackit/en/version-updates-in-ske-10125631.html). - `kubernetes_version_used` (String) Full Kubernetes version used. For example, if 1.22 was set in `kubernetes_version_min`, this value may result to 1.22.15. SKE automatically updates the cluster Kubernetes version if you have set `maintenance.enable_kubernetes_version_updates` to true or if there is a mandatory update, as described in [Updates for Kubernetes versions and Operating System versions in SKE](https://docs.stackit.cloud/stackit/en/version-updates-in-ske-10125631.html).

View file

@ -110,7 +110,11 @@ func (r *clusterDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
DeprecationMessage: "Please remove this flag from your configuration when using Kubernetes version 1.25+.", DeprecationMessage: "Please remove this flag from your configuration when using Kubernetes version 1.25+.",
Computed: true, Computed: true,
}, },
"egress_address_ranges": schema.ListAttribute{
Description: "The outgoing network ranges (in CIDR notation) of traffic originating from workload on the cluster.",
Computed: true,
ElementType: types.StringType,
},
"node_pools": schema.ListNestedAttribute{ "node_pools": schema.ListNestedAttribute{
Description: "One or more `node_pool` block as defined below.", Description: "One or more `node_pool` block as defined below.",
Computed: true, Computed: true,

View file

@ -77,6 +77,7 @@ type Model struct {
Network types.Object `tfsdk:"network"` Network types.Object `tfsdk:"network"`
Hibernations types.List `tfsdk:"hibernations"` Hibernations types.List `tfsdk:"hibernations"`
Extensions types.Object `tfsdk:"extensions"` Extensions types.Object `tfsdk:"extensions"`
EgressAddressRanges types.List `tfsdk:"egress_address_ranges"`
} }
// Struct corresponding to Model.NodePools[i] // Struct corresponding to Model.NodePools[i]
@ -374,6 +375,11 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
Description: "Flag to specify if privileged mode for containers is enabled or not.\nThis should be used with care since it also disables a couple of other features like the use of some volume type (e.g. PVCs).\nDeprecated as of Kubernetes 1.25 and later", Description: "Flag to specify if privileged mode for containers is enabled or not.\nThis should be used with care since it also disables a couple of other features like the use of some volume type (e.g. PVCs).\nDeprecated as of Kubernetes 1.25 and later",
Optional: true, Optional: true,
}, },
"egress_address_ranges": schema.ListAttribute{
Description: "The outgoing network ranges (in CIDR notation) of traffic originating from workload on the cluster.",
Computed: true,
ElementType: types.StringType,
},
"node_pools": schema.ListNestedAttribute{ "node_pools": schema.ListNestedAttribute{
Description: "One or more `node_pool` block as defined below.", Description: "One or more `node_pool` block as defined below.",
Required: true, Required: true,
@ -1320,6 +1326,15 @@ func mapFields(ctx context.Context, cl *ske.Cluster, m *Model) error {
m.AllowPrivilegedContainers = types.BoolPointerValue(cl.Kubernetes.AllowPrivilegedContainers) m.AllowPrivilegedContainers = types.BoolPointerValue(cl.Kubernetes.AllowPrivilegedContainers)
} }
m.EgressAddressRanges = types.ListNull(types.StringType)
if cl.Status != nil {
var diags diag.Diagnostics
m.EgressAddressRanges, diags = types.ListValueFrom(ctx, types.StringType, cl.Status.EgressAddressRanges)
if diags.HasError() {
return fmt.Errorf("map egressAddressRanges: %w", core.DiagsToError(diags))
}
}
err := mapNodePools(ctx, cl, m) err := mapNodePools(ctx, cl, m)
if err != nil { if err != nil {
return fmt.Errorf("map node_pools: %w", err) return fmt.Errorf("map node_pools: %w", err)

View file

@ -57,6 +57,7 @@ func TestMapFields(t *testing.T) {
Network: types.ObjectNull(networkTypes), Network: types.ObjectNull(networkTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
Extensions: types.ObjectNull(extensionsTypes), Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
}, },
true, true,
}, },
@ -140,9 +141,10 @@ func TestMapFields(t *testing.T) {
}, },
}, },
Status: &ske.ClusterStatus{ Status: &ske.ClusterStatus{
Aggregated: &cs, Aggregated: &cs,
Error: nil, Error: nil,
Hibernated: nil, Hibernated: nil,
EgressAddressRanges: &[]string{"0.0.0.0/32", "1.1.1.1/32"},
}, },
}, },
Model{ Model{
@ -152,7 +154,13 @@ func TestMapFields(t *testing.T) {
KubernetesVersion: types.StringNull(), KubernetesVersion: types.StringNull(),
KubernetesVersionUsed: types.StringValue("1.2.3"), KubernetesVersionUsed: types.StringValue("1.2.3"),
AllowPrivilegedContainers: types.BoolValue(true), AllowPrivilegedContainers: types.BoolValue(true),
EgressAddressRanges: types.ListValueMust(
types.StringType,
[]attr.Value{
types.StringValue("0.0.0.0/32"),
types.StringValue("1.1.1.1/32"),
},
),
NodePools: types.ListValueMust( NodePools: types.ListValueMust(
types.ObjectType{AttrTypes: nodePoolTypes}, types.ObjectType{AttrTypes: nodePoolTypes},
[]attr.Value{ []attr.Value{
@ -265,6 +273,7 @@ func TestMapFields(t *testing.T) {
Network: types.ObjectNull(networkTypes), Network: types.ObjectNull(networkTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
Extensions: types.ObjectNull(extensionsTypes), Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
}, },
true, true,
}, },
@ -298,6 +307,7 @@ func TestMapFields(t *testing.T) {
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes), Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{ Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{ "acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(true), "enabled": types.BoolValue(true),
@ -345,6 +355,7 @@ func TestMapFields(t *testing.T) {
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes), Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{ Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{ "acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(false), "enabled": types.BoolValue(false),
@ -403,6 +414,7 @@ func TestMapFields(t *testing.T) {
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}), NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes), Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{ Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{ "acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(true), "enabled": types.BoolValue(true),
@ -440,6 +452,7 @@ func TestMapFields(t *testing.T) {
Maintenance: types.ObjectNull(maintenanceTypes), Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}), Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
Extensions: types.ObjectNull(extensionsTypes), Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
}, },
true, true,
}, },
@ -565,6 +578,7 @@ func TestMapFields(t *testing.T) {
KubernetesVersion: types.StringNull(), KubernetesVersion: types.StringNull(),
KubernetesVersionUsed: types.StringValue("1.2.3"), KubernetesVersionUsed: types.StringValue("1.2.3"),
AllowPrivilegedContainers: types.BoolValue(true), AllowPrivilegedContainers: types.BoolValue(true),
EgressAddressRanges: types.ListNull(types.StringType),
NodePools: types.ListValueMust( NodePools: types.ListValueMust(
types.ObjectType{AttrTypes: nodePoolTypes}, types.ObjectType{AttrTypes: nodePoolTypes},
[]attr.Value{ []attr.Value{