Skip to content

Commit

Permalink
Merge pull request #396 from teodor-pripoae/image-pull-policy
Browse files Browse the repository at this point in the history
fix: add support for imagePullPolicy for installer daemonsets (#395)
  • Loading branch information
bpradipt authored Oct 17, 2024
2 parents 0b03e9b + 9e25c3a commit 40240ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv
{
Name: "cc-runtime-install-pod",
Image: r.ccRuntime.Spec.Config.PayloadImage,
ImagePullPolicy: "Always",
ImagePullPolicy: imagePullPolicyOrDefault(r.ccRuntime.Spec.Config.ImagePullPolicy),
Lifecycle: preStopHook,
SecurityContext: &corev1.SecurityContext{
// TODO - do we really need to run as root?
Expand Down Expand Up @@ -917,7 +917,7 @@ func (r *CcRuntimeReconciler) makeHookDaemonset(operation DaemonOperation) *apps
{
Name: "cc-runtime-" + string(operation) + "-pod",
Image: image,
ImagePullPolicy: "Always",
ImagePullPolicy: imagePullPolicyOrDefault(r.ccRuntime.Spec.Config.ImagePullPolicy),
SecurityContext: &corev1.SecurityContext{
Privileged: &runPrivileged,
RunAsUser: &runAsUser,
Expand Down
13 changes: 13 additions & 0 deletions controllers/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package controllers

import (
corev1 "k8s.io/api/core/v1"
)

// DaemonOperation represents the operation the daemon is going to perform
type DaemonOperation string

Expand All @@ -26,6 +30,8 @@ const (
UpgradeOperation DaemonOperation = "upgrade"

RuntimeConfigFinalizer = "runtimeconfig.confidentialcontainers.org/finalizer"

DefaultImagePullPolicy = corev1.PullAlways
)

func contains(list []string, s string) bool {
Expand All @@ -36,3 +42,10 @@ func contains(list []string, s string) bool {
}
return false
}

func imagePullPolicyOrDefault(policy corev1.PullPolicy) corev1.PullPolicy {
if policy == "" {
return DefaultImagePullPolicy
}
return policy
}

0 comments on commit 40240ab

Please sign in to comment.