-
Notifications
You must be signed in to change notification settings - Fork 286
Add policy for node image lifecycle management #558
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
Open
DustinTrap
wants to merge
6
commits into
open-cluster-management-io:main
Choose a base branch
from
DustinTrap:add-node-image-lifecycle-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6653bbf
Add policy for node image lifecycle management
DustinTrap bfb23a1
Fix CronJob image prune script
DustinTrap 826ab8f
Rewrite prune mechanism: CronJob → MachineConfig + systemd timer
DustinTrap f9dd3c4
Address CodeRabbit review: jq, ID normalization, FAILED counter
DustinTrap 762b219
Templatize KubeletConfig values with hub templates
DustinTrap 5d8a24e
Fix hub template ConfigMap: remove self-provisioning, clarify prereq
DustinTrap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
community/CM-Configuration-Management/policy-node-image-lifecycle.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: Policy | ||
| metadata: | ||
| name: policy-node-image-lifecycle | ||
| annotations: | ||
| policy.open-cluster-management.io/standards: NIST SP 800-53 | ||
| policy.open-cluster-management.io/categories: CM Configuration Management | ||
| policy.open-cluster-management.io/controls: CM-2 Baseline Configuration, SI-2 Flaw Remediation | ||
| spec: | ||
| remediationAction: inform | ||
| disabled: false | ||
| policy-templates: | ||
| - objectDefinition: | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: ConfigurationPolicy | ||
| metadata: | ||
| name: policy-kubelet-image-gc | ||
| spec: | ||
| remediationAction: inform | ||
| severity: medium | ||
| object-templates: | ||
| - complianceType: musthave | ||
| objectDefinition: | ||
| apiVersion: machineconfiguration.openshift.io/v1 | ||
| kind: KubeletConfig | ||
| metadata: | ||
| name: image-gc-policy | ||
| spec: | ||
| machineConfigPoolSelector: | ||
| matchLabels: | ||
| pools.operator.machineconfiguration.openshift.io/worker: "" | ||
| kubeletConfig: | ||
| imageGCHighThresholdPercent: 65 | ||
| imageGCLowThresholdPercent: 50 | ||
| imageMinimumGCAge: 5m | ||
| - objectDefinition: | ||
| apiVersion: policy.open-cluster-management.io/v1 | ||
| kind: ConfigurationPolicy | ||
| metadata: | ||
| name: policy-image-prune-timer | ||
| spec: | ||
| remediationAction: inform | ||
| severity: medium | ||
| object-templates: | ||
| - complianceType: musthave | ||
| objectDefinition: | ||
| apiVersion: machineconfiguration.openshift.io/v1 | ||
| kind: MachineConfig | ||
| metadata: | ||
| name: 99-worker-image-gc-prune | ||
| labels: | ||
| machineconfiguration.openshift.io/role: worker | ||
| spec: | ||
| config: | ||
| ignition: | ||
| version: 3.2.0 | ||
| storage: | ||
| files: | ||
| - path: /usr/local/bin/image-gc-prune.sh | ||
| mode: 0755 | ||
| contents: | ||
| source: data:text/plain;charset=utf-8;base64,IyEvYmluL2Jhc2gKIyBQcnVuZSB1bnJlZmVyZW5jZWQgY29udGFpbmVyIGltYWdlcyBvbGRlciB0aGFuIE1BWF9BR0VfREFZUwpNQVhfQUdFX0RBWVM9NwpOT1c9JChkYXRlICslcykKQ1VUT0ZGPSQoKE5PVyAtIE1BWF9BR0VfREFZUyAqIDg2NDAwKSkKUkVNT1ZFRD0wClNLSVBQRUQ9MApSRUZFUkVOQ0VEPTAKVU5QQVJTQUJMRT0wCgojIEJ1aWxk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MiICslcyAyPi9kZXYvbnVsbCB8fCBlY2hvIDApCgogIGlmIFsgIiRDUkVBVEVEX1RTIiAtZXEgMCBdOyB0aGVuCiAgICBVTlBBUlNBQkxFPSQoKFVOUEFSU0FCTEUgKyAxKSkKICAgIGNvbnRpbnVlCiAgZmkKCiAgaWYgWyAiJENSRUFURURfVFMiIC1sdCAiJENVVE9GRiIgXTsgdGhlbgogICAgY3JpY3RsIHJtaSAiJElNR19JRCIgMj4mMSB8fCB0cnVlCiAgICBSRU1PVkVEPSQoKFJFTU9WRUQgKyAxKSkKICBlbHNlCiAgICBTS0lQUEVEPSQoKFNLSVBQRUQgKyAxKSkKICBmaQpkb25lCgpsb2dnZXIgLXQgaW1hZ2UtZ2MtcHJ1bmUgInJlZmVyZW5jZWQ9JFJFRkVSRU5DRUQgcmVtb3ZlZD0kUkVNT1ZFRCBza2lwcGVkPSRTS0lQUEVEIHVucGFyc2FibGU9JFVOUEFSU0FCTEUiCg== | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| systemd: | ||
| units: | ||
| - name: image-gc-prune.service | ||
| enabled: false | ||
| contents: | | ||
| [Unit] | ||
| Description=Prune unreferenced container images older than 7 days | ||
| Wants=crio.service | ||
| After=crio.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/local/bin/image-gc-prune.sh | ||
| - name: image-gc-prune.timer | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Weekly container image prune | ||
|
|
||
| [Timer] | ||
| OnCalendar=Sun *-*-* 02:00:00 | ||
| RandomizedDelaySec=3600 | ||
| Persistent=true | ||
|
|
||
| [Install] | ||
| WantedBy=timers.target | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.