Skip to content

Commit e9e4c16

Browse files
committed
feat: Support dynamic image repositories
1 parent e56e5ea commit e9e4c16

7 files changed

Lines changed: 67 additions & 42 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 18 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = "https://github.com/stackabletech/druid-operator"
1111

1212
[workspace.dependencies]
1313
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.8.0" }
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.110.1", features = ["crds", "webhook"] }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.111.0", features = ["crds", "webhook"] }
1515

1616
anyhow = "1.0"
1717
built = { version = "0.8", features = ["chrono", "git2"] }

crate-hashes.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extra/crds.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,8 +3575,9 @@ spec:
35753575
properties:
35763576
custom:
35773577
description: |-
3578-
Overwrite the docker image.
3579-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
3578+
Provide a custom container image.
3579+
3580+
Specify the full container image name, e.g. `oci.example.tech/namespace/superset:1.4.1-my-tag`
35803581
type: string
35813582
productVersion:
35823583
description: Version of the product, e.g. `1.4.1`.
@@ -3603,14 +3604,20 @@ spec:
36033604
nullable: true
36043605
type: array
36053606
repo:
3606-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
3607+
description: |-
3608+
The repository on the container image registry where the container image is located, e.g.
3609+
`oci.example.com/namespace`.
3610+
3611+
If not specified, the operator will use the image registry provided via the operator
3612+
environment options.
36073613
nullable: true
36083614
type: string
36093615
stackableVersion:
36103616
description: |-
36113617
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
3612-
If not specified, the operator will use its own version, e.g. `23.4.1`.
3613-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
3618+
3619+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
3620+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
36143621
nullable: true
36153622
type: string
36163623
type: object

rust/operator-binary/src/druid_controller.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use stackable_operator::{
2424
security::PodSecurityContextBuilder, volume::VolumeBuilder,
2525
},
2626
},
27+
cli::OperatorEnvironmentOptions,
2728
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
2829
commons::{
2930
opa::OpaApiVersion,
@@ -95,7 +96,7 @@ use crate::{
9596
pub const DRUID_CONTROLLER_NAME: &str = "druidcluster";
9697
pub const FULL_CONTROLLER_NAME: &str = concatcp!(DRUID_CONTROLLER_NAME, '.', OPERATOR_NAME);
9798

98-
const DOCKER_IMAGE_BASE_NAME: &str = "druid";
99+
const CONTAINER_IMAGE_BASE_NAME: &str = "druid";
99100

100101
// volume names
101102
const DRUID_CONFIG_VOLUME_NAME: &str = "config";
@@ -108,6 +109,7 @@ const USERDATA_MOUNTPOINT: &str = "/stackable/userdata";
108109
pub struct Ctx {
109110
pub client: stackable_operator::client::Client,
110111
pub product_config: ProductConfigManager,
112+
pub operator_environment: OperatorEnvironmentOptions,
111113
}
112114

113115
#[derive(Snafu, Debug, EnumDiscriminants)]
@@ -414,7 +416,11 @@ pub async fn reconcile_druid(
414416
let resolved_product_image = druid
415417
.spec
416418
.image
417-
.resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION)
419+
.resolve(
420+
CONTAINER_IMAGE_BASE_NAME,
421+
&ctx.operator_environment.image_repository,
422+
crate::built_info::PKG_VERSION,
423+
)
418424
.context(ResolveProductImageSnafu)?;
419425

420426
let zk_confmap = druid.spec.cluster_config.zookeeper_config_map_name.clone();
@@ -1421,7 +1427,11 @@ mod test {
14211427
let resolved_product_image: ResolvedProductImage = druid
14221428
.spec
14231429
.image
1424-
.resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION)
1430+
.resolve(
1431+
CONTAINER_IMAGE_BASE_NAME,
1432+
"oci.example.org",
1433+
crate::built_info::PKG_VERSION,
1434+
)
14251435
.expect("test: resolved product image is always valid");
14261436
let role_config = transform_all_roles_to_config(&druid, &druid.build_role_properties());
14271437

rust/operator-binary/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ async fn main() -> anyhow::Result<()> {
165165
druid_controller::error_policy,
166166
Arc::new(druid_controller::Ctx {
167167
client: client.clone(),
168+
operator_environment,
168169
product_config,
169170
}),
170171
)

0 commit comments

Comments
 (0)