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
1
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.
2
Create a ServiceAccount
Associate the Secret with a ServiceAccount:
3
Reference the ServiceAccount
Associate the ServiceAccount with your TaskRun or PipelineRun:
4
Apply the configuration
SSH Authentication for Git
1
Create the SSH Secret
Define a Secret with your SSH private key:
2
Generate the private key
known_hosts field to the appropriate value for your Git server.3
Create a ServiceAccount
4
Apply and use
Custom SSH Port
You can specify a custom SSH port in your Secret annotation:Configuring Docker Authentication
Basic Authentication for Docker
1
Create the Secret
2
Create a ServiceAccount
3
Reference in TaskRun or PipelineRun
Docker Config Authentication
Use your existing Docker client configuration:1
Create Secret from Docker config
2
Associate with ServiceAccount
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.