OCI Connector
The OCI Connector is a platform-agnostic connector that allows you to connect to any OCI Registry, such as Docker Hub, Harbor, etc. You can use the OCI Connector to securely access private OCI repositories in CI/CD pipelines or perform OCI operations in containerized workloads without providing credentials. Additionally, you can centrally manage OCI access configurations, avoiding the need to duplicate OCI credential configurations in each namespace.
This document will describe:
- Access requirements for OCI Registry
- How to create an OCI Connector based on the OCI Connector type
- The proxy and configuration capabilities of the OCI Connector
TOC
OCI Registry RequirementsCreating an OCI Connector Based on OCI Connector Typespec.connectorClassNamedescriptionAddressAuthenticationUsing Token-based AuthenticationToken Permissions RequiredProxy and ConfigurationProxyProxy AddressForward ProxyReverse ProxyMoreOCI Registry Requirements
The OCI Registry to be accessed must meet the following conditions:
-
Interface implementation requirements:
- Must implement at least the interfaces defined in the opencontainers/distribution-spec v1.0 specification
- Must be able to pass the conformance tests of the distribution-spec
-
Authentication method requirements:
- Must implement Token-based authentication and comply with the CNCF Distribution Token Authentication Specification
Creating an OCI Connector Based on OCI Connector Type
Here's how to create a basic OCI Connector:
spec.connectorClassName
Use the constant value oci.
description
You can add descriptive information to the OCI Connector through the annotations field.
cpaas.io/description: Description of the OCI Connector.
For example:
Address
The spec.address specifies the access address of the OCI Registry, for example: https://index.docker.io.
Authentication
The OCI Connector supports the following authentication types:
tokenAuth: Token-based authentication (optional)- Corresponding credential type:
cpaas.io/distribution-registry-token, this type of credential is used for the authentication process defined in the CNCF Distribution Token Authentication Specification, and the credential must provideusernameandpasswordinformation.
- Corresponding credential type:
Using Token-based Authentication
For example:
If the target OCI Registry does not require authentication, you can omit the authentication information. The configuration example is as follows:
Token Permissions Required
The required permissions for the configured token depend on how you intend to use it in your Pods/Pipelines.
For example:
- Image pull operations: If you only need to pull images using this connector, the token only require read permissions for the target repositories.
- Image pull and push operations: If you need to push images using this connector, the token must have both read and write permissions for the target repositories. In other words, the token should allow you to both pull from and push to the registry.
For security best practices, we recommend creating token with minimal required permissions. When additional privileges are needed, create separate Connectors with more privileged secret and use namespace isolation to control which users can access each Connector.
Proxy and Configuration
To provide clients with the ability to access OCI repositories without credentials, the OCI Connector type offers a proxy server to automatically inject authentication information.
Clients with access to the connector can use this proxy server to access OCI repositories without configuring credentials on the client side.
To simplify usage, the OCI Connector type provides configuration information that can be mounted into Pods via CSI. In the Pod, when performing OCI operations, the proxy service can be automatically used to complete OCI operations.
Proxy
Proxy Address
When a Connector is created, the system will:
- Automatically create a Service for the proxy.
- Record the proxy address in the
status.proxy.httpAddressfield.
You can use this proxy address for image push and pull operations.
For example:
Forward Proxy
You can mount proxy information into Pods using CSI, and then use the proxy information through environment variables or configuration files.
Then, before executing container operations, use the proxy information through environment variables or configuration files.
Reverse Proxy
When using a reverse proxy, you need to modify the target image address to the proxy address.
Example: index.docker.io/test/abc:v1 → c-dockerhub-demo.default.svc.cluster.local/namespaces/oci-connector-demo/connectors/oci-connector/test/abc:v1
and mount the credential configuration files into the Pod and configure the proxy address in insecure-registries.
The OCI Connector created based on the OCI Connector type provides the following configurations:
docker-config: Configuration credentials required by OCI CLI like buildkit, buildah.
- Provides the
config.jsonconfiguration file. - Contains the authentication information required to access the proxy.
For example:
buildkitd: Configuration information required by the BuildKit Daemon.
- Provides the
buildkitd.tomlconfiguration file. - In the configuration file, the current connector will be set as
insecure-registriesby default.
For example:
You can mount this configuration information into Pods using connectors-csi, and combined with the proxy capability, achieve image push or pull operations in a secretless manner.