Use ACS Commit to create a container image from a container running in a Pod and push the image to a specified container image repository.
Limitations
Ensure that you have the required permissions to push images. When you configure
imagePullSecretsfor a Pod or Commit custom resource, the specified secret must grant permissions to push images.Submit a Commit only after the Pod is in the Running state.
Only one Commit can be running for the same Pod at a time. After a Commit reaches a terminal state (Succeeded or Failed), submit another Commit.
After a Commit enters the Running state, the task cannot be interrupted by deleting the Commit.
When a Commit completes (reaches Succeeded or Failed status), the cluster retains its metadata for 7 days by default, up to a maximum of 30 days. After this period, the cluster automatically deletes the Commit's metadata. This process does not delete the image artifact.
The tag of the image to push must comply with community specifications for images and can be up to 128 characters in length.
Prerequisites
An ACS cluster or an ACK managed cluster is created.
Install the ack-agent-sandbox-controller component from the Add-ons page of the cluster.
Step 1: Create example resources
Add the image.alibabacloud.com/enable-commit: "true" annotation to the pod to enable the container image commit feature.
Create an
imagePullSecretfor pushing the image.kubectl create secret docker-registry push-secret --docker-server=<acrurl> --docker-username=<username> --docker-password=<password>Replace the placeholders in the command with actual values.
<acrurl>: The address of the image repository, such as***-***-registry.cn-hangzhou.cr.aliyuncs.com. In a PPU scenario, ensure that the image repository is accessible over the VPC network.<username>: the username used to log on to the image repository.<password>: the password used to log on to the image repository.
Create an example Pod.
CPU
apiVersion: v1 kind: Pod metadata: labels: alibabacloud.com/compute-class: performance alibabacloud.com/compute-qos: default alibabacloud.com/acs: 'true' annotations: image.alibabacloud.com/enable-commit: "true" name: commit-01 namespace: default spec: imagePullSecrets: - name: push-secret containers: - image: registry.openanolis.cn/openanolis/nginx:1.14.1-8.6 name: main resources: limits: cpu: "4" memory: 8Gi ephemeral-storage: "40Gi" # Declare the storage space as 40 GiB. You can adjust this value based on your actual needs. requests: cpu: "4" memory: 8Gi ephemeral-storage: "40Gi" # Declare the storage space as 40 GiB. You can adjust this value based on your actual needs.GPU
For information about the
alibabacloud.com/gpu-model-seriesconfiguration, see GPU model series supported by ACS.apiVersion: v1 kind: Pod metadata: labels: # Set compute-class to gpu. alibabacloud.com/compute-class: gpu alibabacloud.com/gpu-model-series: <The GPU model series supported by ACS, such as GU8TF> alibabacloud.com/compute-qos: default annotations: image.alibabacloud.com/enable-commit: "true" name: commit-01 namespace: default spec: imagePullSecrets: - name: push-secret containers: - image: registry.openanolis.cn/openanolis/nginx:1.14.1-8.6 name: main resources: limits: cpu: "4" memory: 8Gi nvidia.com/gpu: 1 ephemeral-storage: "40Gi" # Declare the storage space as 40 GiB. You can adjust this value based on your actual needs. requests: cpu: "4" memory: 8Gi nvidia.com/gpu: 1 ephemeral-storage: "40Gi" # Declare the storage space as 40 GiB. You can adjust this value based on your actual needs.
Step 2: Push image using Commit
A Commit is a namespace-scoped resource. The Commit resource object must be in the same namespace as its target Pod.
Create a
Commitresource object.apiVersion: agents.kruise.io/v1alpha1 kind: Commit metadata: name: commit-01 namespace: default spec: podName: commit-01 containerName: main image: ***-***-registry.cn-hangzhou.cr.aliyuncs.com/commit/nginx:commit-01 ttl: 72h imagePullSecrets: - name: push-secretThe following table describes the key parameters:
Parameter
Description
spec.podNameThe target Pod for the commit operation.
spec.containerNameThe target container within the Pod.
spec.imageThe destination for the image artifact. If an image with the same name and tag already exists, it will be overwritten.
spec.ttlThis is an optional parameter with a default value of 7 days. It configures automatic garbage collection (GC) to delete completed Commit resource objects. Parameter format examples:
30h,30m,30s.spec.status.phaseThe execution status of the Commit. Valid values:
An empty string (
"") indicates the default status.Pending: The commit is queued.Running: The commit request is being processed.Succeeded: The commit completed and the image was pushed.Failed: The commit request failed. Check the Kubernetes event for the error details.
Step 3: Verify the results
Check the status of the
Commit.kubectl get commit commit-01 -oyamlIn the command output, a
status.phaseofSucceededindicates that the image was pushed.apiVersion: agents.kruise.io/v1alpha1 kind: Commit metadata: annotations: alibabacloud.com/instance-id: acs-8vb00987g6o23un9gvs6 creationTimestamp: "2025-12-05T02:23:12Z" finalizers: - agents.kruise.io/commit generation: 1 name: commit-01 namespace: default resourceVersion: "22050" uid: c13ae054-a029-46e3-bfc5-011db3fd5d9f spec: containerName: main image: ***-***-registry.cn-hangzhou.cr.aliyuncs.com/commit/nginx:commit-01 podName: commit-01 ttl: 72h status: commitID: *** completionTime: "2025-12-05T02:23:15Z" phase: Succeeded startTime: "2025-12-05T02:23:12Z"Check the image information.
View the push result in the image repository.