kubeblocks
kubeblocks copied to clipboard
feat: replace image registry dynamically
When does image replcaement happen
Bascially, replacement will happen when workload resources (like pod, job, deployment, statefulset) are created.
Specifically, the replacement will inject to:
-
instanceset controller, so that it affects:
- new cluster creation
- cluster upgrade
But it won't affect:
- cluster scaling
- instance template
-
addon controller, so that it affects helm install jobs
-
backup/restore controller
Replace Configs
sample config:
registries:
defaultRegistry: foo.bar
defaultNamespace: default
registriyConfig:
- from: docker.io
to: docker-mirror.io
- from: k8s.io
to: company-registry.io
registryDefaultNamespace: k8sio
namespaces:
- from: special-ns
to: my-special-ns
The replacement rules are as follows:
- If there's no specific registry config (
registriyConfigfield), or registry does not match any specific registry config,defaultRegistryanddefaultNamespacewill be used.- If
defaultNamespaceis not defined, namespace remains unchanged. - If
defaultRegistryis not defined, registry remains unchanged.
- If
- If image's registry matches a specific registry config:
fromandtoshould not be empty. Registrytowill be used.- If there's no namespace config, or namespace does not match any specific namespace config,
registryDefaultNamespacewill be used. IfregistryDefaultNamespaceis not defined, namespace remains unchanged. - If namespace matches a specific namespace config, namespace
towill be used.fromandtoof the namespace may be empty (empty namespace is legal)
Other things to note
One side effect of this change is that omitted image name (e.g. busybox) will be expanded to full format (e.g. docker.io/library/busybox). IMO this will not have any user facing change.
Codecov Report
Attention: Patch coverage is 77.60000% with 28 lines in your changes missing coverage. Please review.
Project coverage is 60.40%. Comparing base (
d23e2e8) to head (5dda436). Report is 2 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #8018 +/- ##
==========================================
+ Coverage 60.26% 60.40% +0.14%
==========================================
Files 377 378 +1
Lines 45781 45891 +110
==========================================
+ Hits 27589 27722 +133
+ Misses 15600 15592 -8
+ Partials 2592 2577 -15
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 60.40% <77.60%> (+0.14%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@weicao @zjx20 PTAL
@cjc7373 Please resolve conflicts and cover the case at https://github.com/apecloud/kubeblocks/pull/8539 .
/cherry-pick release-1.0-beta
🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/apecloud/kubeblocks/actions/runs/12176948165