Harbor Connector
The Harbor connector is a platform-agnostic connector that you can use to connect to any Harbor registry.
You can use the Harbor Connector to securely perform container image operations in CICD pipelines, or use it in kubernetes workloads to perform image operations without credentials.
Additionally, you can centralize the management of Harbor access configurations across namespaces, avoiding the need to repeat the Harbor credentials in each namespace.
TOC
OverviewIntegration RequirementsCreating a simple Harbor connectorFields ReferenceConnector CapabilitiesAuthentication MethodsToken Permissions RequiredProxy and Configuration CapabilitiesProxy AddressForward ProxyReverse ProxyFurther ReadingOverview
This document covers:
- Integration Requirements: Prerequisites for target Harbor registries
- Creating Harbor connector
- Advanced Features: Proxy capabilities and configuration capabilities about Harbor connector
Integration Requirements
Harbor Registries Prerequisites
- Supports Harbor 2.x versions
Creating a simple Harbor connector
Here's how to create a basic Harbor Connector:
Fields Reference
spec.connectorClassName:
harbor (constant), specifies the ConnectorClass name for Harbor integration.
spec.address:
Target Harbor registry address, for example: https://harbor.example.com.
spec.auth(optional):
specifies the authentication method of the Harbor registry
-
spec.auth.name: should bebasicAuthfor Harbor connector. -
spec.auth.secretRef: specifies the secret that contains the authentication information of the Harbor registry, the secret should be created in the same namespace as the connector. If your Harbor registry does not require authentication, you can omit this field. secret type must bekubernetes.io/basic-auth.
Optional Metadata fields:
-
cpaas.io/description: Description information for the Harbor connector, for example:
Connector Capabilities
Authentication Methods
The Harbor Connector supports the following authentication methods:
- Basic Authentication: Username and password authentication, secret type must be
kubernetes.io/basic-auth.
if your Harbor registry does not require authentication, you can omit this field.
Token Permissions Required
The required permissions for the configured credential depend on how you intend to use it in your Pods/Pipelines.
For example:
- Image pull and push operations: If you need to pull and push images using this connector, the credentials must have both read and write permissions for the target Harbor registry.
- API operations: Configure permissions based on the operations you need to perform. When configuring credentials, ensure the account has permission to access user information (/users/current).
For security best practices, we recommend creating credentials 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 Capabilities
The Harbor Connector provides proxy capabilities to enable secure access to Harbor registries.
To enable clients to access Harbor registries without directly handling credentials, the Harbor ConnectorClass provides a proxy server that automatically injects authentication information.
Clients with access to the connector can use this proxy server to access Harbor registries without needing to configure credentials on the client side.
Proxy Address
When creating a Harbor connector, the system will automatically create a Service for proxying access to the Harbor registry.
The system will record the proxy address in the status.proxy.httpAddress field.
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: harbor.example.com/test/abc:v1 → c-harbor-connector.default.svc.cluster.local/namespaces/harbor-connector-demo/connectors/harbor-connector/test/abc:v1
Additionally, you need to mount the configuration files into the Pod and configure the proxy address in insecure-registries. The default configuration files buildkitd.toml and config.json are provided.
The OCI Connector created based on the OCI Connector type provides the following configurations:
config: Configuration information required by OCI CLI like buildkit, buildah, etc.
- 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: