Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s): add feature gates and admission plugins #386

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions scaleway/resource_k8s_cluster_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ func resourceScalewayK8SClusterBeta() *schema.Resource {
},
},
},
"feature_gates": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Description: "The list of feature gates to enable on the cluster",
},
"admission_plugins": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Description: "The list of admission plugins to enable on the cluster",
},
"default_pool": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -292,13 +308,15 @@ func resourceScalewayK8SClusterBetaCreate(d *schema.ResourceData, m interface{})
}

req := &k8s.CreateClusterRequest{
Region: region,
OrganizationID: d.Get("organization_id").(string),
Name: expandOrGenerateString(d.Get("name"), "cluster"),
Description: description.(string),
Version: version.(string),
Cni: k8s.CNI(d.Get("cni").(string)),
Tags: expandStrings(d.Get("tags")),
Region: region,
OrganizationID: d.Get("organization_id").(string),
Name: expandOrGenerateString(d.Get("name"), "cluster"),
Description: description.(string),
Version: version.(string),
Cni: k8s.CNI(d.Get("cni").(string)),
Tags: expandStrings(d.Get("tags")),
FeatureGates: expandStrings(d.Get("feature_gates")),
AdmissionPlugins: expandStrings(d.Get("admission_plugins")),
}

if dashboard, ok := d.GetOk("enable_dashboard"); ok {
Expand Down Expand Up @@ -680,6 +698,14 @@ func resourceScalewayK8SClusterBetaUpdate(d *schema.ResourceData, m interface{})
updateRequest.Tags = scw.StringsPtr(tags)
}

if d.HasChange("feature_gates") {
updateRequest.FeatureGates = scw.StringsPtr(expandStrings(d.Get("feature_gates")))
}

if d.HasChange("admission_plugins") {
updateRequest.AdmissionPlugins = scw.StringsPtr(expandStrings(d.Get("admission_plugins")))
}

if d.HasChange("version") {
versions, err := k8sAPI.ListClusterAvailableVersions(&k8s.ListClusterAvailableVersionsRequest{
Region: region,
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/k8s_cluster_beta.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ The following arguments are supported:

- `maintenance_window_day` - (Optional) The day of the auto upgrade maintenance window (`monday` to `sunday`, or `any`).

- `feature_gates` - (Optional) The list of [feature gates](https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/) to enable on the cluster.

- `admission_controllers` - (Optional) The list of [admission plugins](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/) to enable on the cluster.

- `default_pool` - (Required) The cluster's default pool configuration.

- `node_type` - (Required) The commercial type of the default pool instances.
Expand Down