Managing Access and Cleanup

These procedures cover Alauda Container Platform Registry and namespace administration: image access, usage reporting, pruning, garbage collection, and recorded signature identity checks.

Task Index

TaskUse when
Grant namespace permissionsA user or service account needs pull, push, delete, or image catalog access in an image namespace.
View usageAn administrator needs image or ImageStream usage information.
Check recorded signature identityAn administrator needs to compare recorded identity claims or record an independently verified trust decision.
Prune imagesAn administrator needs to remove unused image metadata, Registry references, and corresponding unreferenced blobs online, or prune metadata only.
Run Registry garbage collectionAn administrator needs to collect unreferenced storage blobs, including old orphaned content, during separate maintenance.

Prerequisites

  • Registry is installed and available.
  • You have kubectl and ac access to the target cluster.
  • You have permission to create RoleBindings in the image namespace.
  • You can create cluster-scoped subjectaccessreviews.authorization.k8s.io to check another principal's permissions.
  • You have administrator permissions for usage reporting and cleanup. Online metadata pruning uses the Image API. Registry cleanup also requires Registry HTTP deletion and permission to execute commands in a verified Registry Pod. Full maintenance also requires permission to update Config/cluster and ImagePruner/cluster.
  • For signature identity checks, you can get cluster-scoped imagedigests.image.alauda.io. Saving conditions or removing embedded signatures also requires update on that resource.

Select the Operator-managed Registry backend before using the ac administrative commands:

ac config set-registry-mode modern

Expected result:

  • Subsequent ac Image API, pruning, garbage-collection, and signature commands use the Operator-managed Registry.

Grant Namespace Permissions

Grant pull permission to a user:

kubectl create rolebinding image-puller-user \
  --clusterrole=system:image-puller \
  --user='<username>' \
  -n '<image-namespace>'

Grant push permission to a user:

kubectl create rolebinding image-pusher-user \
  --clusterrole=system:image-pusher \
  --user='<username>' \
  -n '<image-namespace>'

Grant pull permission to a service account in another namespace:

kubectl create rolebinding image-puller-sa \
  --clusterrole=system:image-puller \
  --serviceaccount='<workload-namespace>:<serviceaccount-name>' \
  -n '<image-namespace>'
PlaceholderDescription
<username> or Kubernetes username to check. For a ServiceAccount, use system:serviceaccount:<workload-namespace>:<serviceaccount-name>.
<image-namespace>Namespace that owns the image repository, for example team-a.
<repository>ImageStream name in the image namespace, for example demo.
<workload-namespace>Namespace where the workload service account runs.
<serviceaccount-name>ServiceAccount name used by the workload that pulls the image.

Verify that the RoleBinding exists:

kubectl -n '<image-namespace>' get rolebinding

The Registry uses the following permissions in the image.alauda.io API group:

OperationTypical roleScopePermission
Pullsystem:image-pullerImage namespaceimagestreams/layers get
Pushsystem:image-pusherImage namespaceimagestreams/layers update
Delete image referencessystem:image-deleterImage namespaceimagestreamtags delete
Delete an OCI manifest by digestsystem:image-deleterImage namespace and repositoryimagestreamtags delete, checked against the repository name
Upload signatures through the Registrysystem:image-signature-writerImage namespace and repositoryimagesignatures create
Manage ImageSignature API recordssystem:image-signature-writerClusterimagesignatures create, delete
Read the image catalogsystem:image-registry-catalog-readerBound namespace, or cluster with a ClusterRoleBindingimagestreams list
Read Registry metricssystem:image-registry-metrics-readerClusterregistry/metrics get

Use a RoleBinding for namespace access. Direct ImageSignature API operations and metrics require cluster-scoped authorization. A ClusterRoleBinding grants that role across the cluster. The administrative signature command uses ImageDigest get and update permissions instead.

Catalog visibility follows pull permissions. A user with get on imagestreams/layers can see the permitted repositories without a separate catalog-reader grant. A namespace-wide grant covers the namespace; a grant for named repositories covers only those repositories. Catalog visibility does not grant push or delete permission.

Deleting a manifest by digest through the OCI Registry API can remove every current tag in that repository that points to the digest. The authorization check uses the repository name. ImageStreamTag API deletion targets a single <repository>:<tag> resource name. These namespace grants do not authorize deletion of cluster-scoped ImageDigest objects. To remove one tag, use Delete image references.

