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] 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