ADR-042: Automatic Tekton Git Credentials Secret Conversion¶
Status¶
Accepted
Context¶
The Jupyter Notebook Validator Operator supports two build strategies: S2I (Source-to-Image) and Tekton Pipelines. When users provide Git credentials for cloning private repositories, the operator needs to handle different secret formats:
- Validation Pod: Uses standard Kubernetes secret format with
usernameandpasswordkeys - Tekton git-clone Task: Expects basic-auth workspace format with
.git-credentialsand.gitconfigfiles
The Problem¶
Prior to this ADR, users needed to manually create TWO separate secrets:
- git-credentials: Standard format for validation pods
- git-credentials-tekton: Tekton format for build pipelines
This created a poor user experience: 1. E2E tests were failing because only the standard secret was created 2. Users would need to understand Tekton's specific credential format 3. Documentation burden increased 4. Error messages were confusing (build would fail with "secret not found")
Root Cause Analysis¶
From the Tier 2 E2E test failure:
status:
buildStatus:
message: 'Build creation failed: pipelinerun creation verification failed:
PipelineRun.tekton.dev "tier2-test-01-sentiment-model-build" not found'
phase: Failed
The PipelineRun referenced a non-existent secret git-credentials-tekton, causing immediate build failure.
Decision¶
The operator will automatically create and manage Tekton-formatted Git credentials secrets from standard secrets.
Implementation¶
- Automatic Secret Conversion: When a Tekton build is triggered with
spec.notebook.git.credentialsSecretspecified, the operator will: - Check if
{credentialsSecret}-tektonexists - If not, create it from the source secret
-
Convert username/password to Tekton's
.git-credentialsand.gitconfigformat -
Secret Naming Convention:
- Source:
{name}(e.g.,git-credentials) -
Target:
{name}-tekton(e.g.,git-credentials-tekton) -
Format Conversion:
# Source Secret (Standard Format) apiVersion: v1 kind: Secret metadata: name: git-credentials data: username: base64(username) password: base64(password) # Generated Tekton Secret apiVersion: v1 kind: Secret metadata: name: git-credentials-tekton labels: app.kubernetes.io/managed-by: jupyter-notebook-validator-operator annotations: tekton.dev/git-0: https://github.com data: .git-credentials: base64("https://username:password@github.com\n") .gitconfig: base64("[credential]\n\thelper = store\n") -
Lifecycle Management:
- Secrets are created on-demand during
CreateBuild() - Labeled with
app.kubernetes.io/managed-by: jupyter-notebook-validator-operator -
Annotated with source secret reference for tracking
-
RBAC Update:
- Added
createpermission for secrets in ClusterRole
Code Location¶
- Implementation:
pkg/build/tekton_strategy.go:ensureTektonGitCredentials() - Integration: Called from
CreateBuild()before pipeline creation - RBAC:
config/rbac/role.yaml
Consequences¶
Positive¶
- Improved User Experience: Users only need to create one secret
- E2E Test Fix: Tier 2 tests will pass with standard secrets
- Reduced Documentation: No need to explain Tekton credential format
- Better Error Messages: Clear errors if source secret is malformed
- Consistency: Same secret naming works across S2I and Tekton strategies
Negative¶
- RBAC Scope: Operator now needs
createpermission for secrets (previously onlyget,list) - Secret Proliferation: Each credential secret creates a derived
-tektonsecret - Sync Challenges: Source secret updates don't automatically propagate (TODO: implement sync)
Neutral¶
- Backward Compatibility: Existing manual
-tektonsecrets are preserved and not overwritten - Multi-Provider Support: Current implementation hardcodes
github.comin annotations (works for most providers due to generic credential format)
Alternatives Considered¶
Alternative 1: Require Users to Create Both Secrets¶
Rejected: Poor user experience, error-prone, requires deep Tekton knowledge.
Alternative 2: Use Tekton Annotations on Standard Secret¶
Rejected: Tekton git-clone task specifically requires .git-credentials file format, not the standard keys.
Alternative 3: Custom Tekton Task¶
Rejected: Would require maintaining custom Tekton tasks instead of using upstream git-clone task.
Implementation Status¶
Completed Components¶
- Automatic Secret Conversion ✅
- Implemented:
pkg/build/tekton_strategy.go:ensureTektonGitCredentials() - Called from:
CreateBuild()before PipelineRun creation -
Tested: E2E Tier 2 tests
-
RBAC Permissions ✅
- Added kubebuilder markers:
internal/controller/notebookvalidationjob_controller.go:91,94,95 - Permissions:
secrets(create, watch),serviceaccounts(watch),securitycontextconstraints(get, list, use) -
Generated:
config/rbac/role.yaml -
Documentation ✅
- ADR-042 created and maintained
- Code comments in place
- E2E test coverage
S2I Comparison¶
Important: S2I BuildConfig does NOT need credential conversion.
S2I Implementation (pkg/build/s2i_strategy.go:184-189):
// Add Git credentials secret if specified
if job.Spec.Notebook.Git.CredentialsSecret != "" {
source.SourceSecret = &corev1.LocalObjectReference{
Name: job.Spec.Notebook.Git.CredentialsSecret,
}
}
OpenShift BuildConfig's SourceSecret field natively supports the standard username/password format. No conversion is needed.
Why Tekton Needs Conversion:
- Tekton git-clone task uses upstream Tekton catalog tasks
- These tasks expect Git credential helper format (.git-credentials file)
- OpenShift BuildConfig uses OpenShift-native credential injection
Summary: | Build Strategy | Secret Format | Conversion | File | |---------------|---------------|------------|------| | S2I | Standard | Not needed | s2i_strategy.go | | Tekton | Tekton format | Auto-converted | tekton_strategy.go |
Implementation Notes¶
Future Enhancements (TODOs)¶
- Secret Synchronization: Watch source secret for changes and update Tekton secret
- Multi-Provider Support: Extract Git host from
spec.notebook.git.urlfor annotation - Cleanup on Deletion: Consider deleting
-tektonsecret when source secret is deleted - SSH Key Support: Extend to handle SSH-based authentication
Testing Strategy¶
- Unit tests for
ensureTektonGitCredentials() - E2E test verification with Tier 2 builds
- Manual testing with private repositories
Migration Path¶
Existing deployments with manual -tekton secrets:
- Will continue to work
- Operator detects existing secrets and skips creation
- No breaking changes
References¶
- Tekton Auth Documentation: https://tekton.dev/docs/pipelines/auth/
- GitHub Issue: Tier 2 E2E Test Failures
- Related ADRs:
- ADR-028: Tekton Task Management
- ADR-031: Dockerfile Generation and Custom Base Images
- ADR-039: Automatic SCC Management for Tekton Builds
Date¶
2025-11-21