From 8baa34acc7c0b9d7b6dbd231ca4827be1a92b69c Mon Sep 17 00:00:00 2001 From: Ant Weiss Date: Wed, 27 Mar 2024 16:33:50 +0200 Subject: [PATCH] Add imagePullPolicy support to spinApp spec Signed-off-by: Ant Weiss --- api/v1alpha1/spinapp_types.go | 2 ++ config/crd/bases/core.spinoperator.dev_spinapps.yaml | 3 +++ internal/controller/spinapp_controller.go | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/spinapp_types.go b/api/v1alpha1/spinapp_types.go index 0b99fc96..fc0b3b87 100644 --- a/api/v1alpha1/spinapp_types.go +++ b/api/v1alpha1/spinapp_types.go @@ -40,6 +40,8 @@ type SpinAppSpec struct { // ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling the image. ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` + // ImagePullPolicy is the policy for pulling the image. + ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` // Checks defines health checks that should be used by Kubernetes to monitor the application. Checks HealthChecks `json:"checks,omitempty"` diff --git a/config/crd/bases/core.spinoperator.dev_spinapps.yaml b/config/crd/bases/core.spinoperator.dev_spinapps.yaml index cbea19f1..ad96a45f 100644 --- a/config/crd/bases/core.spinoperator.dev_spinapps.yaml +++ b/config/crd/bases/core.spinoperator.dev_spinapps.yaml @@ -214,6 +214,9 @@ spec: image: description: Image is the source for this app. type: string + imagePullPolicy: + description: ImagePullPolicy is the policy for pulling the image. + type: string imagePullSecrets: description: ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling the image. diff --git a/internal/controller/spinapp_controller.go b/internal/controller/spinapp_controller.go index 15cc5788..274c9833 100644 --- a/internal/controller/spinapp_controller.go +++ b/internal/controller/spinapp_controller.go @@ -417,9 +417,10 @@ func constructDeployment(ctx context.Context, app *spinv1alpha1.SpinApp, config RuntimeClassName: &config.RuntimeClassName, Containers: []corev1.Container{ { - Name: app.Name, - Image: app.Spec.Image, - Command: []string{"/"}, + Name: app.Name, + Image: app.Spec.Image, + ImagePullPolicy: app.Spec.ImagePullPolicy, + Command: []string{"/"}, Ports: []corev1.ContainerPort{{ Name: spinapp.HTTPPortName, ContainerPort: spinapp.DefaultHTTPPort,