Skip to content

Commit

Permalink
To automate region and zone labels
Browse files Browse the repository at this point in the history
Signed-off-by: Aishwarya Kamat <aishwarya.kamat@ibm.com>
  • Loading branch information
aishwaryabk committed May 23, 2022
1 parent 89ad857 commit 4fd1295
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/install_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ fips_compliant: false

rsct_image: "quay.io/powercloud/rsct-ppc64le:latest"

set_node_labels: false

region: ""

zone: ""

system_type: ""

chronyconfig:
enabled: false
content:
Expand Down
9 changes: 8 additions & 1 deletion playbooks/roles/ocp-customization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use this to modify kernel tunables for nodes/pods via [tuned operator](https://d
Use this to deploy containerized version of [RSCT](https://www.ibm.com/support/knowledgecenter/SGVKBA) on every OCP node running on PowerVM infrastructure.
This is enabled by default when deploying OCP in PowerVM or PowerVS. Follow the instructions provided [here](/docs/rsct-deploy.md) to deploy RSCT on an existing OCP cluster.

**4. Automate setting of Node Labels

Use this to automate setting of Node Labels for Region, Zone and Instance-type on PowerVS. This refers to the [Well-known Labels document](https://kubernetes.io/docs/reference/labels-annotations-taints).

Requirements
------------

Expand All @@ -32,7 +36,10 @@ Role Variables
| sysctl_tuned_options | no | false | Set to true to apply sysctl options via tuned operator |
| powervm_rmc | no | true | Set to true to deploy RMC daemonset on Node with arch ppc64le |
| rsct_image | no | quay.io/powercloud/rsct-ppc64le:latest | Change to your own registry if you install without internet connection |

| set_node_labels | no | false | Set to true to set the node labels |
| region | no | "" | IBM Cloud PowerVS service instance region. eg. mon |
| zone | no | "" | IBM Cloud PowerVS service instance zone. eg. mon01 |
| system_type | no | "" | IBM Cloud PowerVS service instance zone. eg. mon01 |

If `sysctl_tuned_options` is true then the following variables are must and should be set in [vars/tuned.yaml](./vars/tuned.yaml)

Expand Down
4 changes: 4 additions & 0 deletions playbooks/roles/ocp-customization/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ rhcos_kernel_options: []
sysctl_tuned_options: false
powervm_rmc: true
rsct_image: "quay.io/powercloud/rsct-ppc64le:latest"
set_node_labels: false
region: ""
zone: ""
system_type: ""
4 changes: 4 additions & 0 deletions playbooks/roles/ocp-customization/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
loop:
- master
- worker

- name: Automate Node Labels
when: set_node_labels
import_tasks: node-label.yaml
17 changes: 17 additions & 0 deletions playbooks/roles/ocp-customization/tasks/node-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Get all Nodes
shell: "oc get nodes | awk '(NR>1) { print $1 }'"
register: node_names

- name: Automate Node labels
k8s:
state: present
kind: Node
name: "{{ item }}"
definition:
metadata:
labels:
topology.kubernetes.io/region: "{{ region }}"
topology.kubernetes.io/zone: "{{ zone }}"
node.kubernetes.io/instance-type: "{{ system_type }}"
with_items: "{{ node_names.stdout_lines }}"

0 comments on commit 4fd1295

Please sign in to comment.