Skip to content

add how to cleanup cluster image registry#130

Open
zhhray wants to merge 2 commits intomainfrom
feat/Admin_How_to_Cleanup_Cluster_Image_Registry
Open

add how to cleanup cluster image registry#130
zhhray wants to merge 2 commits intomainfrom
feat/Admin_How_to_Cleanup_Cluster_Image_Registry

Conversation

@zhhray
Copy link
Contributor

@zhhray zhhray commented Mar 23, 2026

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive administrator guide for pruning unused container images from the cluster image registry.
    • Documents the pruning workflow (dry-run vs confirm), supported retention and exclusion options, optional registry garbage collection, and registry endpoint selection.
    • Includes step-by-step commands, CronJob automation examples with RBAC, multiple scheduling scenarios, verification steps, sample logs, cleanup instructions, and troubleshooting guidance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Walkthrough

Adds a new administrator documentation page describing how to prune ACP’s internal cluster image registry using ac adm prune images, including CLI options, dry-run vs confirm behavior, optional registry garbage collection, CronJob automation examples, verification commands, and troubleshooting guidance.

Changes

Cohort / File(s) Summary
Administrator Guide
docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md
New comprehensive guide covering ac adm prune images usage and flags (--keep-younger-than, --keep-tag-revisions, --all, --whitelist, --confirm, --prune-registry, --registry-url), step-by-step dry-run and confirm workflows, CronJob YAML templates and RBAC examples for automation, verification commands, sample logs, cleanup commands, and a troubleshooting table.

Sequence Diagram(s)

(omitted — changes are documentation-only and do not introduce new runtime control flow)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Ait 65906 #125 — Documentation on cleanup and registry workflows related to image pruning and MinIO backup/restore procedures.

Suggested labels

documentation

Suggested reviewers

  • jiazhiguang
  • tyzhou111

Poem

🐰 I nibble old images, one by one,

Dry-runs first, then pruning when done.
CronJobs hum softly, logs gleam in light,
The registry breathes easier — tidy and bright. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding documentation for cleaning up a cluster image registry, which matches the new documentation file added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/Admin_How_to_Cleanup_Cluster_Image_Registry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md (1)

14-14: Tighten wording for readability

Line 14 reads awkwardly (internal registry of cluster). A small wording cleanup improves clarity.

