This project aims to ship a credential provider built for CRI-O to authenticate image pulls against registry mirrors by using namespaced Kubernetes Secrets.
- Seamless integration with CRI-O as a kubelet image credential provider plugin
- Authentication image pulls from registry mirrors using Kubernetes Secrets scoped to namespaces
- Support for registry mirrors and pull-through caches
- Compatible with standard container registry authentication
- Works with both plain Kubernetes and OpenShift
To build the credential provider binary from source:
makeThis will create the binary at build/crio-credential-provider.
You can also specify the target OS and architecture:
GOOS=linux GOARCH=amd64 makeTo clean the build artifacts:
make cleanHow to test the feature in Kubernetes is outlined in test/README.md.
How to test the feature in OpenShift is outlined in test/openshift/README.md.
Run the unit tests:
make testThis will generate coverage reports in build/coverprofile and build/coverage.html.
Run the Go linter:
make lintRun shell script formatting:
make shfmtRun shell script linting:
make shellcheckThe end-to-end tests are written using bats (Bash Automated Testing System).
To run the full test suite using a Vagrant machine:
make e2eOr run the tests locally for an already set-up cluster:
cd test
bats e2e.batsThe test suite includes:
- Mirror found test: Validates that mirrors are correctly identified and auth files are written
- No mirror found test: Ensures proper handling when no mirrors are configured
- No registries.conf test: Validates behavior when registries.conf doesn't exist
- Version test: Validates the
--versionand--version-jsonflags
test/e2e.bats- Main test file containing all test casestest/helpers.bash- Shared helper functions used across teststest/e2e-run- Wrapper script that executes the bats test suitetest/e2e-setup- Initial setup script for configuring Kubernetes and CRI-O
Check that all dependencies are up to date:
make dependenciesThe credential provider implements the Kubernetes kubelet Credential Provider API and integrates with CRI-O's image pull authentication flow. When the kubelet needs to pull an image from a registry, it invokes this credential provider, which:
- Receives authentication requests via stdin (kubelet Credential Provider API).
- Resolves matching mirrors from
/etc/containers/registries.conffor the provided image from the request. - Finds mirror pull secrets in the Pods namespace by using the service account token from the request and the Kubernetes API.
- Extracts the registry credentials from matching Secrets
- Generates a short-lived authentication file for the image pull at
/etc/crio/auth/<NAMESPACE>-<IMAGE_NAME_SHA256>.json, which includes mirror credentials, source registry credentials, and any global pull secrets. - Returns an empty
CredentialProviderResponseto kubelet to indicate success.
This allows for secure, namespace-scoped credential management without exposing credentials in node-level configuration files.
To display version information:
./build/crio-credential-provider --versionFor JSON format:
./build/crio-credential-provider --version-jsonContributions are welcome! This project is part of the CRI-O ecosystem.
When contributing:
- Follow the existing code style
- Run
make lintto ensure code quality - Run
make testto verify all tests pass - Update documentation as needed
- CRI-O - OCI-based Kubernetes Container Runtime Interface
- Kubernetes - Container orchestration platform
