diff --git a/internal/fullnode/build_pods.go b/internal/fullnode/build_pods.go index 5c9bf630..c46571bb 100644 --- a/internal/fullnode/build_pods.go +++ b/internal/fullnode/build_pods.go @@ -30,7 +30,7 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res continue } if o.Image != "" { - pod.Spec.Containers[0].Image = o.Image + setMainContainerImage(pod, o.Image) } } pod.Annotations[configChecksumAnnotation] = cksums[client.ObjectKeyFromObject(pod)] @@ -39,6 +39,15 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res return pods, nil } +func setMainContainerImage(pod *corev1.Pod, image string) { + for i := range pod.Spec.Containers { + if pod.Spec.Containers[i].Name == mainContainer { + pod.Spec.Containers[i].Image = image + return + } + } +} + func podCandidates(crd *cosmosv1.CosmosFullNode) map[string]struct{} { candidates := make(map[string]struct{}) for _, v := range crd.Status.ScheduledSnapshotStatus { diff --git a/internal/fullnode/pod_builder.go b/internal/fullnode/pod_builder.go index 8f44b07f..67c77922 100644 --- a/internal/fullnode/pod_builder.go +++ b/internal/fullnode/pod_builder.go @@ -21,7 +21,10 @@ import ( var bufPool = sync.Pool{New: func() any { return new(bytes.Buffer) }} -const healthCheckPort = healthcheck.Port +const ( + healthCheckPort = healthcheck.Port + mainContainer = "node" +) // PodBuilder builds corev1.Pods type PodBuilder struct { @@ -65,7 +68,7 @@ func NewPodBuilder(crd *cosmosv1.CosmosFullNode) PodBuilder { Containers: []corev1.Container{ // Main start container. { - Name: "node", + Name: mainContainer, Image: tpl.Image, // The following is a useful hack if you need to inspect the PV. //Command: []string{"/bin/sh"},