Skip to content

Commit

Permalink
WIP: restructure sap_hypervisor_node_preconfigure
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Koenig committed Oct 26, 2023
1 parent 8ac014c commit 1000071
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 165 deletions.
2 changes: 1 addition & 1 deletion roles/sap_hypervisor_node_preconfigure/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

- name: SAP certified hypervisor node preconfigure - Include Handler Tasks for {{ sap_hypervisor_node_platform }}
- name: hypervisor node preconfigure - Include Handler Tasks for {{ sap_hypervisor_node_platform }}
ansible.builtin.include_tasks: "{{ role_path }}/handlers/platform/{{ sap_hypervisor_node_platform }}/main.yml"
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
kubernetes.io/hostname: {{ __sap_hypervisor_node_preconfigure_register_worker_name }}
machineconfiguration.openshift.io/role: {{ __sap_hypervisor_node_preconfigure_register_worker_name }}
name: 99-kargs-{{ __sap_hypervisor_node_preconfigure_register_worker_name }}
machineconfiguration.openshift.io/role: worker
name: 99-kargs-worker
spec:
config:
ignition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
index_var: __sap_hypervisor_node_preconfigure_register_worker_network_nr
when: __sap_hypervisor_node_preconfigure_register_worker.networks is defined

- name: "Create MCP for {{ __sap_hypervisor_node_preconfigure_register_worker.name }}"
kubernetes.core.k8s:
template:
path: "mcp.yml.j2"
state: present

- name: Pause so cluster can process config
ansible.builtin.pause:
minutes: 1
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,37 @@
fail_msg: No nodes found that match configuration provided in sap_hypervisor_node_preconfigure_cluster
success_msg: Configured nodes found

# Determine available memory on first worker node.
# This amount will be used for all nodes, so make sure all have an identical amount.
- name: Get worker name
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_worker_name:
"{{ __sap_hypervisor_node_preconfigure_register_nodes[0]['metadata']['labels']['kubernetes.io/hostname'] }}"

- name: Get memory of worker node
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_worker_memory_gb:
"{{ (__sap_hypervisor_node_preconfigure_register_nodes[0]['status']['capacity']['memory'] | replace('Ki', '') | int / 1048576) | int }}"

- name: Check if host has minimal amount of memory (96Gb)
ansible.builtin.assert:
that: __sap_hypervisor_node_preconfigure_register_worker_memory_gb|int >= 96
fail_msg: "Not enough memory on node {{ __sap_hypervisor_node_preconfigure_register_worker_name }}"
success_msg: "Enough memory on node {{ __sap_hypervisor_node_preconfigure_register_worker_name }}"
ignore_errors: "{{ sap_hypervisor_node_preconfigure_ignore_minimal_memory_check }}"

# calculate memory to be allocated as hugepages
# if system < 512GB memory use 32GB as upper boundary, 64GB otherwise as upper boundary
- name: Calculate amount of hugepages to reserve (host memory < 512 Gb)
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_worker_reserved_hugepages: "{{ __sap_hypervisor_node_preconfigure_register_worker_memory_gb | int - sap_hypervisor_node_preconfigure_hypervisor_reserved_ram_host_lt_512 }}"
when: __sap_hypervisor_node_preconfigure_register_worker_memory_gb|int < 512

- name: Calculate amount of hugepages to reserve (host memory >= 512 Gb)
ansible.builtin.set_fact:
__sap_hypervisor_node_preconfigure_register_worker_reserved_hugepages: "{{ __sap_hypervisor_node_preconfigure_register_worker_memory_gb | int - sap_hypervisor_node_preconfigure_hypervisor_reserved_ram_host_ge_512 }}"
when: __sap_hypervisor_node_preconfigure_register_worker_memory_gb|int >= 512

# - meta: end_play

- name: Include prepare
Expand Down Expand Up @@ -66,3 +97,4 @@
- name: Include local storage creation (HPP)
ansible.builtin.include_tasks: install-hpp.yml
when: sap_hypervisor_node_preconfigure_install_hpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
---
- name: Include configure kargs
ansible.builtin.include_tasks: configure-kargs-per-node.yml
with_items: "{{ __sap_hypervisor_node_preconfigure_register_nodes }}"
loop_control:
loop_var: __sap_hypervisor_node_preconfigure_register_worker
index_var: __sap_hypervisor_node_preconfigure_register_worker_nr

- name: Include configure worker
ansible.builtin.include_tasks: configure-worker-node.yml
with_items: "{{ sap_hypervisor_node_preconfigure_cluster_config.workers }}"
Expand All @@ -24,8 +17,7 @@
labels:
custom-kubelet: cpumanager-enabled


- name: Create kubletconfig for cpumanager worker
- name: Create kubletconfig for cpumanager worker with CPUs reserved for kubernetes
when: sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus is defined
kubernetes.core.k8s:
state: absent
Expand All @@ -44,37 +36,31 @@
reservedSystemCPUs: "{{ sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus }}"

- name: Create kubletconfig for cpumanager worker
when: sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus is defined
when: sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus is not defined
kubernetes.core.k8s:
state: present
definition:
apiVersion: machineconfiguration.openshift.io/v1
kind: KubeletConfig
metadata:
name: cpumanager-enabled
machineconfiguration.openshift.io/role: worker
spec:
machineConfigPoolSelector:
matchLabels:
custom-kubelet: cpumanager-enabled
kubeletConfig:
cpuManagerPolicy: static
cpuManagerReconcilePeriod: 5s
reservedSystemCPUs: "{{ sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus }}"

- name: Create kubletconfig for cpumanager worker
when: sap_hypervisor_node_preconfigure_cluster_config.worker_kubernetes_reserved_cpus is not defined
- name: Personalize template
ansible.builtin.template:
src: 99-kargs-worker.yml.j2
dest: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir.path }}/99-kargs-worker.yml.j2"
mode: "0644"

- name: Enable hugepages
kubernetes.core.k8s:
state: present
definition:
apiVersion: machineconfiguration.openshift.io/v1
kind: KubeletConfig
metadata:
name: cpumanager-enabled
machineconfiguration.openshift.io/role: worker
spec:
machineConfigPoolSelector:
matchLabels:
custom-kubelet: cpumanager-enabled
kubeletConfig:
cpuManagerPolicy: static
cpuManagerReconcilePeriod: 5s
src: "{{ __sap_hypervisor_node_preconfigure_register_tmpdir.path }}/99-kargs-worker.yml.j2"

0 comments on commit 1000071

Please sign in to comment.