Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gc add on #280

Merged
merged 7 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ansible/add-on-roles/garbagecollection/README.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions ansible/add-on-roles/garbagecollection/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
garbagecollection_high_treshold_percent: 66
garbagecollection_low_treshold_percent: 50
garbagecollection_minimum_age: "5m30s"
20 changes: 20 additions & 0 deletions ansible/add-on-roles/garbagecollection/meta/main.yml
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions ansible/add-on-roles/garbagecollection/tasks/post-install.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 }}: ""
4 changes: 3 additions & 1 deletion ansible/roles/openshift-4-cluster/tasks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
---
- name: Include vars of stuff.yaml into the 'stuff' variable (2.2).
ansible.builtin.include_vars: "{{ playbook_dir }}/../add-ons.yml"
tags:
- post-install
- post-install-add-ons

- name: "Handle post_install_add_ons (include_role)"
ansible.builtin.include_role:
name: "{{ item.name }}"
tasks_from: "{{ item.tasks_from | default('main.yml') }}"
apply:
tags:
- post-install
- post-install-add-ons
tags:
- post-install
- add-ons
- post-install-add-ons
with_items: "{{ post_install_add_ons | default ([]) }}"