diff --git a/pkg/components/combined.go b/pkg/components/combined.go index cf2d6b3b4a..092e504ab1 100644 --- a/pkg/components/combined.go +++ b/pkg/components/combined.go @@ -18,9 +18,12 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" ) -// CalicoBinaryPath is the absolute path to the combined "calico" binary inside the calico/calico image. -// Components deployed from the combined image invoke this binary via Command / probe exec. -const CalicoBinaryPath = "/usr/bin/calico" +// CalicoBinaryPath is the command used to invoke the combined "calico" binary inside +// the calico/calico image. Bare command so it resolves via PATH, which keeps us +// agnostic to where the binary actually lives — both the legacy Dockerfile build +// (/usr/bin/calico) and the ko-built image (/ko-app/calico) put the containing +// directory on PATH. +const CalicoBinaryPath = "calico" // CombinedCalicoImage returns the combined calico/calico Component for the given installation. // The right Component is selected based on the installation variant (Calico OSS vs. Calico Enterprise) diff --git a/pkg/render/apiserver_test.go b/pkg/render/apiserver_test.go index f98a4f35c2..af9e6b2836 100644 --- a/pkg/render/apiserver_test.go +++ b/pkg/render/apiserver_test.go @@ -1932,7 +1932,7 @@ var _ = Describe("API server rendering tests (Calico)", func() { Expect(d.Spec.Template.Spec.Containers[0].Image).To(Equal( fmt.Sprintf("testregistry.com/%s%s:%s", components.CalicoImagePath, components.ComponentCalico.Image, components.ComponentCalico.Version), )) - Expect(d.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"/usr/bin/calico", "component", "apiserver"})) + Expect(d.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"calico", "component", "apiserver"})) expectedArgs := []string{ "--secure-port=5443", diff --git a/pkg/render/csi.go b/pkg/render/csi.go index 0fc7a81f04..d6d96874fb 100644 --- a/pkg/render/csi.go +++ b/pkg/render/csi.go @@ -182,7 +182,7 @@ func (c *csiComponent) csiContainers() []corev1.Container { registrarContainer := corev1.Container{ Name: CSIRegistrarContainerName, Image: c.csiRegistrarImage, - Command: []string{"/usr/bin/csi-node-driver-registrar"}, + Command: []string{"csi-node-driver-registrar"}, Args: []string{ "--v=5", "--csi-address=$(ADDRESS)", diff --git a/pkg/render/goldmane/component_test.go b/pkg/render/goldmane/component_test.go index 6d3f33e845..1952d2c1f4 100644 --- a/pkg/render/goldmane/component_test.go +++ b/pkg/render/goldmane/component_test.go @@ -141,7 +141,7 @@ var _ = Describe("ComponentRendering", func() { { Name: goldmane.GoldmaneContainerName, Image: "quay.io/calico/calico:master", - Command: []string{"/usr/bin/calico", "component", "goldmane"}, + Command: []string{"calico", "component", "goldmane"}, Env: []corev1.EnvVar{ {Name: "LOG_LEVEL", Value: "INFO"}, {Name: "PORT", Value: "7443"}, @@ -155,13 +155,13 @@ var _ = Describe("ComponentRendering", func() { SecurityContext: securitycontext.NewNonRootContext(), ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{ - Command: []string{"/usr/bin/calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=readiness"}, + Command: []string{"calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=readiness"}, }}, PeriodSeconds: 10, }, LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{ - Command: []string{"/usr/bin/calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=liveness"}, + Command: []string{"calico", "health", fmt.Sprintf("--port=%d", goldmane.GoldmaneHealthPort), "--type=liveness"}, }}, PeriodSeconds: 10, }, diff --git a/pkg/render/kubecontrollers/kube-controllers_test.go b/pkg/render/kubecontrollers/kube-controllers_test.go index 0f673a2280..8ea57605b6 100644 --- a/pkg/render/kubecontrollers/kube-controllers_test.go +++ b/pkg/render/kubecontrollers/kube-controllers_test.go @@ -195,9 +195,9 @@ var _ = Describe("kube-controllers rendering tests", func() { )) // Verify command and probes use the combined image entrypoint with generic health check. - Expect(ds.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"/usr/bin/calico", "component", "kube-controllers", "--health-port=9440"})) - Expect(ds.Spec.Template.Spec.Containers[0].ReadinessProbe.Exec.Command).To(Equal([]string{"/usr/bin/calico", "health", "--port=9440", "--type=readiness"})) - Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(Equal([]string{"/usr/bin/calico", "health", "--port=9440", "--type=liveness"})) + Expect(ds.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"calico", "component", "kube-controllers", "--health-port=9440"})) + Expect(ds.Spec.Template.Spec.Containers[0].ReadinessProbe.Exec.Command).To(Equal([]string{"calico", "health", "--port=9440", "--type=readiness"})) + Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(Equal([]string{"calico", "health", "--port=9440", "--type=liveness"})) // Verify env expectedEnv := []corev1.EnvVar{ diff --git a/pkg/render/logstorage/esmetrics/elasticsearch_metrics_test.go b/pkg/render/logstorage/esmetrics/elasticsearch_metrics_test.go index 6f28603c58..908eb96eb8 100644 --- a/pkg/render/logstorage/esmetrics/elasticsearch_metrics_test.go +++ b/pkg/render/logstorage/esmetrics/elasticsearch_metrics_test.go @@ -165,7 +165,7 @@ var _ = Describe("Elasticsearch metrics", func() { Containers: []corev1.Container{{ Name: ElasticsearchMetricsName, Image: "testregistry.com/tigera/calico@testdigest", - Command: []string{"/usr/bin/calico", "component", "elasticsearch-metrics"}, + Command: []string{"calico", "component", "elasticsearch-metrics"}, Args: []string{ "--es.uri=https://$(ELASTIC_USERNAME):$(ELASTIC_PASSWORD)@$(ELASTIC_HOST):$(ELASTIC_PORT)", "--es.all", "--es.indices", "--es.indices_settings", "--es.shards", "--es.cluster_settings", diff --git a/pkg/render/manager_test.go b/pkg/render/manager_test.go index d9f00ee20a..3c7c4311d4 100644 --- a/pkg/render/manager_test.go +++ b/pkg/render/manager_test.go @@ -203,9 +203,9 @@ var _ = Describe("Tigera Secure Manager rendering tests", func() { Expect(dashboard.VolumeMounts[1].MountPath).To(Equal(fmt.Sprintf("/%s", render.ManagerInternalTLSSecretName))) Expect(dashboard.ReadinessProbe).NotTo(BeNil()) - Expect(dashboard.ReadinessProbe.ProbeHandler.Exec.Command).To(Equal([]string{"/usr/bin/calico", "component", "dashboards", "ready"})) + Expect(dashboard.ReadinessProbe.ProbeHandler.Exec.Command).To(Equal([]string{"calico", "component", "dashboards", "ready"})) Expect(dashboard.LivenessProbe).NotTo(BeNil()) - Expect(dashboard.LivenessProbe.ProbeHandler.Exec.Command).To(Equal([]string{"/usr/bin/calico", "component", "dashboards", "ready"})) + Expect(dashboard.LivenessProbe.ProbeHandler.Exec.Command).To(Equal([]string{"calico", "component", "dashboards", "ready"})) Expect(dashboard.SecurityContext).NotTo(BeNil()) Expect(*dashboard.SecurityContext.AllowPrivilegeEscalation).To(BeFalse()) diff --git a/pkg/render/node_test.go b/pkg/render/node_test.go index e7a4ba37d4..0eb107d587 100644 --- a/pkg/render/node_test.go +++ b/pkg/render/node_test.go @@ -3320,11 +3320,11 @@ func verifyProbesAndLifecycle(ds *appsv1.DaemonSet, isOpenshift, isEnterprise bo var expectedReadinessCmd []string switch { case !bgp: - expectedReadinessCmd = []string{"/usr/bin/calico", "component", "node", "health", "--felix-ready"} + expectedReadinessCmd = []string{"calico", "component", "node", "health", "--felix-ready"} case bgp && isEnterprise: - expectedReadinessCmd = []string{"/usr/bin/calico", "component", "node", "health", "--bird-ready", "--felix-ready", "--bgp-metrics-ready"} + expectedReadinessCmd = []string{"calico", "component", "node", "health", "--bird-ready", "--felix-ready", "--bgp-metrics-ready"} case bgp: - expectedReadinessCmd = []string{"/usr/bin/calico", "component", "node", "health", "--bird-ready", "--felix-ready"} + expectedReadinessCmd = []string{"calico", "component", "node", "health", "--bird-ready", "--felix-ready"} } expectedReadiness.ProbeHandler = corev1.ProbeHandler{Exec: &corev1.ExecAction{Command: expectedReadinessCmd}} @@ -3333,7 +3333,7 @@ func verifyProbesAndLifecycle(ds *appsv1.DaemonSet, isOpenshift, isEnterprise bo expectedLifecycle := &corev1.Lifecycle{ PreStop: &corev1.LifecycleHandler{Exec: &corev1.ExecAction{ - Command: []string{"/usr/bin/calico", "component", "node", "shutdown"}, + Command: []string{"calico", "component", "node", "shutdown"}, }}, } ExpectWithOffset(1, ds.Spec.Template.Spec.Containers[0].Lifecycle).To(Equal(expectedLifecycle)) @@ -3411,7 +3411,7 @@ func verifyInitContainers(ds *appsv1.DaemonSet, instance *operatorv1.Installatio cniImage = fmt.Sprintf("%s%s%s:%s", components.TigeraRegistry, components.TigeraImagePath, components.ComponentTigeraCalico.Image, components.ComponentTigeraCalico.Version) } Expect(cniContainer.Image).To(Equal(cniImage)) - Expect(cniContainer.Command).To(Equal([]string{"/usr/bin/calico", "component", "cni", "install"})) + Expect(cniContainer.Command).To(Equal([]string{"calico", "component", "cni", "install"})) Expect(*cniContainer.SecurityContext.AllowPrivilegeEscalation).To(BeTrue()) Expect(*cniContainer.SecurityContext.Privileged).To(BeTrue()) Expect(*cniContainer.SecurityContext.RunAsGroup).To(BeEquivalentTo(0)) @@ -3471,7 +3471,7 @@ func verifyInitContainers(ds *appsv1.DaemonSet, instance *operatorv1.Installatio Expect(ebpfBootstrap.Image).To(Equal(ebpfImage)) if instance.CalicoNetwork != nil { bpf := instance.CalicoNetwork.LinuxDataplane != nil && *instance.CalicoNetwork.LinuxDataplane == operatorv1.LinuxDataplaneBPF - expectedEbpfCmd := []string{"/usr/bin/calico", "component", "node", "init"} + expectedEbpfCmd := []string{"calico", "component", "node", "init"} if !bpf { expectedEbpfCmd = append(expectedEbpfCmd, "--best-effort") } @@ -3503,7 +3503,7 @@ func verifyInitContainers(ds *appsv1.DaemonSet, instance *operatorv1.Installatio } else { Expect(flexvolContainer.Image).To(Equal(fmt.Sprintf("quay.io/%s%s:%s", components.CalicoImagePath, components.ComponentCalico.Image, components.ComponentCalico.Version))) } - Expect(flexvolContainer.Command).To(Equal([]string{"/usr/bin/calico", "component", "flexvol", "install", "--target", "/host/driver/uds"})) + Expect(flexvolContainer.Command).To(Equal([]string{"calico", "component", "flexvol", "install", "--target", "/host/driver/uds"})) Expect(*flexvolContainer.SecurityContext.AllowPrivilegeEscalation).To(BeTrue()) Expect(*flexvolContainer.SecurityContext.Privileged).To(BeTrue()) diff --git a/pkg/render/webhooks/render_test.go b/pkg/render/webhooks/render_test.go index ca799fe518..9bde01549a 100644 --- a/pkg/render/webhooks/render_test.go +++ b/pkg/render/webhooks/render_test.go @@ -101,7 +101,7 @@ var _ = Describe("Webhooks rendering tests", func() { components.CalicoImagePath, components.ComponentCalico.Image, components.ComponentCalico.Version))) - Expect(dep.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"/usr/bin/calico", "component", "webhooks"})) + Expect(dep.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"calico", "component", "webhooks"})) // Verify the ClusterRole includes expected rules. cr := rtest.GetResource(resources, webhooks.WebhooksName, "", "rbac.authorization.k8s.io", "v1", "ClusterRole").(*rbacv1.ClusterRole) diff --git a/pkg/render/whisker/component_test.go b/pkg/render/whisker/component_test.go index 3fae01728c..82debe89f2 100644 --- a/pkg/render/whisker/component_test.go +++ b/pkg/render/whisker/component_test.go @@ -138,7 +138,7 @@ var _ = Describe("ComponentRendering", func() { { Name: whisker.WhiskerBackendContainerName, Image: "quay.io/calico/calico:master", - Command: []string{"/usr/bin/calico", "component", "whisker-backend"}, + Command: []string{"calico", "component", "whisker-backend"}, Env: []corev1.EnvVar{ {Name: "LOG_LEVEL", Value: "INFO"}, {Name: "PORT", Value: "3002"},