Credentials Field Guide¶
Overview¶
The credentials field in PodConfigSpec provides a simplified, user-friendly way to inject secrets as environment variables into validation pods. It's syntactic sugar that automatically converts to the more verbose envFrom syntax.
Why Use credentials?¶
Before (verbose envFrom syntax):¶
podConfig:
envFrom:
- secretRef:
name: "aws-credentials"
- secretRef:
name: "database-credentials"
- secretRef:
name: "mlflow-credentials"
After (simple credentials syntax):¶
How It Works¶
The operator automatically converts each credential name in the credentials list to an envFrom entry with a secretRef. This happens transparently during pod creation.
Conversion Example:
Is automatically converted to:
Usage Examples¶
Example 1: Single Credential¶
apiVersion: mlops.mlops.dev/v1alpha1
kind: NotebookValidationJob
metadata:
name: aws-test
spec:
notebook:
git:
url: "https://github.com/myorg/notebooks.git"
ref: "main"
path: "notebooks/aws-test.ipynb"
podConfig:
containerImage: "quay.io/jupyter/minimal-notebook:latest"
credentials:
- "aws-credentials"
Example 2: Multiple Credentials¶
apiVersion: mlops.mlops.dev/v1alpha1
kind: NotebookValidationJob
metadata:
name: multi-service-test
spec:
notebook:
git:
url: "https://github.com/myorg/notebooks.git"
ref: "main"
path: "notebooks/integration-test.ipynb"
podConfig:
containerImage: "quay.io/jupyter/minimal-notebook:latest"
credentials:
- "aws-credentials"
- "database-credentials"
- "mlflow-credentials"
- "api-keys"
Example 3: Mixing credentials and envFrom¶
You can use both credentials (for simple secrets) and envFrom (for complex sources like ConfigMaps):
podConfig:
credentials:
- "aws-credentials"
- "database-credentials"
envFrom:
- configMapRef:
name: "app-config"
env:
- name: "CUSTOM_VAR"
value: "custom-value"
Secret Format¶
The secrets referenced in the credentials field should contain key-value pairs that will be injected as environment variables:
apiVersion: v1
kind: Secret
metadata:
name: aws-credentials
type: Opaque
stringData:
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
AWS_DEFAULT_REGION: "us-east-1"
All keys in the secret will be available as environment variables in the validation pod.
Benefits¶
- Simplicity: Reduces YAML verbosity for common use cases
- Readability: Makes it immediately clear what credentials are being used
- Backwards Compatible: Existing
envFromsyntax continues to work - Flexible: Can be mixed with
envFromandenvfor complex scenarios
When to Use Each Syntax¶
Use credentials when:¶
- You're injecting secrets as environment variables
- You want simple, readable configuration
- All your credential sources are Kubernetes Secrets
Use envFrom when:¶
- You need to inject ConfigMaps
- You need fine-grained control over secret injection
- You're using advanced features like
prefixoroptional
Use env when:¶
- You need to inject individual keys from secrets/configmaps
- You need to set static values
- You need to use field references or resource field references
Implementation Details¶
The conversion happens in the createValidationPod function in the controller:
- The controller first processes explicit
envFromentries - Then it processes
credentialsentries, converting each to asecretRef - Both are combined into the pod's
envFromfield - This ensures both syntaxes work together seamlessly
See Also¶
- Notebook Credentials Guide - Comprehensive guide to credential management
- Sample Manifests - Example configurations
- API Reference - Full API documentation