Configure the Platform Default Mirror Repository for External Network Access to the Business Cluster
When creating or connecting a cluster on the platform, the nodes in the cluster need to access the platform’s default repository (configured during global deployment) to obtain the required component images.
If the nodes in the cluster cannot access the platform’s default repository, you can refer to this document to configure an address that the cluster can access for the platform’s default repository. By setting the repository parameter during cluster creation or connection, ensure that the nodes in the cluster can access the platform’s default repository through this address.
Example Scenario
During platform deployment, global is deployed using an intranet address. During platform operation, when it is necessary to connect an external network cluster (e.g., public cloud Kubernetes cluster, other edge clusters) to Platform Management, the cluster can only access the platform’s default repository through the public network to obtain the required component images.
In this scenario, you can refer to the solution provided in this document to add an external network-accessible address to the platform’s default repository. This allows external network clusters to access the platform’s default repository while avoiding the cost and risk of redeploying the platform or modifying the platform repository address.
Prerequisites
Please prepare in advance the Domains that the cluster can access, the IP address pointed to by the domain, and a valid certificate for the corresponding domain.
Note:
-
The domain must not be the same as the platform access address.
-
Ensure that the port of this domain (HTTPS port, i.e., the platform access address port) can forward traffic to all control nodes of global.```
Configure certificates and routing rules for the platform default mirror repository
-
Copy the valid certificate of the domain to any control node of global.
-
Execute the following command to create a certificate on the platform that contains the valid certificate of the domain (registry-address.tls).
kubectl create secret tls registry-address.tls --cert=<domain certificate name> --key=<domain certificate key> -n kube-systemExample:
kubectl create secret tls registry-address.tls --cert=custom.crt --key=custom.key -n kube-systemTip: After successfully creating the certificate, monitor the validity period of the registry-address.tls certificate in the kube-system namespace of global. Please replace the certificate before it expires.
-
On any control node of global, execute the following command to create an ingress rule.
REGISTRY_DOMAIN_NAME=<www.registry.com> #Needs to be replaced with a domain name that is accessible to the cluster cat << EOF | kubectl create -f - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: nginx.ingress.kubernetes.io/backend-protocol: HTTPS name: registry-address namespace: kube-system labels: service_name: registry spec: rules: - host: $REGISTRY_DOMAIN_NAME http: paths: - backend: service: name: registry port: number: 443 path: /v2/ pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /v2/_catalog pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /v2/.+/tags/list pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /v2/.+/manifests/[A-Za-z0-9_+.-:]+ pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /v2/.+/blobls/[A-Za-z0-9-:]+ pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /v2/.+/blobls/uploads/[A-Za-z0-9-:]+ pathType: ImplementationSpecific - backend: service: name: registry port: number: 443 path: /auth/token pathType: ImplementationSpecific tls: - secretName: registry-address.tls hosts: - $REGISTRY_DOMAIN_NAME EOFTip: When you get a display like the one in the following example, the ingress was created successfully.
... created -
On one of the master nodes of global, execute the following command to check for the existence of the Registry’s Service resource
kubectl -n kube-system get svc |grep registryIf the Service does not exist, use the following command to create the Service.
cat << EOF | kubectl create -f - apiVersion: v1 kind: Service metadata: labels: name: registry service_name: registry name: registry namespace: kube-system spec: ports: - protocol: TCP port: 443 targetPort: 60080 selector: component: registry type: ClusterIP EOF -
Please replace the
<repository domain>parameter with the actual domain name and test pulling images by logging into the repository using the domain name from any node.crictl pull <repository domain>/automation/qaimages:helloworldor
docker pull <repository domain>/automation/qaimages:helloworld
Configure the mirror repository for the business cluster
After configuring the certificate and routing rules for the repository, the repository is ready. Depending on the scenario, you can add this repository to a cluster when creating/connecting it or configure the repository for an already created cluster.
-
When creating/connecting a cluster on the platform, follow the instructions below for configuration:
-
Repository: Select
External. -
IP Address/Domain and Port: Use the custom domain and port (HTTPS port) of the custom address.
-
Username and Password: Use the username and password of the platform’s default repository.
-
-
If the cluster was created using the platform’s default repository, follow these instructions to configure the repository for the existing cluster:
Add an
annotationto all nodes in the cluster, adding key-value pairscpaas.io/registry-addressl:<repository access address, e.g., https://publicIP:11443>.