Skip to content

Commit

Permalink
Support #1196: Pod Subnet and Service Subnet for classic clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya498 authored and hkantare committed Jan 21, 2021
1 parent 24e5cb6 commit 4023785
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a
github.com/IBM-Cloud/bluemix-go v0.0.0-20210121044850-88407f23bf6b
github.com/IBM-Cloud/power-go-client v1.0.53
github.com/IBM/apigateway-go-sdk v0.0.0-20200414212859-416e5948678a
github.com/IBM/go-sdk-core v1.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a h1:Lg81dp8Ohj/I6evkdWTEOZo4/DCuXtkXL03OykiZ2Co=
github.com/IBM-Cloud/bluemix-go v0.0.0-20201230053147-e03f93e5013a/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210121044850-88407f23bf6b h1:Vv+0iRa/xXUSt2gZshqbK+Br1Z/LSlciIBHuOVFU6ko=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210121044850-88407f23bf6b/go.mod h1:gPJbH1etcDj7qS/hBRiLuYW9CY0bRcostSKusa51xR0=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.0.53 h1:v29RRy5S3z950rgOXGEHab4h0LI9L8/8qot30JjmQXs=
github.com/IBM-Cloud/power-go-client v1.0.53/go.mod h1:+mOxjyLeLIloR4EMHTpiDbN+FilZpiVHTwu5eqi+cbI=
Expand Down
24 changes: 23 additions & 1 deletion ibm/resource_ibm_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ func resourceIBMContainerCluster() *schema.Resource {
Default: true,
Description: "Wait for worker node to update during kube version update.",
},
"service_subnet": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Custom subnet CIDR to provide private IP addresses for services",
Computed: true,
},

"pod_subnet": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Custom subnet CIDR to provide private IP addresses for pods",
Computed: true,
},

"ingress_hostname": {
Type: schema.TypeString,
Expand Down Expand Up @@ -591,7 +606,6 @@ func resourceIBMContainerClusterCreate(d *schema.ResourceData, meta interface{})
diskEncryption := d.Get("disk_encryption").(bool)
defaultPoolSize := d.Get("default_pool_size").(int)
gatewayEnabled := d.Get("gateway_enabled").(bool)

hardware := d.Get("hardware").(string)
switch strings.ToLower(hardware) {
case hardwareDedicated:
Expand All @@ -616,6 +630,12 @@ func resourceIBMContainerClusterCreate(d *schema.ResourceData, meta interface{})
if v, ok := d.GetOk("entitlement"); ok {
params.DefaultWorkerPoolEntitlement = v.(string)
}
if v, ok := d.GetOk("pod_subnet"); ok {
params.PodSubnet = v.(string)
}
if v, ok := d.GetOk("service_subnet"); ok {
params.ServiceSubnet = v.(string)
}

if gatewayEnabled {
if v, ok := d.GetOkExists("private_service_endpoint"); ok {
Expand Down Expand Up @@ -781,6 +801,8 @@ func resourceIBMContainerClusterRead(d *schema.ResourceData, meta interface{}) e
d.Set("ingress_hostname", cls.IngressHostname)
d.Set("ingress_secret", cls.IngressSecretName)
d.Set("region", cls.Region)
d.Set("service_subnet", cls.ServiceSubnet)
d.Set("pod_subnet", cls.PodSubnet)
d.Set("subnet_id", d.Get("subnet_id").(*schema.Set))
d.Set("workers_info", workers)
if strings.HasSuffix(cls.MasterKubeVersion, "_openshift") {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ The following arguments are supported:
* Standard clusters:
(a) If you already have a public VLAN set up in your IBM Cloud Classic Infrastructure (SoftLayer) account for that zone, enter the ID of the public VLAN.<br/>
(b) If you want to connect your worker nodes to a private VLAN only, do not specify this option.

* `pod_subnet` - (Optional, Forces new resource,String) Specify a custom subnet CIDR to provide private IP addresses for pods. The subnet must be at least '/23' or larger. For more info, refer [here](https://cloud.ibm.com/docs/containers?topic=containers-cli-plugin-kubernetes-service-cli#pod-subnet).
* `service_subnet` - (Optional, Forces new resource,String) Specify a custom subnet CIDR to provide private IP addresses for services. The subnet must be at least '/24' or larger. For more info, refer [here](https://cloud.ibm.com/docs/containers?topic=containers-cli-plugin-kubernetes-service-cli#service-subnet).
* `private_vlan_id` - (Optional, Forces new resource, string) The private VLAN of the worker node. You can retrieve the value by running the ibmcloud ks vlans <data-center> command in the IBM Cloud CLI.
* Free clusters: You must not specify any private VLAN. Your free cluster is automatically connected to a private VLAN that is owned by IBM.
* Standard clusters:<br/>
Expand Down

0 comments on commit 4023785

Please sign in to comment.