The system:image-pruner ClusterRole is reserved for the Operator-managed pruner ServiceAccount. It is not a namespace access role. Manual pruning and garbage collection require the corresponding administrator permissions.

Check effective pull access with a SubjectAccessReview that matches the Registry authorization check. Run the command in the target cluster's kubeconfig context to preserve any API proxy path. --validate=false bypasses the client schema check when OpenAPI validation blocks the request. Authentication and RBAC still apply:

kubectl create --validate=false -f - -o jsonpath='{.status.allowed}{"\n"}' <<'EOF'
{
  "apiVersion": "authorization.k8s.io/v1",
  "kind": "SubjectAccessReview",
  "spec": {
    "user": "<username>",
    "groups": ["system:authenticated"],
    "resourceAttributes": {
      "namespace": "<image-namespace>",
      "verb": "get",
      "group": "image.alauda.io",
      "resource": "imagestreams/layers",
      "name": "<repository>"
    }
  }
}
EOF

Supply the principal's actual groups when testing group-based grants. For a ServiceAccount, include system:serviceaccounts, system:serviceaccounts:<workload-namespace>, and system:authenticated. For push access, repeat the request with verb set to update.

The command prints status.allowed. A true result means the supplied identity and resource attributes are authorized. A false result does not establish whether the account exists. For details, repeat with -o json and inspect status.reason and status.evaluationError.

For Registry signature uploads, reuse the request above with these resourceAttributes:

{
  "namespace": "<image-namespace>",
  "verb": "create",
  "group": "image.alauda.io",
  "resource": "imagesignatures",
  "name": "<repository>"
}

For direct cluster-scoped ImageSignature API creation, omit the namespace and repository name:

{
  "verb": "create",
  "group": "image.alauda.io",
  "resource": "imagesignatures"
}

Repeat that review with verb set to delete to check direct signature deletion. To check the administrative signature command, use resource: imagedigests, name: sha256:<digest>, and verb: get or verb: update, still without a namespace.

registry/metrics is an RBAC-only subresource absent from Image API discovery. Check its cluster-scoped permission directly:

kubectl create --validate=false -f - -o jsonpath='{.status.allowed}{"\n"}' <<'EOF'
{
  "apiVersion": "authorization.k8s.io/v1",
  "kind": "SubjectAccessReview",
  "spec": {
    "user": "<username>",
    "groups": ["system:authenticated"],
    "resourceAttributes": {
      "verb": "get",
      "group": "image.alauda.io",
      "resource": "registry",
      "subresource": "metrics"
    }
  }
}
EOF

Use the principal's actual groups as above. The command prints true when the supplied identity has the metrics reader permission in the target cluster.

View Usage

Show metadata-derived storage totals and Pod usage for ImageDigest objects:

ac adm top images

Show metadata-derived totals for ImageStreams:

ac adm top imagestreams

Expected result:

  • The command prints usage rows for ImageDigest or ImageStream resources visible to the current administrator.

Interpret the columns as follows:

  • Image STORAGE sums recorded layer sizes and child-manifest sizes. ImageStream STORAGE sums those values once per distinct referenced image digest, including tag history.
  • Shared layers are counted again across different images. These totals do not measure physical backend usage or predict reclaimable bytes.
  • Image USAGE counts Pods with matching digest references in the queried Pod scope. It does not include every workload or external consumer. METADATA counts recorded layer and child-manifest entries; ImageStream LAYERS sums those counts per referenced image.
  • Image IMAGESTREAMTAG lists the namespace/stream:tag references that contribute the row, comma-separated when several match. ImageStream IMAGES counts the distinct image digests the stream references.

Check Recorded Signature Identity

The command compares identity claims recorded on an ImageDigest object. It does not verify signature cryptography, signer trust, or image integrity. Independently verify the signature under your signing policy before recording a trust decision.

Check the recorded identity without modifying the object:

ac adm verify-image-signature 'sha256:<digest>' \
  --expected-identity=registry.example.com/team-a/demo:latest
PlaceholderDescription
sha256:<digest>Digest of the ImageDigest object to verify. Use ac get imagedigests.image.alauda.io or ac get imagestreamtags <name>:<tag> -n <namespace> -o wide to find the digest.
registry.example.com/team-a/demo:latestExpected signed image identity. Use the image reference required by your signing policy.

Expected result: the command reports a matching recorded identity and leaves the ImageDigest unchanged.

