Skip to content

Commit

Permalink
feat: Add support to create a three node OCP cluster (#245)
Browse files Browse the repository at this point in the history
With this patch you can create a three node OCP cluster, without
dedicated compute nodes. You just need to uncomment the compute node
hostname definition in the config file (all.yaml).

---------

Signed-off-by: Klaus Smolin <smolin@de.ibm.com>
  • Loading branch information
smolin-de authored Mar 13, 2024
1 parent b440fe5 commit 582efb9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
10 changes: 9 additions & 1 deletion docs/run-the-playbooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ ansible-playbook playbooks/0_setup.yaml
* Watch Ansible as it completes the installation, correcting errors if they arise.
* To look at what tasks are running in detail, open the playbook or roles/role-name/tasks/main.yaml
* Alternatively, to run all the playbooks at once, start the master playbook by running this shell command:
```

```shell
ansible-playbook playbooks/site.yaml
```

* If the process fails in error, go through the steps in the [troubleshooting](troubleshooting.md) page.
* At the end of the the last playbook, follow the printed instructions for first-time login to the cluster.
* If you make cluster configuration changes in all.yaml file, like increased number of nodes or
a new bastion setup, after you have successfully installed a OCP cluster,
then you just need to run these playbooks in order:
* 5_setup_bastion.yaml
* 6_create_nodes.yaml
* 7_ocp_verification.yaml

## 0 Setup Playbook
### Overview
Expand Down
2 changes: 1 addition & 1 deletion roles/check_nodes/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ansible.builtin.shell: |
set -o pipefail
oc get nodes | grep "^{{ node | lower }}" | awk '{print $2}'
loop: "{{ env.cluster.nodes.control.hostname + env.cluster.nodes.compute.hostname }}"
loop: "{{ env.cluster.nodes.control.hostname + (env.cluster.nodes.compute.hostname | default([])) }}"
loop_control:
loop_var: node
register: cmd_output
Expand Down
2 changes: 1 addition & 1 deletion roles/create_compute_nodes/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
loop_control:
extended: yes
index_var: i
when: env.z.high_availability == False and inventory_hostname == env.z.lpar1.hostname
when: env.cluster.nodes.compute.hostname is defined and env.z.high_availability == False and inventory_hostname == env.z.lpar1.hostname

- name: Install CoreOS on infra nodes
tags: create_compute_nodes
Expand Down
23 changes: 23 additions & 0 deletions roles/haproxy/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
extended: yes
index_var: i

- name: Add control node information to 443 section in haproxy config, when no compute nodes are defined
tags: haproxy
lineinfile:
line: " server {{ env.cluster.nodes.control.hostname[i] }} {{ env.cluster.nodes.control.hostname[i] }}.{{ env.cluster.networking.metadata_name }}.{{ env.cluster.networking.base_domain }}:443 check inter 1s"
path: /etc/haproxy/haproxy.cfg
insertafter: "443 section"
with_sequence: start=0 end={{(env.cluster.nodes.control.hostname | length) - 1}} stride=1
loop_control:
extended: yes
index_var: i
when: env.cluster.nodes.compute.hostname is not defined

- name: Add compute node information to 443 section in haproxy config
tags: haproxy
lineinfile:
Expand All @@ -60,6 +72,17 @@
index_var: i
when: env.cluster.nodes.infra.hostname is defined

- name: Add control node information to 80 section in haproxy config, when no compute nodes are defined
tags: haproxy
lineinfile:
line: " server {{ env.cluster.nodes.control.hostname[i] }} {{ env.cluster.nodes.control.hostname[i] }}.{{ env.cluster.networking.metadata_name }}.{{ env.cluster.networking.base_domain }}:80 check inter 1s"
path: /etc/haproxy/haproxy.cfg
with_sequence: start=0 end={{(env.cluster.nodes.control.hostname | length) - 1}} stride=1
loop_control:
extended: yes
index_var: i
when: env.cluster.nodes.compute.hostname is not defined

- name: Add compute node information to 80 section in haproxy config
tags: haproxy
lineinfile:
Expand Down

0 comments on commit 582efb9

Please sign in to comment.