As an administrator, you can configure how {product-title} performs garbage collection by creating a kubeletConfig
object for each Machine Config Pool.
Note
|
{product-title} supports only one |
You can configure any combination of the following:
-
soft eviction for containers
-
hard eviction for containers
-
eviction for images
For soft container eviction you can also configure a grace period before eviction.
-
Obtain the label associated with the static Machine Config Pool CRD for the type of node you want to configure. Perform one of the following steps:
-
View the Machine Config Pool:
$ oc describe machineconfigpool <name>
For example:
$ oc describe machineconfigpool worker apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfigPool metadata: creationTimestamp: 2019-02-08T14:52:39Z generation: 1 labels: custom-kubelet: small-pods (1)
-
If a label has been added it appears under
labels
.
-
-
If the label is not present, add a key/value pair:
$ oc label machineconfigpool worker custom-kubelet=small-pods
-
-
Create a Custom Resource (CR) for your configuration change.
Sample configuration for a container garbage collection CR:apiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig metadata: name: worker-kubeconfig (1) spec: machineConfigPoolSelector: matchLabels: custom-kubelet: small-pods (2) kubeletConfig: evictionSoft: (3) evictionSoft: memory.available: "500Mi" (4) nodefs.available: "10%" nodefs.inodesFree: "5%" imagefs.available: "15%" imagefs.inodesFree: "10%" evictionSoftGracePeriod: (5) memory.available: "1m30s" nodefs.available: "1m30s" nodefs.inodesFree: "1m30s" imagefs.available: "1m30s" imagefs.inodesFree: "1m30s" evictionHard: memory.available: "200Mi" nodefs.available: "5%" nodefs.inodesFree: "4%" imagefs.available: "10%" imagefs.inodesFree: "5%" evictionPressureTransitionPeriod: 0s (6) imageMinimumGCAge: 5m (7) imageGCHighThresholdPercent: 80 (8) imageGCLowThresholdPercent: 75 (9)
-
Name for the object.
-
Selector label.
-
Type of eviction:
EvictionSoft
andEvictionHard
. -
Eviction thresholds based on a specific eviction trigger signal.
-
Grace periods for the soft eviction. This parameter does not apply to
eviction-hard
. -
The duration to wait before transitioning out of an eviction pressure condition
-
The minimum age for an unused image before the image is removed by garbage collection.
-
The percent of disk usage (expressed as an integer) which triggers image garbage collection.
-
The percent of disk usage (expressed as an integer) to which image garbage collection attempts to free.
-
-
Create the object:
$ oc create -f <file-name>.yaml
For example:
oc create -f gc-container.yaml kubeletconfig.machineconfiguration.openshift.io/gc-container created
-
Verify that garbage collection is active. The Machine Config Pool you specified in the custom resource appears with
UPDATING
as 'true` until the change is fully implemented:$ oc get machineconfigpool NAME CONFIG UPDATED UPDATING master rendered-master-546383f80705bd5aeaba93 True False worker rendered-worker-b4c51bb33ccaae6fc4a6a5 False True