Before changing signatures, back up the ImageDigest metadata to a protected local file:

umask 077
ac get imagedigests.image.alauda.io 'sha256:<digest>' -o yaml > image-signatures-backup.yaml

Warning: --save replaces the matching signatures' conditions with Trusted=True and ForImage=True. An identity match alone does not justify trust. Use this option only after independent verification, with cluster-scoped ImageDigest update permission and a metadata backup.

Record the independently verified trust decision:

ac adm verify-image-signature 'sha256:<digest>' \
  --expected-identity=registry.example.com/team-a/demo:latest \
  --save

Verify the saved condition:

ac get imagedigests.image.alauda.io 'sha256:<digest>' -o yaml

Expected result:

  • Matching signature records contain Trusted=True and ForImage=True conditions.

To roll back --save, restore the affected signatures' previous conditions from the metadata backup.

Warning: --remove-all immediately clears all embedded signature data from the ImageDigest object without a confirmation prompt. The Registry cannot undo this operation. Keep a metadata backup and confirm the records are no longer required before running it.

Remove the embedded records and verify that signatures is empty:

ac adm verify-image-signature 'sha256:<digest>' --remove-all
ac get imagedigests.image.alauda.io 'sha256:<digest>' -o yaml

Prune Images

Warning: Confirmed online pruning permanently removes selected image metadata and eligible Registry data. Keep metadata and storage backups, and review a dry run with the same retention, endpoint, and exclusion flags before adding --confirm. There is no automatic rollback.

Pruning requires platform-level access. The account must be allowed to get configs.imageregistry.operator.alauda.io/cluster; otherwise the command exits before scanning. Namespace image roles such as system:image-deleter are not sufficient.

For the Operator-managed Registry, ac adm prune images uses the Image API reference graph. A confirmed run without --prune-registry=true removes eligible Image API metadata only. With --prune-registry=true, it verifies the bound Service, Ready EndpointSlice, and Registry Pod before deleting eligible manifest references through authenticated HTTP requests. It then refreshes the graph and runs Registry garbage collection in that Pod. Online pruning does not automatically isolate writers. Use the separate maintenance procedure for standalone GC.

Manual defaults are independent of ImagePruner/cluster:

OptionDefault
--keep-younger-than60m
--keep-tag-revisions3 per tag
--prune-registryfalse

Explicit flags override these defaults. The examples retain five revisions per tag and images younger than 72 hours. Use the same policy for every preview and confirmation. The --all flag bypasses age and revision retention. Omit it when those limits must apply. It does not mean "apply the configured retention to all images."

The pruner scans Pod specifications in this cluster's Pods, Deployments, StatefulSets, DaemonSets, ReplicaSets, ReplicationControllers, Jobs, and CronJobs. Retained tag history, workload references, shared config and layer blobs, and image index children are protected by the observed graph. Consumers in other clusters or outside the platform are not scanned; exclude their repositories with --whitelist or retain the required images before proceeding.

For running containers, the pruner also checks resolved image IDs in regular, init, and ephemeral container statuses. This protects an older image while its workload tag advances. If the pruner cannot safely interpret a running container's image ID, it stops and identifies the affected Pod. Inspect that Pod's container runtime status before retrying.

The pruner refreshes metadata and workload checks during cleanup. These checks do not lock out writers or make deletion atomic with new references. Concurrent pushes, imports, retagging, or workload changes can introduce references after a check. Choose retention that covers image publication and deployment, and avoid reusing candidates while they are being deleted.

Prune Metadata and Reclaim Storage

Use online pruning while the Image API graph is available. The CLI verifies the Registry operand binding. A confirmed run with --prune-registry=true also verifies the Registry endpoint and Pod. If your workstation cannot reach the internal Service, add --registry-url with a verified, reachable endpoint and --certificate-authority with its PEM CA bundle to confirmed runs that include --prune-registry=true. See Configure client trust.

Preview online pruning:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=true

Expected result:

  • The dry run lists metadata candidates without deleting metadata, Registry references, or blobs. It does not run Registry garbage collection.

Run pruning after reviewing the dry-run output:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=true \
  --confirm

Verify pruning:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=true

Expected result:

  • A follow-up dry run no longer lists the completed targets. Check command errors separately; an empty metadata candidate list alone does not prove storage cleanup finished.

