Skip to content

Commit c2841f4

Browse files
committed
spike: Use dynamic product image selection
1 parent 6b15c8b commit c2841f4

10 files changed

Lines changed: 106 additions & 109 deletions

File tree

Cargo.lock

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

Cargo.nix

Lines changed: 15 additions & 54 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
@@ -36,4 +36,4 @@ tracing = "0.1"
3636
[patch."https://github.com/stackabletech/operator-rs.git"]
3737
# TODO revert this before merging!
3838
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
39-
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
39+
stackable-operator = { path = "../operator-rs/crates/stackable-operator" }

Tiltfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ operator_name = meta['operator']['name']
55
# If tilt_options.json exists read it and load the default_registry and default_repository value from it
66
settings = read_json('tilt_options.json', default={})
77
registry = settings.get('default_registry', 'oci.stackable.tech')
8-
repository = settings.get('default_repository', 'sandbox' + '/' + operator_name)
8+
repository = settings.get('default_repository', 'sdp' + '/' + operator_name)
99

10-
# Configure default registry either read from config file above, or with default value of "oci.stackable.tech/sandbox"
10+
# Configure default registry either read from config file above, or with default value of "oci.stackable.tech"
1111
default_registry(registry)
1212

1313
custom_build(
@@ -20,8 +20,8 @@ custom_build(
2020
)
2121

2222
# We need to set the correct image annotation on the operator Deployment to use e.g.
23-
# oci.stackable.tech/sandbox/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of
24-
# oci.stackable.tech/sandbox/opa-operator:0.0.0-dev (which does not exist)
23+
# oci.stackable.tech/sdp/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of
24+
# oci.stackable.tech/sdp/opa-operator:0.0.0-dev (which does not exist)
2525
k8s_kind('Deployment', image_json_path='{.spec.template.metadata.annotations.internal\\.stackable\\.tech/image}')
2626
k8s_kind('DaemonSet', image_json_path='{.spec.template.metadata.annotations.internal\\.stackable\\.tech/image}')
2727

crate-hashes.json

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

deploy/helm/airflow-operator/templates/deployment.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ spec:
7070
- name: OPERATOR_SERVICE_NAME
7171
value: {{ include "operator.fullname" . }}
7272

73-
# The URI of the image registry, like "oci.stackable.tech". Used to derive product image
74-
# name.
75-
- name: IMAGE_REGISTRY_URI
73+
# The image registry, like "oci.stackable.tech". Used to derive product image name.
74+
- name: IMAGE_REGISTRY
7675
value: {{ .Values.image.registry }}
7776

7877
# The image repository, like "sdp/airflow-operator"

extra/crds.yaml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,8 +2398,9 @@ spec:
23982398
properties:
23992399
custom:
24002400
description: |-
2401-
Overwrite the docker image.
2402-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
2401+
Overwrite the container image.
2402+
2403+
Specify the full container image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
24032404
type: string
24042405
productVersion:
24052406
description: Version of the product, e.g. `1.4.1`.
@@ -2425,15 +2426,29 @@ spec:
24252426
type: object
24262427
nullable: true
24272428
type: array
2428-
repo:
2429-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
2429+
registry:
2430+
description: |-
2431+
The container image registry, e.g. `oci.stackable.tech`.
2432+
2433+
If not specified, the operator will use the image registry provided via the operator
2434+
environment options.
2435+
nullable: true
2436+
type: string
2437+
repository:
2438+
description: |-
2439+
The repository on the container image registry where the container image is located, e.g.
2440+
`sdp/airflow`.
2441+
2442+
If not specified, the operator will use the image registry provided via the operator
2443+
environment options.
24302444
nullable: true
24312445
type: string
24322446
stackableVersion:
24332447
description: |-
24342448
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
2435-
If not specified, the operator will use its own version, e.g. `23.4.1`.
2436-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
2449+
2450+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
2451+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
24372452
nullable: true
24382453
type: string
24392454
type: object
@@ -8379,8 +8394,9 @@ spec:
83798394
properties:
83808395
custom:
83818396
description: |-
8382-
Overwrite the docker image.
8383-
Specify the full docker image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
8397+
Overwrite the container image.
8398+
8399+
Specify the full container image name, e.g. `oci.stackable.tech/sdp/superset:1.4.1-stackable2.1.0`
83848400
type: string
83858401
productVersion:
83868402
description: Version of the product, e.g. `1.4.1`.
@@ -8406,15 +8422,29 @@ spec:
84068422
type: object
84078423
nullable: true
84088424
type: array
8409-
repo:
8410-
description: Name of the docker repo, e.g. `oci.stackable.tech/sdp`
8425+
registry:
8426+
description: |-
8427+
The container image registry, e.g. `oci.stackable.tech`.
8428+
8429+
If not specified, the operator will use the image registry provided via the operator
8430+
environment options.
8431+
nullable: true
8432+
type: string
8433+
repository:
8434+
description: |-
8435+
The repository on the container image registry where the container image is located, e.g.
8436+
`sdp/airflow`.
8437+
8438+
If not specified, the operator will use the image registry provided via the operator
8439+
environment options.
84118440
nullable: true
84128441
type: string
84138442
stackableVersion:
84148443
description: |-
84158444
Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
8416-
If not specified, the operator will use its own version, e.g. `23.4.1`.
8417-
When using a nightly operator or a pr version, it will use the nightly `0.0.0-dev` image.
8445+
8446+
If not specified, the operator will use its own version, e.g. `23.4.1`. When using a nightly
8447+
operator or a PR version, it will use the nightly `0.0.0-dev` image.
84188448
nullable: true
84198449
type: string
84208450
type: object

rust/operator-binary/src/airflow_controller.rs

Lines changed: 10 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},
@@ -112,13 +113,13 @@ use crate::{
112113
};
113114

114115
pub const AIRFLOW_CONTROLLER_NAME: &str = "airflowcluster";
115-
pub const DOCKER_IMAGE_BASE_NAME: &str = "airflow";
116116
pub const AIRFLOW_FULL_CONTROLLER_NAME: &str =
117117
concatcp!(AIRFLOW_CONTROLLER_NAME, '.', OPERATOR_NAME);
118118

119119
pub struct Ctx {
120120
pub client: stackable_operator::client::Client,
121121
pub product_config: ProductConfigManager,
122+
pub operator_environment: OperatorEnvironmentOptions,
122123
}
123124

124125
#[derive(Snafu, Debug, EnumDiscriminants)]
@@ -380,7 +381,14 @@ pub async fn reconcile_airflow(
380381
let resolved_product_image = airflow
381382
.spec
382383
.image
383-
.resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION)
384+
.resolve(
385+
&ctx.operator_environment.image_registry.to_string(),
386+
ctx.operator_environment
387+
.image_repository
388+
// I'm not happy about this. Is this something we can and should adjust?
389+
.trim_end_matches("-operator"),
390+
crate::built_info::PKG_VERSION,
391+
)
384392
.context(ResolveProductImageSnafu)?;
385393

386394
let cluster_operation_cond_builder =

0 commit comments

Comments
 (0)