diff --git a/chirpstack-operator/Cargo.toml b/chirpstack-operator/Cargo.toml index a77c785..82367a7 100644 --- a/chirpstack-operator/Cargo.toml +++ b/chirpstack-operator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chirpstack-operator" -version = "0.3.3" +version = "0.3.4" authors = ["Ole Kliemann ", "Malte Groth "] edition = "2021" diff --git a/chirpstack-operator/src/builder/server/deployment.rs b/chirpstack-operator/src/builder/server/deployment.rs index 4479143..4d6f91d 100644 --- a/chirpstack-operator/src/builder/server/deployment.rs +++ b/chirpstack-operator/src/builder/server/deployment.rs @@ -36,6 +36,12 @@ pub fn build(chirpstack: &Chirpstack, dependent_hash: String) -> Deployment { chirpstack.spec.server.workload.image.tag ); + let image_pull_policy = chirpstack + .spec + .server + .workload + .image_pull_policy.to_string(); + let mut env_vars = vec![EnvVar { name: "CHIRPSTACK_SERVER_POD_NAME".to_string(), value_from: Some(k8s_openapi::api::core::v1::EnvVarSource { @@ -104,6 +110,7 @@ pub fn build(chirpstack: &Chirpstack, dependent_hash: String) -> Deployment { env_from: chirpstack.spec.server.configuration.env_from.clone(), ports: Some(ports), volume_mounts: Some(volume_mounts), + image_pull_policy: Some(image_pull_policy), ..Default::default() }; diff --git a/chirpstack-operator/src/crd.rs b/chirpstack-operator/src/crd.rs index d7abe34..7035d52 100644 --- a/chirpstack-operator/src/crd.rs +++ b/chirpstack-operator/src/crd.rs @@ -37,7 +37,7 @@ pub mod spec { } pub mod workload { - use super::super::super::types::{Image, KeyValue, WorkloadType}; + use super::super::super::types::{Image, ImagePullPolicy, KeyValue, WorkloadType}; use k8s_openapi::api::core::v1::EnvVar; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -56,6 +56,8 @@ pub mod spec { pub pod_labels: Vec, #[serde(default)] pub extra_env_vars: Vec, + #[serde(default)] + pub image_pull_policy: ImagePullPolicy, } fn default_image() -> Image { @@ -262,6 +264,21 @@ pub mod types { pub tag: String, } + #[derive(Debug, Serialize, Deserialize, Default, Clone, JsonSchema, PartialEq)] + #[serde(rename_all = "PascalCase")] + pub enum ImagePullPolicy { + #[default] + Always, + IfNotPresent, + Never, + } + + impl fmt::Display for ImagePullPolicy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{self:?}") + } + } + #[derive(Debug, Serialize, Deserialize, Default, Clone, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct KeyValue { diff --git a/config/crd/bases/applications.deepshore.de_chirpstacks.yaml b/config/crd/bases/applications.deepshore.de_chirpstacks.yaml index ed7cb77..a10f7a7 100644 --- a/config/crd/bases/applications.deepshore.de_chirpstacks.yaml +++ b/config/crd/bases/applications.deepshore.de_chirpstacks.yaml @@ -357,6 +357,13 @@ spec: - repository - tag type: object + imagePullPolicy: + default: Always + enum: + - Always + - IfNotPresent + - Never + type: string podAnnotations: default: [] items: