Skip to content

Commit 2fff047

Browse files
authored
Merge branch 'master' into akstag
2 parents 4d7eaea + f6a0aee commit 2fff047

14 files changed

Lines changed: 270 additions & 0 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ FEATURES:
44

55
* **Deprecated Argument:** `rancher2_cluster.aks_config.tag` - (Deprecated) Use `tags` argument instead as []string
66
* **New Argument:** `rancher2_cluster.aks_config.tags` - (Optional/Computed) Tags for Kubernetes cluster. For example, `["foo=bar","bar=foo"]` (list)
7+
* **New Argument:** `rancher2_cluster.agent_env_vars` - (Optional) Optional Agent Env Vars for Rancher agent. Just for Rancher v2.5.6 and above (list)
78

89
ENHANCEMENTS:
910

docs/data-sources/cluster.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The following arguments are supported:
2525
The following attributes are exported:
2626

2727
* `id` - (Computed) The ID of the resource (string)
28+
* `agent_env_vars` - (Computed) Optional Agent Env Vars for Rancher agent. Just for Rancher v2.5.6 and above (list)
2829
* `cluster_registration_token` - (Computed) Cluster Registration Token generated for the cluster (list maxitems:1)
2930
* `default_project_id` - (Computed) Default project ID for the cluster (string)
3031
* `driver` - (Computed) The driver used for the Cluster. `imported`, `azurekubernetesservice`, `amazonelasticcontainerservice`, `googlekubernetesengine` and `rancherKubernetesEngine` are supported (string)

