Third-party images are container images provided by organizations or individuals other than the official image repository and SWR image repository. These images typically contain custom applications, tools, or specific versions of OSs to meet particular service requirements. In a CCE standard or Turbo cluster, you can create workloads using third-party images pulled through secret authentication. For more information, see Using a Private Registry.
If third-party images are used, the CCE standard or Turbo cluster must be able to access the network environment where the third-party image repository is deployed. The network access types include:
Ensure sufficient bandwidth when pulling images over the Internet. Insufficient bandwidth may cause slow or failed image pulls.
To create a secret on the console and pull a third-party image to create a workload, follow these steps.
Parameter | Example Value | Description |
|---|---|---|
Name | test | Secret name. Enter up to 253 characters. Start and end with a lowercase letter or digit. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed. |
Secret Type | kubernetes.io/dockerconfigjson | Secret type. The value is fixed at kubernetes.io/dockerconfigjson, indicating that the secret is used for authentication when third-party images are pulled. |
Data | Image Repository Address: www.example.com Username: ssl Password: xxx |
|
If you do not specify a domain name when entering a third-party image address, for example, nginx:latest, the image will be pulled from docker.io by default. To specify the default image pull address, configure the Modify Image Repository Configuration parameter in the container engine configuration of the node pool.
kubectl create secret docker-registry test -n default --docker-server=www.example.com --docker-username=ssl --docker-password=xxx --docker-email=example@123.com
In the command, test indicates the secret name, default indicates the namespace where the secret is located, and other parameters are described in the following table.
Parameter | Example Value | Description |
|---|---|---|
docker-server | www.example.com | Enter the address of the third-party image repository. |
docker-username | ssl | Enter the username for accessing the third-party image repository. |
docker-password | xxx | Enter the password for accessing the third-party image repository. |
docker-email | example@123.com | Email address of the third-party image repository. This parameter is optional. |
Information similar to the following is displayed:
secret/test created
kubectl get secret
If the following information is displayed, the secret has been created:
NAME TYPE DATA AGEdefault-secret kubernetes.io/dockerconfigjson 1 41hpaas.elb cfe/secure-opaque 1 41htest kubernetes.io/dockerconfigjson 1 16s
vim deployment.yaml
The file content is as follows:
apiVersion: apps/v1kind: Deploymentmetadata:name: foonamespace: defaultspec:replicas: 1selector:matchLabels:app: foostrategy:type: RollingUpdatetemplate:metadata:labels:app: foospec:containers:- image: www.example.com/janedoe/awesomeapp:v1 # Third-party image pathimagePullPolicy: Alwaysname: fooimagePullSecrets:- name: test # Use the created secret for identity authentication when images are pulled.
If you do not specify a domain name when entering a third-party image address, for example, nginx:latest, the image will be pulled from docker.io by default. To specify the default image pull address, configure the Modify Image Repository Configuration parameter in the container engine configuration of the node pool.
kubectl create -f deployment.yaml
If information similar to the following is displayed, the workload is being created:
deployment.apps/foo created
kubectl get deployment
If all the pods of the workload are available, the workload has been created.
NAME READY UP-TO-DATE AVAILABLE AGEfoo 1/1 1 1 4m59s