Skip to content

Commit

Permalink
To Automate Node Labels
Browse files Browse the repository at this point in the history
Fixes: ocp-power-automation#418
Signed-off-by: Aishwarya Kamat <aishwarya.kamat@ibm.com>
  • Loading branch information
aishwaryabk committed Jun 6, 2022
1 parent 200595f commit 740eab3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/var.tfvars-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ rhcos_kernel_options = []
rhcos_kernel_options = ["slub_max_order=0","loglevel=7"]
```

This is a Map of [Node labels](https://kubernetes.io/docs/reference/labels-annotations-taints) and its values. Some of the well known labels such as region, zone and instance-type are automated. More custom labels can be added using the `node_labels` map variable.
Note that this will be applied after the cluster is installed and all the nodes are in `Ready` status.
```
node_labels = {}
```
- Example 1
```
node_labels = {"failure-domain.beta.kubernetes.io/region": "mon","failure-domain.beta.kubernetes.io/zone": "mon01"}
```

These are NTP specific variables that are used for time-synchronization in the OpenShift cluster.
```
chrony_config = true
Expand Down
7 changes: 7 additions & 0 deletions modules/5_install/install.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ locals {
password = uuid()
}

node_labels = {
"topology.kubernetes.io/region" = var.region
"topology.kubernetes.io/zone" = var.zone
"node.kubernetes.io/instance-type" = var.system_type
}

local_registry = {
enable_local_registry = var.enable_local_registry
registry_image = var.local_registry_image
Expand Down Expand Up @@ -114,6 +120,7 @@ locals {
fips_compliant = var.fips_compliant
rhcos_pre_kernel_options = var.rhcos_pre_kernel_options
rhcos_kernel_options = var.rhcos_kernel_options
node_labels = var.node_labels == "" ? local.node_labels : merge(local.node_labels, var.node_labels)
chrony_config = var.chrony_config
chrony_config_servers = var.chrony_config_servers
chrony_allow_range = var.cidr
Expand Down
5 changes: 5 additions & 0 deletions modules/5_install/templates/install_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ rhcos_pre_kernel_options: [%{ for opt in rhcos_pre_kernel_options ~}"${opt}",%{

rhcos_kernel_options: [%{ for opt in rhcos_kernel_options ~}"${opt}",%{ endfor ~}]

node_labels:
%{ for key,value in node_labels ~}
${key}: "${value}"
%{ endfor ~}

setup_squid_proxy : ${setup_squid_proxy}
squid_acl_localnet:
- acl localnet src ${squid_source_range}
Expand Down
2 changes: 2 additions & 0 deletions modules/5_install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ variable "dns_forwarders" {
variable "service_instance_id" {}
variable "region" {}
variable "zone" {}
variable "system_type" {}
variable "name_prefix" {}
variable "node_prefix" {}

Expand Down Expand Up @@ -87,6 +88,7 @@ variable "log_level" {}
variable "ansible_extra_options" {}
variable "rhcos_pre_kernel_options" {}
variable "rhcos_kernel_options" {}
variable "node_labels" {}
variable "chrony_config" { default = true }
variable "chrony_config_servers" {}

Expand Down
2 changes: 2 additions & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module "install" {
service_instance_id = var.service_instance_id
region = var.ibmcloud_region
zone = var.ibmcloud_zone
system_type = var.system_type
cluster_domain = module.nodes.cluster_domain
cluster_id = local.cluster_id
name_prefix = local.name_prefix
Expand Down Expand Up @@ -161,6 +162,7 @@ module "install" {
ansible_extra_options = var.ansible_extra_options
rhcos_pre_kernel_options = var.rhcos_pre_kernel_options
rhcos_kernel_options = var.rhcos_kernel_options
node_labels = var.node_labels
chrony_config = var.chrony_config
chrony_config_servers = var.chrony_config_servers
upgrade_image = var.upgrade_image
Expand Down
1 change: 1 addition & 0 deletions var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ use_zone_info_for_names = true # If set it to false, the zone info would not be
#dns_forwarders = "1.1.1.1; 9.9.9.9"
#rhcos_pre_kernel_options = []
#rhcos_kernel_options = []
#node_labels = {}
#chrony_config = true
#chrony_config_servers = [ {server = "0.centos.pool.ntp.org", options = "iburst"}, {server = "1.centos.pool.ntp.org", options = "iburst"} ]

Expand Down
8 changes: 7 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ variable "install_playbook_repo" {
variable "install_playbook_tag" {
type = string
description = "Set the branch/tag name or commit# for using ocp4-playbooks repo"
default = "2ca4346f740429fdcd31cc346a6ae91e79746843"
default = "777878939449c3cfa140a773ad8e71a708858e0c"
# Checkout level for var.install_playbook_repo which is used for running ocp4 installations steps
}

Expand Down Expand Up @@ -361,6 +361,12 @@ variable "rhcos_kernel_options" {
default = []
}

variable "node_labels" {
type = map(string)
description = "List of node labels for the cluster nodes"
default = {}
}

variable "chrony_config" {
type = bool
description = "Set to true to setup time synchronization and setup chrony. Default: true"
Expand Down

0 comments on commit 740eab3

Please sign in to comment.