Skip to content

Commit

Permalink
Added cloud-config support (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilic authored Mar 29, 2020
1 parent cf80c0e commit 51a2a0e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.5.0 (March 29, 2020)
FEATURES:
* `rancher2-vsphere-cluster`: Added support for specifying cloud-config YAML for cluster nodes, either through global setting `node_cloud_config` or through a local `cloud_config` parameter inside `node_spec`; contents of a cloud-config YAML file should be passed to the module, and this can be done either by defining YAML inline using Terraform's `heredoc` synthax or by loading it from a file using Terraform's `file()` function; cloud-config spec is optional, if omitted, cloud-config file will be left empty (set to `#cloud-config`)

## 2.4.0 (March 29, 2020)

FEATURES:
Expand Down
3 changes: 2 additions & 1 deletion rancher2-vsphere-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| master\_node\_pool\_name | Name of the master (consolidated control plane and etcd) node pool | `string` | `"master"` | no |
| master\_node\_prefix | Prefix for nodes created in master (consolidated control plane and etcd) node pool | `string` | `"master-"` | no |
| master\_node\_quantity | Number of nodes in master (consolidated control plane and etcd) node pool | `number` | n/a | yes |
| node\_cloud\_config | Global setting for the contents of cloud-config YAML file which will be applied on all cluster nodes; these contents should be defined in the root module either inline using the `heredoc` synthax, or loaded from a file using Terraform's `file()` function. `cloud_config` parameter inside `node_spec` overrides this global setting on a per node role basis; if neither are set, cloud-config file for the node will have content of `#cloud-config` (which effectively makes it empty) | `string` | n/a | yes |
| node\_cluster | Global setting for vSphere cluster in which to create all cluster nodes; either this or `cluster` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
| node\_datacenter | Global setting for vSphere datacenter in which to create all cluster nodes; either this or `datacenter` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
| node\_datastore | Global setting for vSphere datastore in which to create all cluster nodes; either this or `datastore` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
Expand All @@ -39,7 +40,7 @@
| node\_template\_ssh\_user | Global setting for the SSH user for Rancher to connect to all cluster nodes after deployment from template; either this or `template_ssh_user` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
| node\_template\_ssh\_user\_group | Global setting for the user group to which Rancher will chown the uploaded keys on all cluster nodes; either this or `template_ssh_user_group` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
| node\_vsphere\_template | Global setting for vSphere template from which to create all cluster nodes; either this or `vsphere_template` parameter inside `node_spec` (which overrides it) need to be set | `string` | n/a | yes |
| private\_registries\_spec | Specification of private registries for Docker images. Take a look at the `examples` directory for synthax | `map` | `{}` | no |
| private\_registries\_spec | Specification of private registries for Docker images. Multiple registries can be specified, take a look at the `examples` directory for synthax. Only the `url` parameter is mandatory. If you set password access to registry, for future Terraform runs have in mind that Rancher API doesn't return registry password, so every Terraform operation will offer to change the cluster resource by adding the registry password field even if you haven't done any changes in your spec | `map` | `{}` | no |
| single\_node\_cluster | Whether to create a single node cluster with all roles consolidated on one node | `bool` | `false` | no |
| worker\_node\_pool\_name | Name of the worker node pool | `string` | `"worker"` | no |
| worker\_node\_prefix | Prefix for nodes created in worker node pool | `string` | `"worker-"` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module "rancher_cluster_cloud_provider" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
worker = {
vsphere_template = "MyFolder/k8s-worker"
Expand All @@ -84,6 +85,7 @@ module "rancher_cluster_cloud_provider" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module "rancher_cluster_single_node" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
}

Expand Down
5 changes: 5 additions & 0 deletions rancher2-vsphere-cluster/examples/various-node-roles/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module "rancher_cluster_separate_control_plane_etcd" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
etcd = {
vsphere_template = "MyFolder/k8s-etcd"
Expand All @@ -53,6 +54,7 @@ module "rancher_cluster_separate_control_plane_etcd" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
worker = {
vsphere_template = "MyFolder/k8s-worker"
Expand All @@ -68,6 +70,7 @@ module "rancher_cluster_separate_control_plane_etcd" {
template_ssh_user = "root"
template_ssh_password = "MySecretPass"
template_ssh_user_group = "root"
cloud_config = file("cloud-config.yml")
}
}

Expand Down Expand Up @@ -106,6 +109,7 @@ module "rancher_cluster_separate_control_plane_etcd_global_spec" {
node_template_ssh_user = "root"
node_template_ssh_password = "MySecretPass"
node_template_ssh_user_group = "root"
node_cloud_config = file("cloud-config.yml")

node_spec = {
control_plane = {
Expand Down Expand Up @@ -165,6 +169,7 @@ module "rancher_cluster_consolidated_control_plane_etcd" {
node_template_ssh_user = "root"
node_template_ssh_password = "MySecretPass"
node_template_ssh_user_group = "root"
node_cloud_config = file("cloud-config.yml")

node_spec = {
master = {
Expand Down
2 changes: 1 addition & 1 deletion rancher2-vsphere-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "rancher2_node_template" "node_template" {
contains(keys(each.value), "portgroup") ? "guestinfo.interface.0.ip.0.netmask=$${netmask:${each.value.portgroup}}" : "guestinfo.interface.0.ip.0.netmask=$${netmask:${var.node_portgroup}}",
contains(keys(each.value), "portgroup") ? "guestinfo.interface.0.route.0.gateway=$${gateway:${each.value.portgroup}}" : "guestinfo.interface.0.route.0.gateway=$${gateway:${var.node_portgroup}}"
]
cloud_config = "#cloud-config"
cloud_config = contains(keys(each.value), "cloud_config") ? each.value.cloud_config : (var.node_cloud_config != null ? var.node_cloud_config : "#cloud-config")
}
}

Expand Down
6 changes: 6 additions & 0 deletions rancher2-vsphere-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ variable "node_template_ssh_user_group" {
default = null
}

variable "node_cloud_config" {
type = string
description = "Global setting for the contents of cloud-config YAML file which will be applied on all cluster nodes; these contents should be defined in the root module either inline using the `heredoc` synthax, or loaded from a file using Terraform's `file()` function. `cloud_config` parameter inside `node_spec` overrides this global setting on a per node role basis; if neither are set, cloud-config file for the node will have content of `#cloud-config` (which effectively makes it empty)"
default = null
}

variable "node_spec" {
description = "Specification of node templates for each of the node roles. Available roles are `control_plane`, `etcd`, `master` (consolidated `control_plane` and `etcd`), `worker` and `all_in_one` (`control_plane`, `etcd` and `worker` consolidate on one node, used for creating single node clusters). `node_spec` allows for specifying parameters such as vSphere template, datacenter, cluster etc. on a node role basis. If these parameters are set both through `node_spec` and globally through `node_*`, `node_spec` values will have precedence. As a minimum, each node role needs to have the following inputs set in `node_spec`: `num_vcpu` (VM number of vCPUs), `memory_gb` (VM memory in GB) and `disk_gb` (VM disk size in GB) - all other values can be inherited from global variables. Take a look at the `examples` directory for detailed synthax"
}
Expand Down

0 comments on commit 51a2a0e

Please sign in to comment.