docs/resources/cluster.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ resource "rancher2_cluster" "foo" {
505505
The following arguments are supported:
506506

507507
* `name` - (Required) The name of the Cluster (string)
508+
* `agent_env_vars` - (Optional) Optional Agent Env Vars for Rancher agent. Just for Rancher v2.5.6 and above (list)
508509
* `rke_config` - (Optional/Computed) The RKE configuration for `rke` Clusters. Conflicts with `aks_config`, `eks_config`, `eks_config_v2`, `gke_config`, `gke_config_v2`, `oke_config` and `k3s_config` (list maxitems:1)
509510
* `rke2_config` - (Optional/Computed) The RKE2 configuration for `rke2` Clusters. Conflicts with `aks_config`, `eks_config`, `gke_config`, `oke_config`, `k3s_config` and `rke_config` (list maxitems:1)
510511
* `k3s_config` - (Optional/Computed) The K3S configuration for `k3s` imported Clusters. Conflicts with `aks_config`, `eks_config`, `eks_config_v2`, `gke_config`, `gke_config_v2`, `oke_config` and `rke_config` (list maxitems:1)
@@ -558,6 +559,13 @@ The following attributes are exported:
558559

559560
## Nested blocks
560561

562+
### `agent_env_vars`
563+
564+
#### Arguments
565+
566+
* `name` - (Required) Rancher agent env var name (string)
567+
* `value` - (Required) Rancher agent env var value (string)
568+
561569
### `rke_config`
562570

563571
**Note** `rke_config` works the same as within Rancher GUI; it will not _provision_ hosts when using no `cloud_provider` or when `cloud_provider` is set to custom. It is expected that nodes are registered by having the `node_command` run on each node. Running the `node_command` is outside the scope of this provider.
@@ -1479,11 +1487,13 @@ The following arguments are supported:
14791487
* `node_pool_subnet_name` - (Optional) Name for node pool subnet. Default `nodedns` (string)
14801488
* `node_public_key_contents` - (Optional) The contents of the SSH public key file to use for the nodes (string)
14811489
* `node_shape` - (Required) The shape of the node (determines number of CPUs and amount of memory on each OKE node) (string)
1490+
* `pod_cidr` - (Optional) A CIDR IP range from which to assign Kubernetes Pod IPs (string)
14821491
* `private_key_contents` - (Required/Sensitive) The private API key file contents for the specified user, in PEM format (string)
14831492
* `private_key_passphrase` - (Optional/Sensitive) The passphrase (if any) of the private key for the OKE cluster (string)
14841493
* `quantity_of_node_subnets` - (Optional) Number of node subnets. Default `1` (int)
14851494
* `quantity_per_subnet` - (Optional) Number of OKE worker nodes in each subnet / availability domain. Default `1` (int)
14861495
* `region` - (Required) The availability domain within the region to host the cluster. See [here](https://docs.cloud.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm) for a list of region names. (string)
1496+
* `service_cidr` - (Optional) A CIDR IP range from which to assign Kubernetes Service IPs (string)
14871497
* `service_dns_domain_name` - (Optional) Name for DNS domain of service subnet. Default `svcdns` (string)
14881498
* `skip_vcn_delete` - (Optional) Specifies whether to skip deleting the virtual cloud network (VCN) on destroy. Default `false` (bool)
14891499
* `tenancy_id` - (Required) The OCID of the tenancy in which to create resources (string)

rancher2/data_source_rancher2_cluster.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ func dataSourceRancher2Cluster() *schema.Resource {
1515
Type: schema.TypeString,
1616
Required: true,
1717
},
18+
"agent_env_vars": {
19+
Type: schema.TypeList,
20+
Computed: true,
21+
Description: "Optional Agent Env Vars for Rancher agent",
22+
Elem: &schema.Schema{
23+
Type: schema.TypeString,
24+
},
25+
},
1826
"driver": {
1927
Type: schema.TypeString,
2028
Computed: true,
@@ -23,6 +31,11 @@ func dataSourceRancher2Cluster() *schema.Resource {
2331
Type: schema.TypeString,
2432
Computed: true,
2533
},
34+
"ca_cert": {
35+
Type: schema.TypeString,
36+
Computed: true,
37+
Sensitive: true,
38+
},
2639
"rke_config": {
2740
Type: schema.TypeList,
2841
MaxItems: 1,

rancher2/resource_rancher2_cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err
261261
enableNetworkPolicy := d.Get("enable_network_policy").(bool)
262262
update := map[string]interface{}{
263263
"name": d.Get("name").(string),
264+
"agentEnvVars": expandEnvVars(d.Get("agent_env_vars").([]interface{})),
264265
"description": d.Get("description").(string),
265266
"defaultPodSecurityPolicyTemplateId": d.Get("default_pod_security_policy_template_id").(string),
266267
"desiredAgentImage": d.Get("desired_agent_image").(string),

rancher2/schema_cluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,14 @@ func clusterFields() map[string]*schema.Schema {
470470
Type: schema.TypeString,
471471
Required: true,
472472
},
473+
"agent_env_vars": {
474+
Type: schema.TypeList,
475+
Optional: true,
476+
Description: "Optional Agent Env Vars for Rancher agent",
477+
Elem: &schema.Resource{
478+
Schema: envVarFields(),
479+
},
480+
},
473481
"driver": {
474482
Type: schema.TypeString,
475483
Optional: true,

rancher2/schema_cluster_oke_config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ type OracleKubernetesEngineConfig struct {
3333
PrivateKeyContents string `json:"privateKeyContents,omitempty" yaml:"privateKeyContents,omitempty"`
3434
PrivateKeyPassphrase string `json:"privateKeyPassphrase,omitempty" yaml:"privateKeyPassphrase,omitempty"`
3535
PrivateNodes bool `json:"enablePrivateNodes,omitempty" yaml:"enablePrivateNodes,omitempty"`
36+
PodCidr string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"`
3637
QuantityOfSubnets int64 `json:"quantityOfNodeSubnets,omitempty" yaml:"quantityOfNodeSubnets,omitempty"`
3738
QuantityPerSubnet int64 `json:"quantityPerSubnet,omitempty" yaml:"quantityPerSubnet,omitempty"`
3839
Region string `json:"region,omitempty" yaml:"region,omitempty"`
40+
ServiceCidr string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"`
3941
ServiceLBSubnet1Name string `json:"loadBalancerSubnetName1,omitempty" yaml:"loadBalancerSubnetName1,omitempty"`
4042
ServiceLBSubnet2Name string `json:"loadBalancerSubnetName2,omitempty" yaml:"loadBalancerSubnetName2,omitempty"`
4143
ServiceSubnetDNSDomainName string `json:"serviceDnsDomainName,omitempty" yaml:"serviceDnsDomainName,omitempty"`
@@ -201,6 +203,16 @@ func clusterOKEConfigFields() map[string]*schema.Schema {
201203
Optional: true,
202204
Description: "Additional CIDR from which to allow ingress to worker nodes",
203205
},
206+
"pod_cidr": {
207+
Type: schema.TypeString,
208+
Optional: true,
209+
Description: "Optional specify the pod CIDR, defaults to 10.244.0.0/16",
210+
},
211+
"service_cidr": {
212+
Type: schema.TypeString,
213+
Optional: true,
214+
Description: "Optional specify the service CIDR, defaults to 10.96.0.0/16",
215+
},
204216
}
205217

206218
return s

rancher2/schema_env_var.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package rancher2
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
5+
)
6+
7+
//Schemas
8+
9+
func envVarFields() map[string]*schema.Schema {
10+
s := map[string]*schema.Schema{
11+
"name": {
12+
Type: schema.TypeString,
13+
Required: true,
14+
},
15+
"value": {
16+
Type: schema.TypeString,
17+
Required: true,
18+
},
19+
}
20+
21+
return s
22+
}

rancher2/structure_cluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage
5959
d.Set("name", in.Name)
6060
d.Set("description", in.Description)
6161

62+
if len(in.AgentEnvVars) > 0 {
63+
d.Set("agent_env_vars", flattenEnvVars(in.AgentEnvVars))
64+
}
65+
6266
err := d.Set("cluster_auth_endpoint", flattenClusterAuthEndpoint(in.LocalClusterAuthEndpoint))
6367
if err != nil {
6468
return err
@@ -396,6 +400,10 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) {
396400
obj.Name = in.Get("name").(string)
397401
obj.Description = in.Get("description").(string)
398402

403+
if v, ok := in.Get("agent_env_vars").([]interface{}); ok && len(v) > 0 {
404+
obj.AgentEnvVars = expandEnvVars(v)
405+
}
406+
399407
if v, ok := in.Get("cluster_auth_endpoint").([]interface{}); ok && len(v) > 0 {
400408
obj.LocalClusterAuthEndpoint = expandClusterAuthEndpoint(v)
401409
}

rancher2/structure_cluster_oke_config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func flattenClusterOKEConfig(in *OracleKubernetesEngineConfig, p []interface{})
7575
obj["node_shape"] = in.NodeShape
7676
}
7777

78+
if len(in.PodCidr) > 0 {
79+
obj["pod_cidr"] = in.PodCidr
80+
}
81+
7882
if len(in.PrivateKeyContents) > 0 {
7983
obj["private_key_contents"] = in.PrivateKeyContents
8084
}
@@ -95,6 +99,10 @@ func flattenClusterOKEConfig(in *OracleKubernetesEngineConfig, p []interface{})
9599
obj["region"] = in.Region
96100
}
97101

102+
if len(in.ServiceCidr) > 0 {
103+
obj["service_cidr"] = in.ServiceCidr
104+
}
105+
98106
if len(in.ServiceSubnetDNSDomainName) > 0 {
99107
obj["service_dns_domain_name"] = in.ServiceSubnetDNSDomainName
100108
}
@@ -205,6 +213,10 @@ func expandClusterOKEConfig(p []interface{}, name string) (*OracleKubernetesEngi
205213
obj.NodeShape = v
206214
}
207215

216+
if v, ok := in["pod_cidr"].(string); ok && len(v) > 0 {
217+
obj.PodCidr = v
218+
}
219+
208220
if v, ok := in["private_key_contents"].(string); ok && len(v) > 0 {
209221
obj.PrivateKeyContents = v
210222
}
@@ -229,6 +241,10 @@ func expandClusterOKEConfig(p []interface{}, name string) (*OracleKubernetesEngi
229241
obj.ServiceSubnetDNSDomainName = v
230242
}
231243

244+
if v, ok := in["service_cidr"].(string); ok && len(v) > 0 {
245+
obj.ServiceCidr = v
246+
}
247+
232248
if v, ok := in["skip_vcn_delete"].(bool); ok {
233249
obj.SkipVCNDelete = v
234250
}

0 commit comments

Comments
 (0)