You can use an image stored in an image repository to create workloads in an Alibaba Cloud Container Compute Service (ACS) cluster. Before you start, you need to push a container image to an image repository. We recommend that you use Container Registry to build, distribute, and manage container images.
Prerequisites
An image repository is created.
The ACS cluster is connected to the image repository.
All images are pulled through the network plane of the ACS cluster. You can pull all images available in the virtual private cloud (VPC) of the ACS cluster.
NoteTo images from a public address, make sure that the workload has Internet access. For more information, see Associate an exclusive EIP with a pod.
Specify an image
Use the console
Log on to the ACS console. Go to the Workloads page of the ACS cluster and create a Deployment, StatefulSet, Job, or CronJob. When you create the workload, you can use the following methods to select an image on the Container wizard page.
Method 1: Specify the name and tag of the image
You can manually specify the name and tag of an image. This method applies to all types of images.
Method 2: Select an existing image repository
Select an image when you create a workload
This method applies to all types of images:
Container Registry Enterprise Edition: You can specify a VPC endpoint or public endpoint. For more information, see Create a Container Registry Enterprise Edition instance.
Container Registry Personal Edition: You can specify a VPC endpoint or public endpoint. For more information, see Create a Container Registry Personal Edition instance.
Third-party Image Repository: Select an image repository that is accessible over the Internet.
If authentication is need to pull images, you must specify the Secret. You can specify the Secret when you create the workload or go to the Configurations > Secrets page of the ACS cluster to use an existing Secret.
The endpoint of the image repository must be the same as that in the image address. For example, to pull registry.cn-hangzhou.aliyuncs.com/acsRepo/privateImage:latest
, set the image repository to registry.cn-hangzhou.aliyuncs.com
.
Use YAML
When you use YAML to create an ACS pod, you can set Kubernetes fields to specify the image information.
Templates: ACK provides a variety of Kubernetes YAML templates. You can create a pod for a Magic Cube application based on the following YAML template.
kind: Pod
apiVersion: v1
metadata:
name: acs-pod
spec:
tolerations:
- operator: "Exists"
containers:
- name: acs-container
image: registry.cn-hangzhou.aliyuncs.com/acr-toolkit/cube:1.0
imagePullPolicy: Always
resources:
limits:
cpu: 1
memory: "1Gi"
requests:
cpu: 1
memory: "1Gi"
To ensure the validity of the image, the imagePullPolicy parameter in the pod configuration file is forcefully set to Always.
References
For more information about container images, see What is Container Registry?
For more information about how to pull images without using Secrets, see Pull images from a Container Registry instance without using Secrets.