From 5be39536f36227537d51dd5cfbc91d507d2967bd Mon Sep 17 00:00:00 2001 From: Joonas Bergius Date: Wed, 12 Jun 2024 11:55:57 -0500 Subject: [PATCH] feat: Add option to customize NATS leaf node image Signed-off-by: Joonas Bergius --- Cargo.lock | 2 +- crates/types/Cargo.toml | 2 +- crates/types/src/v1alpha1/wasmcloud_host_config.rs | 4 ++++ src/controller.rs | 7 ++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2282db9..5bbe55b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4452,7 +4452,7 @@ dependencies = [ [[package]] name = "wasmcloud-operator-types" -version = "0.1.4" +version = "0.1.5" dependencies = [ "k8s-openapi", "kube", diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index a04fc5d..f083a05 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmcloud-operator-types" -version = "0.1.4" +version = "0.1.5" edition = "2021" [dependencies] diff --git a/crates/types/src/v1alpha1/wasmcloud_host_config.rs b/crates/types/src/v1alpha1/wasmcloud_host_config.rs index f2ec6ca..f1accb0 100644 --- a/crates/types/src/v1alpha1/wasmcloud_host_config.rs +++ b/crates/types/src/v1alpha1/wasmcloud_host_config.rs @@ -33,6 +33,10 @@ pub struct WasmCloudHostConfigSpec { /// If not provided, the default image for the version will be used. /// Also if provided, the version field will be ignored. pub image: Option, + /// The image to use for the NATS leaf that is deployed alongside the wasmCloud host. + /// If not provided, the default upstream image will be used. + /// If provided, it should be fully qualified by including the image tag. + pub nats_leaf_image: Option, /// The name of a secret containing the primary cluster issuer key along with an optional set /// of NATS credentials. pub secret_name: String, diff --git a/src/controller.rs b/src/controller.rs index da7ff22..d831526 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -410,10 +410,15 @@ fn pod_template(config: &WasmCloudHostConfig, _ctx: Arc) -> PodTemplate None => format!("ghcr.io/wasmcloud/wasmcloud:{}", config.spec.version), }; + let leaf_image = match &config.spec.nats_leaf_image { + Some(img) => img.clone(), + None => "nats:2.10-alpine".to_string(), + }; + let containers = vec![ Container { name: "nats-leaf".to_string(), - image: Some("nats:2.10-alpine".to_string()), + image: Some(leaf_image), args: Some(vec![ "-js".to_string(), "--config".to_string(),