Skip to content

Commit 519539d

Browse files
committed
feat: Support dynamic image repositories
1 parent 5435195 commit 519539d

7 files changed

Lines changed: 64 additions & 43 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/hdfs-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.1", 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
@@ -1332,8 +1332,9 @@ spec:
13321332
properties:
13331333
custom:
13341334
description: |-
1335-
Overwrite the docker image.
1336-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
1335+
Provide a custom container image.
1336+
1337+
Specify the full container image name, e.g. `oci.example.tech/namespace/superset:1.4.1-my-tag`
13371338
type: string
13381339
productVersion:
13391340
description: Version of the product, e.g. `1.4.1`.
@@ -1360,14 +1361,20 @@ spec:
13601361
nullable: true
13611362
type: array
13621363
repo:
1363-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
1364+
description: |-
1365+
The repository on the container image registry where the container image is located, e.g.
1366+
`oci.example.com/namespace`.
1367+
1368+
If not specified, the operator will use the image registry provided via the operator
1369+
environment options.
13641370
nullable: true
13651371
type: string
13661372
stackableVersion:
13671373
description: |-
13681374
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
1369-
If not specified, the operator will use its own version, e.g. `23.4.1`.
1370-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
1375+
1376+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
1377+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
13711378
nullable: true
13721379
type: string
13731380
type: object

rust/operator-binary/src/hdfs_controller.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use stackable_operator::{
1616
meta::ObjectMetaBuilder,
1717
pod::{PodBuilder, security::PodSecurityContextBuilder},
1818
},
19+
cli::OperatorEnvironmentOptions,
1920
client::Client,
2021
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
2122
commons::{
@@ -76,7 +77,7 @@ pub const RESOURCE_MANAGER_HDFS_CONTROLLER: &str = "hdfs-operator-hdfs-controlle
7677
const HDFS_CONTROLLER_NAME: &str = "hdfs-controller";
7778
pub const HDFS_FULL_CONTROLLER_NAME: &str = concatcp!(HDFS_CONTROLLER_NAME, '.', OPERATOR_NAME);
7879

79-
const DOCKER_IMAGE_BASE_NAME: &str = "hadoop";
80+
const CONTAINER_IMAGE_BASE_NAME: &str = "hadoop";
8081

8182
#[derive(Snafu, Debug, EnumDiscriminants)]
8283
#[strum_discriminants(derive(IntoStaticStr))]
@@ -262,6 +263,7 @@ pub struct Ctx {
262263
pub client: Client,
263264
pub product_config: ProductConfigManager,
264265
pub event_recorder: Arc<Recorder>,
266+
pub operator_environment: OperatorEnvironmentOptions,
265267
}
266268

267269
pub async fn reconcile_hdfs(
@@ -280,7 +282,11 @@ pub async fn reconcile_hdfs(
280282
let resolved_product_image = hdfs
281283
.spec
282284
.image
283-
.resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION)
285+
.resolve(
286+
CONTAINER_IMAGE_BASE_NAME,
287+
&ctx.operator_environment.image_repository,
288+
crate::built_info::PKG_VERSION,
289+
)
284290
.context(ResolveProductImageSnafu)?;
285291

286292
let validated_config = {
@@ -995,7 +1001,7 @@ properties: []
9951001
let resolved_product_image = hdfs
9961002
.spec
9971003
.image
998-
.resolve(DOCKER_IMAGE_BASE_NAME, "0.0.0-dev")
1004+
.resolve(CONTAINER_IMAGE_BASE_NAME, "oci.example.org", "0.0.0-dev")
9991005
.expect("test resolved product image is always valid");
10001006

10011007
let mut pb = PodBuilder::new();

rust/operator-binary/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ async fn main() -> anyhow::Result<()> {
190190
hdfs_controller::reconcile_hdfs,
191191
hdfs_controller::error_policy,
192192
Arc::new(hdfs_controller::Ctx {
193+
event_recorder: hdfs_event_recorder.clone(),
193194
client: client.clone(),
195+
operator_environment,
194196
product_config,
195-
event_recorder: hdfs_event_recorder.clone(),
196197
}),
197198
)
198199
// We can let the reporting happen in the background

0 commit comments

Comments
 (0)