Skip to main content

Git

Git connections enable integration with Git repositories across various platforms including GitHub, GitLab, Azure DevOps, and generic Git servers.

FieldDescriptionScheme
url*

Git repository URL

string

branch

Branch to clone (defaults to repository default branch)

string

certificate

SSH private key for authentication

EnvVar

connection

Connection name to use for credentials

string

destination

Local directory path for cloning (auto-generated if empty)

string

password

Password or access token for authentication

EnvVar

type

Type of Git service

github | gitlab | azure_devops | git

username

Username for authentication

EnvVar

You must specify connection or url but not both

Example

HTTPS with Personal Access Token

git-https-connection.yaml
apiVersion: v1
kind: Connection
metadata:
name: github-repo
namespace: default
spec:
type: git
url: https://github.com/organization/repository.git
username: github-user
password:
valueFrom:
secretKeyRef:
name: git-credentials
key: token
branch: main

SSH with Private Key

git-ssh-connection.yaml
apiVersion: v1
kind: Connection
metadata:
name: gitlab-repo
namespace: default
spec:
type: git
url: git@gitlab.com:organization/repository.git
certificate:
valueFrom:
secretKeyRef:
name: git-ssh-key
key: private-key
branch: develop

Authentication Methods

1. HTTPS with Username/Password

For HTTPS repositories using username and password or personal access tokens:

username: your-username
password:
valueFrom:
secretKeyRef:
name: git-credentials
key: password-or-token

2. SSH with Private Key

For SSH repositories using private key authentication:

certificate:
valueFrom:
secretKeyRef:
name: ssh-key
key: private-key

3. Connection Reference

Reference an existing connection for credentials:

connection: connection://git/my-git-connection

Supported Git Services

GitHub

type: github
url: https://github.com/owner/repo.git

GitLab

type: gitlab
url: https://gitlab.com/owner/repo.git

Azure DevOps

type: azure_devops
url: https://dev.azure.com/organization/project/_git/repository

Generic Git

type: git
url: https://git.example.com/repo.git

Use Cases

  • Source Code Access: Clone repositories for configuration management
  • GitOps Workflows: Sync configurations from Git repositories
  • CI/CD Integration: Access repositories for build and deployment processes
  • Configuration Storage: Store and retrieve configuration files from Git
  • Documentation: Access documentation stored in Git repositories

Best Practices

  • Access Tokens: Use personal access tokens instead of passwords for better security
  • SSH Keys: Prefer SSH keys for automated systems
  • Branch Strategy: Specify explicit branches for predictable behavior
  • Credential Management: Store credentials in Kubernetes secrets
  • Repository URLs: Use consistent URL formats for your Git service