diff --git a/internal/cnpgi/operator/lifecycle.go b/internal/cnpgi/operator/lifecycle.go index e29aa1c..34ca43f 100644 --- a/internal/cnpgi/operator/lifecycle.go +++ b/internal/cnpgi/operator/lifecycle.go @@ -336,7 +336,15 @@ func InjectPluginSidecarPodSpec( if spec.Containers[i].Name == mainContainerName { volumeMounts = spec.Containers[i].VolumeMounts mainContainerFound = true - } else if spec.Containers[i].Name == sidecar.Name { + } + } + + if !mainContainerFound { + return errors.New("main container not found") + } + + for i := range spec.InitContainers { + if spec.InitContainers[i].Name == sidecar.Name { sidecarContainerFound = true } } @@ -346,10 +354,6 @@ func InjectPluginSidecarPodSpec( return nil } - if !mainContainerFound { - return errors.New("main container not found") - } - // Do not modify the passed sidecar definition if injectMainContainerVolumes { sidecar.VolumeMounts = append(sidecar.VolumeMounts, volumeMounts...) diff --git a/scripts/run.sh b/scripts/run.sh index 0dceefb..6e88bc8 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -13,8 +13,8 @@ MYTMPDIR="$(mktemp -d)" trap 'rm -rf -- "$MYTMPDIR"' EXIT current_context=$(kubectl config view --raw -o json | jq -r '."current-context"' | sed "s/kind-//") -operator_image=$(KIND_CLUSTER_NAME="$current_context" KO_DOCKER_REPO=kind.local ko build -BP ./cmd/operator) -instance_image=$(KIND_CLUSTER_NAME="$current_context" KO_DOCKER_REPO=kind.local KO_DEFAULTBASEIMAGE="ghcr.io/cloudnative-pg/postgresql:17.0" ko build -BP ./cmd/instance) +operator_image=$(KIND_CLUSTER_NAME="$current_context" KO_DOCKER_REPO=kind.local ko build -BP ./cmd/manager) +instance_image=$(KIND_CLUSTER_NAME="$current_context" KO_DOCKER_REPO=kind.local KO_DEFAULTBASEIMAGE="ghcr.io/cloudnative-pg/postgresql:17.0" ko build -BP ./cmd/manager) # Now we deploy the plugin inside the `cnpg-system` workspace (