Skip to content

Commit

Permalink
Add support for CNI and PSS profile to clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Kooi <t.j.kooi@avisi.nl>
  • Loading branch information
thojkooi committed Mar 14, 2024
1 parent dc325f2 commit def2341
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
12 changes: 11 additions & 1 deletion acloud/data_source_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 21 additions & 5 deletions acloud/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 8 additions & 4 deletions acloud/resource_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit def2341

Please sign in to comment.