Verify that retained ImageStream tags still resolve. Fully pull or extract critical images from a fresh client directory to check layer availability; metadata inspection alone cannot verify this. Resolve failures before another cleanup run.

Exclude repositories from pruning with --whitelist. The flag takes regular expressions and can be repeated:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=true \
  --whitelist='^cpaas-system/.*'

After reviewing the preview, confirm the same policy:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=true \
  --whitelist='^cpaas-system/.*' \
  --confirm

Prune Metadata Only

Set --prune-registry=false explicitly to update ImageStream references and remove eligible ImageDigest objects without deleting Registry references or blobs. Preview and confirm the same policy:

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=false

ac adm prune images \
  --keep-tag-revisions=5 \
  --keep-younger-than=72h \
  --prune-registry=false \
  --confirm

Metadata-only pruning uses the bound operand namespace, including a custom installation namespace, and does not require an available Registry Service.

It leaves storage manifest and layer references intact. Standalone garbage collection follows those references and can retain blobs after Image API metadata is gone. To reclaim storage, choose online pruning while the graph still exists. Later garbage collection cannot recover missing manifest unlink information.

If a previous online run failed, resolve the error and rerun the same policy with --prune-registry=true.

Retry a Failed Online Cleanup

Cleanup does not store a journal or blob inventory in a ConfigMap. With --prune-registry=true, the CLI verifies the bound Registry Service, Ready EndpointSlice, and Pod before unlinking eligible manifest references. It then refreshes the Image API graph, removes eligible metadata, and runs Registry garbage collection in that Pod. If manifest deletion fails, the run stops before removing the corresponding metadata.

If a command or scheduled Job fails, resolve the error, review another dry run, and retry with the same Registry endpoint, retention, and exclusion options. Kubernetes retries scheduled Jobs according to backoffLimit. Each retry rebuilds the current image and workload view. Do not edit or create an image-pruner-state ConfigMap to bypass a failed cleanup. Standalone garbage collection cannot reconstruct manifest links that were never removed, and it does not scan Image API metadata for retention candidates.

For scheduled pruning, see Configure scheduled image pruning. For recovery, restore both metadata and missing blobs from verified backups or republish from a trusted image source. Re-importing external metadata alone does not restore local blob data.

Run Registry Garbage Collection

ac adm registry gc performs full storage garbage collection in a Registry Pod, separately from ordinary online image pruning. It collects blobs no longer referenced by storage manifests, including old orphaned blobs. It does not use Image API retention to select images or unlink manifests. After metadata-only pruning, storage manifest links can still retain blobs during GC.

Warning: Confirmed blob reclamation is irreversible through the Registry. Full GC does not automatically stop writers. Prevent concurrent pushes, imports, and other Registry or Image API writes, enable read-only mode, and let in-flight writes finish before cleanup. Keep writers paused until verification completes. Restore missing data from a storage backup or a trusted image source.

Prepare the Maintenance Window

ac adm registry gc resolves the Registry operand namespace from the installation binding, even when Registry mode is selected explicitly. It uses the bound Service's complete selector to find a ready Registry Pod. The CLI refuses GC if it cannot verify the binding or find that Pod.

Use an administrator environment with kubectl, ac, curl, pull access to critical images, and enough disk space to extract them. Select and verify the access path before changing Registry settings:

  • For an external endpoint, use the verified HTTPS hostname from Exposing the Registry.
  • For an internal-only Registry, run from a maintenance environment with cluster network and DNS access. Use image-registry.cpaas-system.svc:5000 and the Registry service CA. You do not need to expose an external Ingress for cleanup.

An administrator can obtain the internal service CA from the operand namespace:

REGISTRY_NAMESPACE="$(kubectl get configs.imageregistry.operator.alauda.io cluster \
  -o jsonpath='{.metadata.annotations.imageregistry\.operator\.alauda\.io/operand-namespace}')" || exit 1
test -n "$REGISTRY_NAMESPACE" || {
  echo "The Registry operand namespace binding is missing." >&2
  exit 1
}
kubectl -n "$REGISTRY_NAMESPACE" get configmap serviceca \
  -o jsonpath='{.data.service-ca\.crt}' > registry-service-ca.crt

Set the endpoint and CA bundle for the selected path. The bundle must validate the endpoint's certificate chain and hostname. The examples pass it explicitly to curl. On Linux, SSL_CERT_FILE supplies it to each direct ac invocation. On macOS or Windows, add the CA to the client's system trust store before login and extraction. The environment variable does not replace that step. See Configure client trust.

