From def234115fa24547a592b42b00108804d456ee5f Mon Sep 17 00:00:00 2001 From: Thomas Kooi Date: Fri, 8 Mar 2024 15:25:13 +0100 Subject: [PATCH] Add support for CNI and PSS profile to clusters Signed-off-by: Thomas Kooi --- acloud/data_source_cluster.go | 12 +++++++++++- acloud/resource_cluster.go | 26 +++++++++++++++++++++----- acloud/resource_nodepool.go | 12 ++++++++---- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/acloud/data_source_cluster.go b/acloud/data_source_cluster.go index 1699b74..f1f34a5 100644 --- a/acloud/data_source_cluster.go +++ b/acloud/data_source_cluster.go @@ -41,6 +41,11 @@ func dataSourceCluster() *schema.Resource { Required: true, Description: "Slug of the Cluster", }, + "cni": { + Type: schema.TypeString, + Computed: true, + Description: "CNI plugin for Kubernetes", + }, "cloud_provider": { Type: schema.TypeString, Computed: true, @@ -69,7 +74,12 @@ func dataSourceCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "deleted_protection": { + "pod_security_standards_profile": { + Type: schema.TypeString, + Computed: true, + Description: "Pod Security Standards used by default within the cluster", + }, + "delete_protection": { Description: "Is delete protection enabled on the cluster", Type: schema.TypeBool, Computed: true, diff --git a/acloud/resource_cluster.go b/acloud/resource_cluster.go index b6ea550..20ff3e2 100644 --- a/acloud/resource_cluster.go +++ b/acloud/resource_cluster.go @@ -70,6 +70,11 @@ func resourceCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "cni": { + Type: schema.TypeString, + Optional: true, + Description: "CNI plugin for Kubernetes", + }, "cloud_provider": { Type: schema.TypeString, Computed: true, @@ -96,6 +101,12 @@ func resourceCluster() *schema.Resource { Optional: true, Description: "Avisi Cloud Kubernetes Update Channel that the Cluster follows", }, + "pod_security_standards_profile": { + Type: schema.TypeString, + Optional: true, + Default: "privileged", + Description: "Pod Security Standards used by default within the cluster", + }, "enable_multi_availability_zones": { Type: schema.TypeBool, Optional: true, @@ -159,6 +170,8 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, m interf Name: d.Get("name").(string), Version: d.Get("version").(string), Region: d.Get("region").(string), + CNI: d.Get("cni").(string), + PodSecurityStandardsProfile: d.Get("pod_security_standards_profile").(string), EnableMultiAvailabilityZones: d.Get("enable_multi_availability_zones").(bool), EnableHighAvailability: d.Get("enable_high_available_control_plane").(bool), EnableNATGateway: d.Get("enable_private_cluster").(bool), @@ -236,9 +249,11 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac d.Set("description", cluster.Description) d.Set("slug", cluster.Slug) d.Set("cloud_provider", cluster.CloudProvider) + d.Set("cni", cluster.CNI) d.Set("region", cluster.Region) d.Set("version", cluster.Version) d.Set("update_channel", cluster.UpdateChannel) + d.Set("pod_security_standards_profile", cluster.PodSecurityStandardsProfile) d.Set("enable_multi_availability_zones", cluster.EnableMultiAvailAbilityZones) d.Set("enable_high_available_control_plane", cluster.HighlyAvailable) d.Set("enable_private_cluster", cluster.EnableNATGateway) @@ -269,12 +284,13 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, m interf enableNetworkEncryption := d.Get("enable_network_encryption").(bool) enableHAControlPlane := d.Get("enable_high_available_control_plane").(bool) - + pss := d.Get("pod_security_standards_profile").(string) updateCluster := acloudapi.UpdateCluster{ - UpdateChannel: d.Get("update_channel").(string), - Version: d.Get("version").(string), - EnableNetworkEncryption: &enableNetworkEncryption, - EnableHighAvailability: &enableHAControlPlane, + UpdateChannel: d.Get("update_channel").(string), + Version: d.Get("version").(string), + PodSecurityStandardsProfile: &pss, + EnableNetworkEncryption: &enableNetworkEncryption, + EnableHighAvailability: &enableHAControlPlane, } desiredStatus := "running" diff --git a/acloud/resource_nodepool.go b/acloud/resource_nodepool.go index 3159d16..f5ecf86 100644 --- a/acloud/resource_nodepool.go +++ b/acloud/resource_nodepool.go @@ -24,6 +24,10 @@ func resourceNodepool() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "identity": { + Type: schema.TypeString, + Computed: true, + }, "organisation": { Type: schema.TypeString, Optional: true, @@ -101,9 +105,10 @@ func resourceNodepool() *schema.Resource { Description: "Maximum amount of nodes in the Node Pool. Used when auto_scaling is set to `true`.", }, "node_auto_replacement": { - Type: schema.TypeBool, - Optional: true, - Default: true, + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Auto healing for nodes within this node pool", }, "annotations": { Type: schema.TypeMap, @@ -194,7 +199,6 @@ func resourceNodepoolCreate(ctx context.Context, d *schema.ResourceData, m inter } return resourceNodepoolRead(ctx, d, m) - } func castNodeTaints(taints []interface{}) []acloudapi.NodeTaint {