ADR-051: Git Init Container Image Compatibility¶
Status¶
Accepted
Context¶
The operator uses a git-clone init container to fetch notebooks from Git repositories before validation. The choice of git init image affects compatibility with OpenShift's security context constraints and different execution modes.
Current Implementation¶
The operator's git_helper.go uses bash scripts to clone repositories:
Image Compatibility Issue¶
Two different approaches exist for git cloning in containers:
- Standard bash + git (alpine/git, bitnami/git):
- Has
/bin/bashandgitcommand available - Works with our current bash script approach
-
Simpler, more portable
-
Tekton git-init binary (Red Hat pipelines-git-init-rhel8, Tekton git-init):
- Uses a specialized
git-initbinary - Requires specific arguments:
-url,-revision,-path, etc. - Does NOT have
/bin/bashor standardgitcommand - Example:
git-init -url=https://... -revision=main -path=/workspace/repo
Problem Discovered¶
When using registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8, the operator's bash-based approach fails with exit code 128 because:
- The image doesn't have /bin/bash in the expected location
- The image is designed to run the git-init binary directly, not bash scripts
Research Findings¶
From examining the Tekton git-clone task on OpenShift 4.18:
exec git-init \
-url="${PARAMS_URL}" \
-revision="${PARAMS_REVISION}" \
-refspec="${PARAMS_REFSPEC}" \
-path="${checkout_dir}" \
-sslVerify="${PARAMS_SSL_VERIFY}" \
-submodules="${PARAMS_SUBMODULES}" \
-depth="${PARAMS_DEPTH}"
Decision¶
Use a custom RHEL9-based git-init image (quay.io/takinosh/git-init-rhel9:latest) for the following reasons:
- Compatibility: Works with our current bash-based implementation
- Red Hat Ecosystem: Based on ubi9/ubi-minimal, aligned with OpenShift/RHEL
- Security: Runs as non-root user (UID 1001, group 0), compatible with OpenShift SCC
- Controlled: We maintain the image source and build process
- Automated Updates: Dependabot keeps base image updated
- Portability: Works on both OpenShift and vanilla Kubernetes
Image Source: https://github.com/tosin2013/git-init-rhel9 Registry: quay.io/takinosh/git-init-rhel9:latest
Consequences¶
Positive¶
- ✅ Fixes current tier1 test failures caused by incompatible git-init image
- ✅ No code changes required to git clone logic
- ✅ Works on OpenShift without requiring Red Hat registry authentication
- ✅ Simpler debugging - can exec into container and run git commands
- ✅ Consistent behavior across environments
- ✅ RHEL9-based, aligned with Red Hat ecosystem
- ✅ Automated security updates via Dependabot
- ✅ Full control over image source and build process
Negative¶
- ⚠️ Requires maintaining separate git-init image repository
- ⚠️ Requires Quay.io for image hosting
- ⚠️ Not an official Red Hat supported image (but uses UBI9 base)
Neutral¶
- 💡 Future enhancement: Support both modes (bash+git AND git-init binary)
- 💡 Could add auto-detection based on image capabilities
- 💡 GIT_INIT_IMAGE env var already supported for custom images
Implementation¶
Custom Git-Init Image¶
Created a separate repository with RHEL9-based Dockerfile: - Repository: https://github.com/tosin2013/git-init-rhel9 - Base Image: registry.access.redhat.com/ubi9/ubi-minimal:latest - Installed Packages: git, bash, openssh-clients, ca-certificates - User: Non-root UID 1001, group 0 (OpenShift SCC compatible) - Working Directory: /workspace with 1001:0 ownership and g+rwX permissions - GitHub Actions: Automated build and push to Quay.io - Dependabot: Automated base image security updates
Update git_helper.go¶
func getGitImage() string {
// Priority 1: Check for manual override
if gitImage := os.Getenv("GIT_INIT_IMAGE"); gitImage != "" {
return gitImage
}
// Priority 2: Use custom RHEL9-based git-init image for all platforms
// Built from: https://github.com/tosin2013/git-init-rhel9
return "quay.io/takinosh/git-init-rhel9:latest"
}
Configuration Override¶
Users can still use alternative images by setting:
Note: Tekton git-init binary images would require updating the git clone logic to use git-init binary arguments instead of bash scripts.
Future Work¶
- Dual Mode Support: Detect image type and use appropriate invocation method
- RHEL 9 Support: Investigate pipelines-git-init-rhel9 compatibility
- Image Caching: Consider bundling git in operator image to avoid pull
- Documentation: Add troubleshooting guide for git clone failures
References¶
- Tekton git-init source
- Alpine Git image
- OpenShift Pipelines Tasks
- Issue discovered during tier1 E2E test execution on OpenShift 4.18