Skip to content

Commit

Permalink
add gc add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
sluetze committed May 15, 2023
1 parent a84d63d commit cec888e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
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 }}: ""

0 comments on commit cec888e

Please sign in to comment.