Tekton supports authentication for Git repositories and Docker registries using Kubernetes Secrets. This guide shows you how to configure authentication for your TaskRuns and PipelineRuns.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tektoncd/pipeline/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Tekton supports authentication via Kubernetes first-class Secret types:- Git:
kubernetes.io/basic-authandkubernetes.io/ssh-auth - Docker:
kubernetes.io/basic-auth,kubernetes.io/dockercfg, andkubernetes.io/dockerconfigjson
- Git:
~/.gitconfigfile or~/.sshdirectory - Docker:
~/.docker/config.jsonfile
Tekton performs credential initialization within every Pod before executing any Steps, accessing each Secret and aggregating them into
/tekton/creds before copying or symlinking files to the user’s $HOME directory.Understanding Credential Selection
You must annotate each Secret to specify the domains for which Tekton can use the credentials. Tekton ignores all Secrets that are not properly annotated. A credential annotation key must begin withtekton.dev/git- or tekton.dev/docker- and its value is the URL of the host:
Configuring Git Authentication
Basic Authentication for Git
Create the Secret
Define a Secret with your username and password (or personal access token for GitHub):
GitHub deprecated basic authentication with username and password. Use a personal access token instead of a cleartext password. See GitHub’s documentation.
SSH Authentication for Git
Generate the private key
known_hosts field to the appropriate value for your Git server.Custom SSH Port
You can specify a custom SSH port in your Secret annotation:Configuring Docker Authentication
Basic Authentication for Docker
Docker Config Authentication
Use your existing Docker client configuration:If you specify both Tekton
basic-auth and Kubernetes dockerconfigjson Secrets, Tekton merges all credentials but basic-auth overrides the Kubernetes Secrets.Using Secrets as a Non-Root User
When running Steps as a non-root user, consider the following:- SSH authentication for Git requires the user to have a valid home directory in
/etc/passwd - SSH ignores the
$HOMEenvironment variable, so you must symlink or move Secret files from/tekton/hometo the non-root user’s home directory
Limiting Secret Access to Specific Steps
By default, Tekton makes Secrets available to all Steps. To limit a Secret to specific Steps:- Do not use the ServiceAccount-based approach described above
- Instead, explicitly specify a Volume using the Secret definition
- Manually mount it only into the desired Steps using VolumeMount
Disabling Built-In Authentication
To disable Tekton’s built-in credential handling, edit thefeature-flag ConfigMap:
disable-creds-init to "true".
Troubleshooting
Warning: unsuccessful cred copy
Warning: unsuccessful cred copy
This warning can occur for several reasons:Multiple Steps with varying UIDsSteps with different users/UIDs trying to initialize credentials in the same Task. Solution: Ensure all Steps run with the same UID using a TaskRun’s Pod template field.Workspace or Volume also mountedA Task has both a Workspace/Volume for credentials and a ServiceAccount with credentials. Solution: Don’t mix credentials mounted via Workspace with those initialized via ServiceAccount.Read-only Workspace for $HOMEA Task has a read-only Workspace mounted for the HOME directory. Solution: Don’t mix credentials mounted via Workspace with ServiceAccount-based initialization.Step named image-digest-exporterIf this warning appears for the
image-digest-exporter Step, you can safely ignore it. This Step is injected by Tekton and doesn’t use the credentials.