Skip to content

Commit 2372efc

Browse files
committed
feat: Support dynamic image repositories
1 parent 50b6b10 commit 2372efc

8 files changed

Lines changed: 86 additions & 58 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
@@ -14,7 +14,7 @@ product-config = { git = "https://github.com/stackabletech/product-config.git",
1414
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = [
1515
"crds",
1616
"webhook",
17-
], tag = "stackable-operator-0.110.1" }
17+
], tag = "stackable-operator-0.111.0" }
1818

1919
anyhow = "1.0"
2020
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: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,8 +2576,9 @@ spec:
25762576
properties:
25772577
custom:
25782578
description: |-
2579-
Overwrite the docker image.
2580-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
2579+
Provide a custom container image.
2580+
2581+
Specify the full container image name, e.g. `oci.example.tech/namespace/superset:1.4.1-my-tag`
25812582
type: string
25822583
productVersion:
25832584
description: Version of the product, e.g. `1.4.1`.
@@ -2604,14 +2605,20 @@ spec:
26042605
nullable: true
26052606
type: array
26062607
repo:
2607-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
2608+
description: |-
2609+
The repository on the container image registry where the container image is located, e.g.
2610+
`oci.example.com/namespace`.
2611+
2612+
If not specified, the operator will use the image registry provided via the operator
2613+
environment options.
26082614
nullable: true
26092615
type: string
26102616
stackableVersion:
26112617
description: |-
26122618
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
2613-
If not specified, the operator will use its own version, e.g. `23.4.1`.
2614-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
2619+
2620+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
2621+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
26152622
nullable: true
26162623
type: string
26172624
type: object
@@ -8735,8 +8742,9 @@ spec:
87358742
properties:
87368743
custom:
87378744
description: |-
8738-
Overwrite the docker image.
8739-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
8745+
Provide a custom container image.
8746+
8747+
Specify the full container image name, e.g. `oci.example.tech/namespace/superset:1.4.1-my-tag`
87408748
type: string
87418749
productVersion:
87428750
description: Version of the product, e.g. `1.4.1`.
@@ -8763,14 +8771,20 @@ spec:
87638771
nullable: true
87648772
type: array
87658773
repo:
8766-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
8774+
description: |-
8775+
The repository on the container image registry where the container image is located, e.g.
8776+
`oci.example.com/namespace`.
8777+
8778+
If not specified, the operator will use the image registry provided via the operator
8779+
environment options.
87678780
nullable: true
87688781
type: string
87698782
stackableVersion:
87708783
description: |-
87718784
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
8772-
If not specified, the operator will use its own version, e.g. `23.4.1`.
8773-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
8785+
8786+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
8787+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
87748788
nullable: true
87758789
type: string
87768790
type: object

rust/operator-binary/src/airflow_controller.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use stackable_operator::{
2929
},
3030
},
3131
},
32+
cli::OperatorEnvironmentOptions,
3233
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
3334
commons::{
3435
product_image_selection::{self, ResolvedProductImage},
@@ -119,13 +120,14 @@ use crate::{
119120
};
120121

121122
pub const AIRFLOW_CONTROLLER_NAME: &str = "airflowcluster";
122-
pub const DOCKER_IMAGE_BASE_NAME: &str = "airflow";
123+
pub const CONTAINER_IMAGE_BASE_NAME: &str = "airflow";
123124
pub const AIRFLOW_FULL_CONTROLLER_NAME: &str =
124125
concatcp!(AIRFLOW_CONTROLLER_NAME, '.', OPERATOR_NAME);
125126

126127
pub struct Ctx {
127128
pub client: stackable_operator::client::Client,
128129
pub product_config: ProductConfigManager,
130+
pub operator_environment: OperatorEnvironmentOptions,
129131
}
130132

131133
#[derive(Snafu, Debug, EnumDiscriminants)]
@@ -387,7 +389,11 @@ pub async fn reconcile_airflow(
387389
let resolved_product_image = airflow
388390
.spec
389391
.image
390-
.resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION)
392+
.resolve(
393+
CONTAINER_IMAGE_BASE_NAME,
394+
&ctx.operator_environment.image_repository,
395+
crate::built_info::PKG_VERSION,
396+
)
391397
.context(ResolveProductImageSnafu)?;
392398

393399
let cluster_operation_cond_builder =

rust/operator-binary/src/crd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ mod tests {
11521152
let resolved_airflow_image: ResolvedProductImage = cluster
11531153
.spec
11541154
.image
1155-
.resolve("airflow", "0.0.0-dev")
1155+
.resolve("oci.example.org", "airflow", "0.0.0-dev")
11561156
.expect("test: resolved product image is always valid");
11571157

11581158
assert_eq!("3.1.6", &resolved_airflow_image.product_version);

rust/operator-binary/src/main.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ async fn main() -> anyhow::Result<()> {
121121
},
122122
));
123123

124+
let webhook_server = create_webhook_server(
125+
&operator_environment,
126+
maintenance.disable_crd_maintenance,
127+
client.as_kube_client(),
128+
)
129+
.await?;
130+
131+
let webhook_server = webhook_server
132+
.run(sigterm_watcher.handle())
133+
.map_err(|err| anyhow!(err).context("failed to run webhook server"));
134+
124135
let airflow_controller = Controller::new(
125136
watch_namespace.get_api::<DeserializeGuard<v1alpha2::AirflowCluster>>(&client),
126137
watcher::Config::default(),
@@ -170,6 +181,7 @@ async fn main() -> anyhow::Result<()> {
170181
airflow_controller::error_policy,
171182
Arc::new(airflow_controller::Ctx {
172183
client: client.clone(),
184+
operator_environment,
173185
product_config,
174186
}),
175187
)
@@ -192,17 +204,6 @@ async fn main() -> anyhow::Result<()> {
192204
)
193205
.map(anyhow::Ok);
194206

195-
let webhook_server = create_webhook_server(
196-
&operator_environment,
197-
maintenance.disable_crd_maintenance,
198-
client.as_kube_client(),
199-
)
200-
.await?;
201-
202-
let webhook_server = webhook_server
203-
.run(sigterm_watcher.handle())
204-
.map_err(|err| anyhow!(err).context("failed to run webhook server"));
205-
206207
let delayed_airflow_controller = async {
207208
signal::crd_established(&client, v1alpha1::AirflowCluster::crd_name(), None)
208209
.await?;

0 commit comments

Comments
 (0)