REGISTRY_HOST='<registry-host>'
REGISTRY_URL="https://$REGISTRY_HOST"
REGISTRY_CA='/absolute/path/to/registry-ca.crt'

HTTP_STATUS="$(curl --silent --show-error --cacert "$REGISTRY_CA" \
  --output /dev/null --write-out '%{http_code}' "${REGISTRY_URL%/}/v2/")" || exit 1
case "$HTTP_STATUS" in
  200|401) ;;
  *) echo "Registry endpoint check failed: HTTP $HTTP_STATUS" >&2; exit 1 ;;
esac

REGISTRY_AUTH_DIR="$(mktemp -d "${TMPDIR:-/tmp}/registry-auth.XXXXXX")" || exit 1
REGISTRY_AUTH_FILE="$REGISTRY_AUTH_DIR/config.json"
SSL_CERT_FILE="$REGISTRY_CA" ac registry login \
  --registry "$REGISTRY_HOST" --to "$REGISTRY_AUTH_FILE" || exit 1
VERIFY_IMAGE="$REGISTRY_HOST/team-a/demo@sha256:<digest>"
VERIFY_PLATFORM=linux/amd64
ValueDescription
<registry-host>Verified external Registry host, or image-registry.cpaas-system.svc:5000 from a maintenance environment that can reach it. Do not include a scheme or path.
REGISTRY_CAAbsolute path to a PEM CA bundle that validates the selected endpoint. For the internal service, use the registry-service-ca.crt file obtained above. For a public certificate, you can use the workstation's system CA bundle.
VERIFY_IMAGEImmutable reference to an image that must survive cleanup. Replace team-a/demo and the hexadecimal <digest> with a critical repository and digest.
VERIFY_PLATFORMPlatform required by consumers, in os/arch form.

A 401 response is the expected unauthenticated challenge. It confirms reachability but does not establish permission. Extract the image to establish a baseline before entering maintenance:

VERIFY_DIR="$(mktemp -d "${TMPDIR:-/tmp}/registry-verify.XXXXXX")" || exit 1
SSL_CERT_FILE="$REGISTRY_CA" ac image extract "$VERIFY_IMAGE" \
  --filter-by-os="$VERIFY_PLATFORM" \
  --path "/:$VERIFY_DIR" \
  --registry-config="$REGISTRY_AUTH_FILE" || exit 1

Expected result: the image filesystem is extracted successfully. Repeat with every critical image and required platform, each time using a fresh directory. Resolve any failure before cleanup. Keep these endpoint, authentication, and verification variables in the same shell throughout the maintenance procedure.

Record the current settings and suspend scheduled pruning to prevent overlapping cleanup:

REGISTRY_READ_ONLY="$(kubectl get configs.imageregistry.operator.alauda.io cluster \
  -o jsonpath='{.spec.readOnly}')" || exit 1
REGISTRY_READ_ONLY="${REGISTRY_READ_ONLY:-false}"
REGISTRY_PRUNER_SUSPENDED="$(kubectl get imagepruners.imageregistry.operator.alauda.io cluster \
  -o jsonpath='{.spec.suspend}')" || exit 1
REGISTRY_PRUNER_SUSPENDED="${REGISTRY_PRUNER_SUSPENDED:-false}"
kubectl patch imagepruners.imageregistry.operator.alauda.io cluster \
  --type=merge -p '{"spec":{"suspend":true}}' || exit 1
kubectl -n "$REGISTRY_NAMESPACE" wait cronjob/image-pruner \
  --for=jsonpath='{.spec.suspend}'=true --timeout=300s || exit 1
kubectl -n "$REGISTRY_NAMESPACE" get jobs -l created-by=image-pruner \
  -o custom-columns='NAME:.metadata.name,CONDITION:.status.conditions[*].type'

Wait until every existing pruner Job has a terminal Complete or Failed condition. Suspending the schedule does not stop an existing Job. Pause workflows that change images and prevent other clients from writing throughout garbage collection and verification. Read-only mode alone does not block direct backend writers or finish requests already in flight.

Collect Already Unlinked Blobs

Use standalone GC after storage manifest links have been removed. It does not unlink manifests based on Image API retention. After stopping writers, follow the enabling steps in Enable read-only mode. Wait for the requested Config generation to reconcile and the Registry rollout to complete; keep read-only mode enabled until blob verification finishes. Do not run metadata pruning in this mode; Image API writes and deletes are blocked.

