|
| 1 | +# Using Alternative Container Registry |
| 2 | + |
| 3 | +This example demonstrates how to configure the SpiceDB operator to use an alternative container registry instead of the default one. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The SpiceDB operator supports specifying a custom base image for SpiceDB containers through the `baseImage` field in the `SpiceDBCluster` spec. This is useful when: |
| 8 | + |
| 9 | +- You need to use a private container registry |
| 10 | +- You want to mirror images to your own registry for security or compliance reasons |
| 11 | +- You need to use a registry proxy for better performance |
| 12 | +- You're running in an air-gapped environment |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +The image selection follows this precedence order (highest to lowest): |
| 17 | + |
| 18 | +1. `.spec.config.image` with explicit tag/digest (overrides everything) |
| 19 | +2. `.spec.baseImage` field (what this example uses) |
| 20 | +3. The operator's `--base-image` flag |
| 21 | +4. The `imageName` defined in the update graph |
| 22 | + |
| 23 | +**Important:** The `baseImage` field must NOT contain a tag (`:tag`) or digest (`@sha256:...`). The operator will automatically append the appropriate tag based on the `version` or `channel` you specify. If you need to specify an exact image with tag, use `.spec.config.image` instead. |
| 24 | + |
| 25 | +## Example |
| 26 | + |
| 27 | +See [spicedb-cluster.yaml](spicedb-cluster.yaml) for a complete example. |
| 28 | + |
| 29 | +```yaml |
| 30 | +apiVersion: authzed.com/v1alpha1 |
| 31 | +kind: SpiceDBCluster |
| 32 | +metadata: |
| 33 | + name: example-with-custom-registry |
| 34 | +spec: |
| 35 | + # Specify your alternative registry here (NO TAG!) |
| 36 | + baseImage: "my-registry.company.com/authzed/spicedb" |
| 37 | + |
| 38 | + # The operator will append the appropriate tag based on the version/channel |
| 39 | + version: "v1.33.0" |
| 40 | + |
| 41 | + config: |
| 42 | + datastoreEngine: postgres |
| 43 | + # ... other config |
| 44 | + |
| 45 | + # If using a private registry, use patches to add imagePullSecrets |
| 46 | + patches: |
| 47 | + - kind: Deployment |
| 48 | + patch: | |
| 49 | + spec: |
| 50 | + template: |
| 51 | + spec: |
| 52 | + imagePullSecrets: |
| 53 | + - name: registry-credentials |
| 54 | +``` |
| 55 | +
|
| 56 | +## How it Works |
| 57 | +
|
| 58 | +When you specify a `baseImage`, the operator will: |
| 59 | + |
| 60 | +1. Use your specified registry as the base |
| 61 | +2. Append the appropriate tag or digest based on the `version` or `channel` you specify |
| 62 | +3. The final image will be: `<baseImage>:<tag>` or `<baseImage>@<digest>` |
| 63 | + |
| 64 | +For example, if you specify: |
| 65 | + |
| 66 | +- `baseImage: "my-registry.company.com/authzed/spicedb"` |
| 67 | +- `version: "v1.33.0"` |
| 68 | + |
| 69 | +The operator will use: `my-registry.company.com/authzed/spicedb:v1.33.0` |
| 70 | + |
| 71 | +## Private Registry Authentication |
| 72 | + |
| 73 | +If your alternative registry requires authentication, you need to: |
| 74 | + |
| 75 | +1. Create an image pull secret with your registry credentials: |
| 76 | + |
| 77 | + ```bash |
| 78 | + kubectl create secret docker-registry registry-credentials \ |
| 79 | + --docker-server=my-registry.company.com \ |
| 80 | + --docker-username=YOUR-USERNAME \ |
| 81 | + --docker-password=YOUR-PASSWORD \ |
| 82 | + --namespace=spicedb-custom-registry |
| 83 | + ``` |
| 84 | + |
| 85 | +2. Use the `patches` field to inject the image pull secret into the deployment: |
| 86 | + |
| 87 | + ```yaml |
| 88 | + spec: |
| 89 | + patches: |
| 90 | + - kind: Deployment |
| 91 | + patch: | |
| 92 | + spec: |
| 93 | + template: |
| 94 | + spec: |
| 95 | + imagePullSecrets: |
| 96 | + - name: registry-credentials |
| 97 | + ``` |
| 98 | + |
| 99 | +## Common Mistakes |
| 100 | + |
| 101 | +### Including a tag in baseImage |
| 102 | + |
| 103 | +**Wrong:** |
| 104 | + |
| 105 | +```yaml |
| 106 | +spec: |
| 107 | + baseImage: "my-registry.company.com/authzed/spicedb:v1.33.0" # Don't include tag! |
| 108 | +``` |
| 109 | + |
| 110 | +**Correct:** |
| 111 | + |
| 112 | +```yaml |
| 113 | +spec: |
| 114 | + baseImage: "my-registry.company.com/authzed/spicedb" |
| 115 | + version: "v1.33.0" |
| 116 | +``` |
| 117 | + |
| 118 | +### Confusing baseImage with config.image |
| 119 | + |
| 120 | +- Use `baseImage` when you want the operator to manage versions via the update graph |
| 121 | +- Use `config.image` (with full tag/digest) when you want to bypass the update graph entirely |
| 122 | + |
| 123 | +## Important Notes |
| 124 | + |
| 125 | +- Make sure your Kubernetes nodes can pull from your alternative registry |
| 126 | +- If using a private registry, use the `patches` field to configure image pull secrets |
| 127 | +- The operator still uses the update graph to determine valid versions and migration paths |
| 128 | +- The alternative registry must contain the exact same images as the official registry |
0 commit comments