Quick Start
This document will help you quickly understand how to create a Git Connector and use it for securely cloning repositories without directly handling credentials.
TOC
Introduction
Applicable Scenarios
The Git Connector allows you to perform code cloning operations securely by:
- Managing credentials centrally rather than hardcoding them in workloads
- Automatically injecting authentication during the cloning process
- Providing controlled access to private repositories across teams
This approach is particularly useful for:
- CI/CD pipelines requiring secure access to private repositories
- Teams sharing repository access without sharing credentials
- Environments requiring centralized management of Git credentials
Estimated Reading Time
15 minutes
Notes
- The Git connector uses CSI driver integration to inject Git credentials securely.
- Connector-generated configurations expire after 30 minutes.
Prerequisites
- Kubernetes cluster with Connectors system installed (Operator, Core and Git components). See the Installation Guide for details on installing these components.
- kubectl configured to communicate with your cluster
- Git repository with valid credentials (username/password or token)
- Basic knowledge of Kubernetes resources
Process Overview
Steps to Operate
Step 1: Create Namespace
Create a dedicated namespace for this demonstration:
Step 2: Create Git Credentials and Connector
Create both the Secret containing Git credentials and the Git Connector resource. For more detailed information about creating and configuring connectors, please refer to the Connectors Quick Start Guide.
Verify that the connector is in "Ready" status:
The output should show:
Step 3: Create a Clone Job
Create a job that uses the connector to clone the repository:
Key parameters:
connector.name: The name of your Git connectorconfiguration.names: Set to "gitconfig", which references a specific configuration template defined in the Git ConnectorClass. This template is used to generate the ".gitconfig" file with the appropriate settings for authentication and URL rewriting.mountPath: Must be set to "/root/" because the container runs as the root user, and Git will look for configuration in the "/root/.gitconfig" path
Step 4: Verify Operation
Check the job's logs to confirm the repository was successfully cloned:
You should see the Git clone operation completing successfully without any authentication errors.
Expected Results
After successfully completing all steps, you will see:
-
A Git connector in "Ready" status:
-
A successful Git clone operation in the job logs:
How It Works
The Git Connector works by:
- Replacing the original Git repository URL with a proxy service URL
- Injecting authentication information into requests to the proxy service
- The proxy service adding the necessary credentials when forwarding requests to the Git server
To examine the generated configuration:
View the generated configuration:
Example output:
Troubleshooting
If your clone operation fails, check the following:
-
Connector Status: Ensure the connector is in "Ready" state:
-
RBAC Permissions: Verify the RoleBinding is correctly configured.
-
Job Configuration:
- Ensure the volume mount path is correct (/root/)
- Verify the repository URL matches what's configured in the connector
Next Steps
After successfully cloning your first repository using the Git Connector, you can:
- Integrate this approach into your CI/CD pipelines
- Use the connector in other Git operations like push, pull, and fetch
- Create connectors for different Git services