Preview storage garbage collection:

ac adm registry gc

Expected result:

  • The command previews eligible unreferenced blobs and does not delete them.

Run registry garbage collection only after reviewing the preview:

ac adm registry gc --confirm

Expected result:

  • The command removes eligible unreferenced blobs from Registry storage.

Verify blob availability before restoring the previous settings.

Verify Blob Availability

Repeat the baseline check with the same immutable image reference and platform. Extract into a fresh directory to read the image layers without a local runtime cache:

VERIFY_DIR="$(mktemp -d "${TMPDIR:-/tmp}/registry-verify.XXXXXX")" || exit 1
SSL_CERT_FILE="$REGISTRY_CA" ac image extract "$VERIFY_IMAGE" \
  --filter-by-os="$VERIFY_PLATFORM" \
  --path "/:$VERIFY_DIR" \
  --registry-config="$REGISTRY_AUTH_FILE" || exit 1

Expected result: extraction completes and writes the image filesystem to $VERIFY_DIR. Repeat for every critical image and required platform checked before cleanup. An ac image info inspection alone does not verify layer availability. Remove temporary authentication and image directories after verification and any investigation are complete.

Restore the Previous Settings

After successful verification, restore the recorded read-only setting while keeping writers isolated and scheduled pruning suspended:

REGISTRY_CONFIG_GENERATION="$(kubectl patch configs.imageregistry.operator.alauda.io cluster \
  --type=merge -p "{\"spec\":{\"readOnly\":$REGISTRY_READ_ONLY}}" \
  -o jsonpath='{.metadata.generation}')" || exit 1
kubectl wait configs.imageregistry.operator.alauda.io/cluster \
  --for=jsonpath='{.status.observedGeneration}'="$REGISTRY_CONFIG_GENERATION" --timeout=300s || exit 1
kubectl wait configs.imageregistry.operator.alauda.io/cluster \
  --for=condition=Degraded=false --timeout=300s || exit 1
kubectl wait configs.imageregistry.operator.alauda.io/cluster \
  --for=condition=Progressing=false --timeout=300s || exit 1
EXPECTED_REGISTRY_READ_ONLY=''
if [ "$REGISTRY_READ_ONLY" = true ]; then
  EXPECTED_REGISTRY_READ_ONLY='{enabled: true}'
fi
REGISTRY_TEMPLATE_READ_ONLY="$(kubectl -n "$REGISTRY_NAMESPACE" get deployment image-registry \
  -o jsonpath='{.spec.template.spec.containers[?(@.name=="registry")].env[?(@.name=="REGISTRY_STORAGE_MAINTENANCE_READONLY")].value}')" || exit 1
test "$REGISTRY_TEMPLATE_READ_ONLY" = "$EXPECTED_REGISTRY_READ_ONLY" || {
  echo "The Registry Pod template does not match the recorded read-only setting." >&2
  exit 1
}
kubectl -n "$REGISTRY_NAMESPACE" rollout status deployment/image-registry --timeout=300s || exit 1

kubectl -n "$REGISTRY_NAMESPACE" get pods -l app.kubernetes.io/name=image-registry \
  -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.deletionTimestamp}{"\t"}{.spec.containers[?(@.name=="registry")].env[?(@.name=="REGISTRY_STORAGE_MAINTENANCE_READONLY")].value}{"\n"}{end}'

Continue only when Pods are present, no row has a deletion timestamp, and every read-only value matches EXPECTED_REGISTRY_READ_ONLY (empty when the recorded setting was false). Repeat this check until all old Pods have terminated. Resume writers only after successful verification and only if the Registry is intended to be writable. After maintenance, restore the recorded schedule state:

kubectl patch imagepruners.imageregistry.operator.alauda.io cluster \
  --type=merge -p "{\"spec\":{\"suspend\":$REGISTRY_PRUNER_SUSPENDED}}" || exit 1
kubectl -n "$REGISTRY_NAMESPACE" wait cronjob/image-pruner \
  --for=jsonpath='{.spec.suspend}'="$REGISTRY_PRUNER_SUSPENDED" --timeout=300s || exit 1

Verify that the rollout completes and both settings match their recorded values. An originally suspended schedule must remain suspended. If any check fails, keep the maintenance controls and schedule suspension in place while investigating.