From 0805c1fdfd315eae176c6d342191164b03fd58fd Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Mon, 15 May 2023 16:09:12 +0200 Subject: [PATCH 1/6] add post-install-add-on tag --- ansible/roles/openshift-4-cluster/tasks/create.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible/roles/openshift-4-cluster/tasks/create.yml b/ansible/roles/openshift-4-cluster/tasks/create.yml index 1a42ca86..efab5b4c 100644 --- a/ansible/roles/openshift-4-cluster/tasks/create.yml +++ b/ansible/roles/openshift-4-cluster/tasks/create.yml @@ -137,4 +137,6 @@ - name: Include post installation tasks ansible.builtin.include_tasks: post-install.yml - tags: post-install + tags: + - post-install + - post-install-add-ons From b20cbea9f9d33f544a739ab7ec0cc98dabfa0ef6 Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Mon, 15 May 2023 16:10:05 +0200 Subject: [PATCH 2/6] add tags to add-on include --- .../roles/openshift-4-cluster/tasks/post-install-add-ons.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml index 1919e03a..4f2897e1 100644 --- a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml +++ b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml @@ -1,6 +1,10 @@ --- - name: Include vars of stuff.yaml into the 'stuff' variable (2.2). ansible.builtin.include_vars: "{{ playbook_dir }}/../add-ons.yml" + tags: + - post-install + - add-ons + - post-install-add-ons - name: "Handle post_install_add_ons (include_role)" ansible.builtin.include_role: From a84d63dca25cc142ff63e566689e9a9fdd1f9270 Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Mon, 15 May 2023 16:19:41 +0200 Subject: [PATCH 3/6] add tags to imported tasks, to ensure they get executed --- .../roles/openshift-4-cluster/tasks/post-install-add-ons.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml index 4f2897e1..deb8cc91 100644 --- a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml +++ b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml @@ -10,6 +10,11 @@ ansible.builtin.include_role: name: "{{ item.name }}" tasks_from: "{{ item.tasks_from | default('main.yml') }}" + apply: + tags: + - post-install + - add-ons + - post-install-add-ons tags: - post-install - add-ons From cec888ee4264943f10100571341ddf7481659ee7 Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Mon, 15 May 2023 14:50:40 +0000 Subject: [PATCH 4/6] add gc add-on --- .../add-on-roles/garbagecollection/README.md | 12 +++++++++++ .../garbagecollection/defaults/main.yml | 3 +++ .../garbagecollection/meta/main.yml | 20 +++++++++++++++++++ .../garbagecollection/tasks/post-install.yml | 18 +++++++++++++++++ ...ter-garbagecollection-machineconfig.yml.j2 | 14 +++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 ansible/add-on-roles/garbagecollection/README.md create mode 100644 ansible/add-on-roles/garbagecollection/defaults/main.yml create mode 100644 ansible/add-on-roles/garbagecollection/meta/main.yml create mode 100644 ansible/add-on-roles/garbagecollection/tasks/post-install.yml create mode 100644 ansible/add-on-roles/garbagecollection/templates/cluster-garbagecollection-machineconfig.yml.j2 diff --git a/ansible/add-on-roles/garbagecollection/README.md b/ansible/add-on-roles/garbagecollection/README.md new file mode 100644 index 00000000..c53e9ad1 --- /dev/null +++ b/ansible/add-on-roles/garbagecollection/README.md @@ -0,0 +1,12 @@ +# garbagecollection + +this add-on adds a KubeConfig Machineconfiguration as per https://cloud.redhat.com/blog/image-garbage-collection-in-openshift +This can be used to have a tighter garbagecollection for the images. This may be useful in environments with low disk volume + +## Role Variables + +see [defaults](defaults/main.yml) + +## License + +Apache 2.0 \ No newline at end of file diff --git a/ansible/add-on-roles/garbagecollection/defaults/main.yml b/ansible/add-on-roles/garbagecollection/defaults/main.yml new file mode 100644 index 00000000..5bf98728 --- /dev/null +++ b/ansible/add-on-roles/garbagecollection/defaults/main.yml @@ -0,0 +1,3 @@ +garbagecollection_high_treshold_percent: 66 +garbagecollection_low_treshold_percent: 50 +garbagecollection_minimum_age: "5m30s" \ No newline at end of file diff --git a/ansible/add-on-roles/garbagecollection/meta/main.yml b/ansible/add-on-roles/garbagecollection/meta/main.yml new file mode 100644 index 00000000..2200d5de --- /dev/null +++ b/ansible/add-on-roles/garbagecollection/meta/main.yml @@ -0,0 +1,20 @@ +galaxy_info: + author: Steffen Luetzenkirchen + description: configures tight garbage collection for ocp4 + company: Red Hat + + license: Apache-2.0 + + min_ansible_version: 2.9 + + platforms: + - name: OpenShift + versions: + - all + galaxy_tags: + [] + +dependencies: + [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. \ No newline at end of file diff --git a/ansible/add-on-roles/garbagecollection/tasks/post-install.yml b/ansible/add-on-roles/garbagecollection/tasks/post-install.yml new file mode 100644 index 00000000..3f82ff55 --- /dev/null +++ b/ansible/add-on-roles/garbagecollection/tasks/post-install.yml @@ -0,0 +1,18 @@ +--- +- name: Ensure GarbageCollection machineconfig + delegate_to: localhost + kubernetes.core.k8s: + state: present + kubeconfig: "{{ k8s_kubeconfig }}" + host: "{{ k8s_host }}" + ca_cert: "{{ k8s_ca_cert }}" + client_cert: "{{ k8s_client_cert }}" + client_key: "{{ k8s_client_key }}" + definition: "{{ lookup('template', 'templates/cluster-garbagecollection-machineconfig.yml.j2') }}" + vars: + role: "{{ loop_role }}" + with_items: + - master + - worker + loop_control: + loop_var: loop_role \ No newline at end of file diff --git a/ansible/add-on-roles/garbagecollection/templates/cluster-garbagecollection-machineconfig.yml.j2 b/ansible/add-on-roles/garbagecollection/templates/cluster-garbagecollection-machineconfig.yml.j2 new file mode 100644 index 00000000..fd2aa302 --- /dev/null +++ b/ansible/add-on-roles/garbagecollection/templates/cluster-garbagecollection-machineconfig.yml.j2 @@ -0,0 +1,14 @@ +apiVersion: machineconfiguration.openshift.io/v1 +kind: KubeletConfig +metadata: + labels: + machineconfiguration.openshift.io/role: {{ role }} + name: 60-{{ role }}-kubeconfig-tight-garbage +spec: + kubeletConfig: + imageGCHighThresholdPercent: {{ garbagecollection_high_treshold_percent }} + imageGCLowThresholdPercent: {{ garbagecollection_low_treshold_percent }} + imageMinimumGCAge: "{{ garbagecollection_minimum_age }} " + machineConfigPoolSelector: + matchLabels: + pools.operator.machineconfiguration.openshift.io/{{ role }}: "" \ No newline at end of file From 285142fd45fac196524af8337555ced75c5777cc Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Tue, 16 May 2023 08:24:01 +0000 Subject: [PATCH 5/6] fix lint errors --- ansible/add-on-roles/garbagecollection/defaults/main.yml | 2 +- ansible/add-on-roles/garbagecollection/meta/main.yml | 2 +- ansible/add-on-roles/garbagecollection/tasks/post-install.yml | 2 +- ansible/roles/openshift-4-cluster/tasks/create.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible/add-on-roles/garbagecollection/defaults/main.yml b/ansible/add-on-roles/garbagecollection/defaults/main.yml index 5bf98728..4d997c51 100644 --- a/ansible/add-on-roles/garbagecollection/defaults/main.yml +++ b/ansible/add-on-roles/garbagecollection/defaults/main.yml @@ -1,3 +1,3 @@ garbagecollection_high_treshold_percent: 66 garbagecollection_low_treshold_percent: 50 -garbagecollection_minimum_age: "5m30s" \ No newline at end of file +garbagecollection_minimum_age: "5m30s" diff --git a/ansible/add-on-roles/garbagecollection/meta/main.yml b/ansible/add-on-roles/garbagecollection/meta/main.yml index 2200d5de..6edfcb8c 100644 --- a/ansible/add-on-roles/garbagecollection/meta/main.yml +++ b/ansible/add-on-roles/garbagecollection/meta/main.yml @@ -17,4 +17,4 @@ galaxy_info: dependencies: [] # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file + # if you add dependencies to this list. diff --git a/ansible/add-on-roles/garbagecollection/tasks/post-install.yml b/ansible/add-on-roles/garbagecollection/tasks/post-install.yml index 3f82ff55..d59e62ad 100644 --- a/ansible/add-on-roles/garbagecollection/tasks/post-install.yml +++ b/ansible/add-on-roles/garbagecollection/tasks/post-install.yml @@ -15,4 +15,4 @@ - master - worker loop_control: - loop_var: loop_role \ No newline at end of file + loop_var: loop_role diff --git a/ansible/roles/openshift-4-cluster/tasks/create.yml b/ansible/roles/openshift-4-cluster/tasks/create.yml index efab5b4c..7fad1354 100644 --- a/ansible/roles/openshift-4-cluster/tasks/create.yml +++ b/ansible/roles/openshift-4-cluster/tasks/create.yml @@ -137,6 +137,6 @@ - name: Include post installation tasks ansible.builtin.include_tasks: post-install.yml - tags: + tags: - post-install - post-install-add-ons From eaa5ece6d2d25cc9773c7206340095fb483a5b4d Mon Sep 17 00:00:00 2001 From: sluetze <13255307+sluetze@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:53:52 +0000 Subject: [PATCH 6/6] removed add-ons tag --- .../roles/openshift-4-cluster/tasks/post-install-add-ons.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml index deb8cc91..41d55429 100644 --- a/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml +++ b/ansible/roles/openshift-4-cluster/tasks/post-install-add-ons.yml @@ -3,7 +3,6 @@ ansible.builtin.include_vars: "{{ playbook_dir }}/../add-ons.yml" tags: - post-install - - add-ons - post-install-add-ons - name: "Handle post_install_add_ons (include_role)" @@ -13,10 +12,8 @@ apply: tags: - post-install - - add-ons - post-install-add-ons tags: - post-install - - add-ons - post-install-add-ons with_items: "{{ post_install_add_ons | default ([]) }}"