💡 Suggested patch
-This document provides a practical and production-ready approach for cleaning images in ACP's internal registry of cluster and automating the cleanup process with `CronJob`.
+This document provides a practical, production-ready approach for cleaning images in ACP's internal cluster registry and automating cleanup with `CronJob`.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md`
at line 14, Summary: The sentence "This document provides a practical and
production-ready approach for cleaning images in ACP's internal registry of
cluster and automating the cleanup process with `CronJob`." is awkwardly worded;
change it to improve clarity. Replace "internal registry of cluster" with "the
cluster's internal registry" (or "the internal registry of the cluster") and add
a comma before "and automating" so the sentence reads smoothly, e.g., "This
document provides a practical, production-ready approach for cleaning images in
ACP's cluster internal registry, and automating the cleanup process with
`CronJob`." Locate and edit the sentence in the document (the line starting with
"This document provides a practical...") to apply this wording fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md`:
- Around line 256-257: The scenarios reference serviceAccountName: ac-tester-sa
but the runnable RBAC creates ac-images-pruner-sa, causing SA-not-found errors;
update each scenario YAML that sets serviceAccountName (instances containing
"serviceAccountName: ac-tester-sa") to use "ac-images-pruner-sa" instead so they
match the RBAC setup (replace all occurrences of ac-tester-sa with
ac-images-pruner-sa in the CronJob/Job scenario blocks).
- Line 385: The docs use the CronJob name ac-prune-images-daily when collecting
logs, but you must use an actual Job instance name; replace the example command
"ac logs job/ac-prune-images-daily -n cpaas-system" with a two-step approach:
list Jobs to find the real instance (e.g., run "kubectl get jobs -n
cpaas-system" and locate the job whose name starts with
ac-prune-images-daily-<timestamp>) and then run "kubectl logs
job/<actual-job-name> -n cpaas-system" (use the actual Job name that starts with
ac-prune-images-daily) to collect logs.

---

Nitpick comments:
In
`@docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md`:
- Line 14: Summary: The sentence "This document provides a practical and
production-ready approach for cleaning images in ACP's internal registry of
cluster and automating the cleanup process with `CronJob`." is awkwardly worded;
change it to improve clarity. Replace "internal registry of cluster" with "the
cluster's internal registry" (or "the internal registry of the cluster") and add
a comma before "and automating" so the sentence reads smoothly, e.g., "This
document provides a practical, production-ready approach for cleaning images in
ACP's cluster internal registry, and automating the cleanup process with
`CronJob`." Locate and edit the sentence in the document (the line starting with
"This document provides a practical...") to apply this wording fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 877ab4b4-a49f-4c21-a730-ccd011c1cf29

📥 Commits

Reviewing files that changed from the base of the PR and between cfa09a1 and efb28a7.

📒 Files selected for processing (1)
  • docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md (1)

475-476: ⚠️ Potential issue | 🟠 Major

Use a real Job instance name for log collection

Line 475 uses the CronJob name as a Job name. CronJob runs create generated Job names, so this command can fail during normal execution. Replace with a two-step lookup + logs flow.

💡 Suggested patch
-ac logs job/ac-prune-images-daily -n cpaas-system
+ac get jobs -n cpaas-system --sort-by=.metadata.creationTimestamp
+# Pick the latest Job created by CronJob `ac-prune-images-daily`, then:
+ac logs job/<actual-job-name> -n cpaas-system
In Kubernetes CronJob behavior, what naming pattern do spawned Jobs use, and should logs be fetched via `kubectl logs job/<cronjob-name>` or via the actual generated Job name?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md`
around lines 475 - 476, The command uses the CronJob name directly
(ac-prune-images-daily) but CronJobs spawn Jobs with generated names like
ac-prune-images-daily-<timestamp|hash>, so replace the single-line "ac logs
job/ac-prune-images-daily -n cpaas-system" with a two-step lookup + logs flow:
first list or filter Jobs for the spawned name (e.g., use "kubectl get jobs -n
cpaas-system" and find entries starting with "ac-prune-images-daily-" or use a
label/selector for the CronJob), then run "kubectl logs job/<generated-job-name>
-n cpaas-system" to fetch logs from the actual Job instance; update any
references to ac-prune-images-daily accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md`:
- Around line 475-476: The command uses the CronJob name directly
(ac-prune-images-daily) but CronJobs spawn Jobs with generated names like
ac-prune-images-daily-<timestamp|hash>, so replace the single-line "ac logs
job/ac-prune-images-daily -n cpaas-system" with a two-step lookup + logs flow:
first list or filter Jobs for the spawned name (e.g., use "kubectl get jobs -n
cpaas-system" and find entries starting with "ac-prune-images-daily-" or use a
label/selector for the CronJob), then run "kubectl logs job/<generated-job-name>
-n cpaas-system" to fetch logs from the actual Job instance; update any
references to ac-prune-images-daily accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 705baf5c-4d3b-432a-95aa-d1e71d98997a

📥 Commits

Reviewing files that changed from the base of the PR and between efb28a7 and a929736.

📒 Files selected for processing (1)
  • docs/en/solutions/How_to_Cleanup_Alauda_Container_Platform_Cluster_Image_Registry_Administrator_Guide.md

Copy link

@vivindu-1213 vivindu-1213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

标题是不是可以稍微调整下?
Implementation Steps 算是 Quick Start: Manual Cleanup?
Configure Scheduled Cleanup with CronJob 定时执行 Automating Cleanup with CronJob?
Fully Runnable Example (Dry Run Recommended)”与“Scenario-Based Demos”内容感觉有点冗余...或者整合下,提供 Important Considerations & Best Practices?


### Step 3: Run confirmed cleanup with policy

Keep younger than 7 days, keep latest 5 revisions per repository, and exclude images in `cpaas-system` namespace, confirm the cleanup operation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep yonger than ...这句话的描述不太合适...语法也不是很顺畅


### Step 4: Trigger GC when required

Keep younger than 3 days, keep latest 3 revisions per repository, and trigger registry GC in non-dry-run mode, confirm the cleanup operation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@chinaran
Copy link
Contributor

文档中既有 ac 又有 kubectl 命令,是否需要统一成 ac 呢?

Check logs for details:

```bash
ac logs job/ac-prune-images-daily -n cpaas-system
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议修改 job 示例名称,job/ac-prune-images-daily 在上文示例中为 cronjob 名称。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants