diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 2451f676bf..c806760a80 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -523,6 +523,7 @@ func probeToHealthConfig(probe *v1.Probe) (*manifest.Schema2HealthConfig, error) // configure healthcheck on the basis of Handler Actions. switch { case probeHandler.Exec != nil: + // `makeHealthCheck` function can accept a json array as the command. cmd, err := json.Marshal(probeHandler.Exec.Command) if err != nil { return nil, err @@ -618,6 +619,8 @@ func makeHealthCheck(inCmd string, interval int32, retries int32, timeout int32, // ...otherwise pass it to "/bin/sh -c" inside the container cmd = []string{define.HealthConfigTestCmdShell} cmd = append(cmd, strings.Split(inCmd, " ")...) + } else { + cmd = append([]string{define.HealthConfigTestCmd}, cmd...) } } hc := manifest.Schema2HealthConfig{ diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index b10f9333cb..13dedb9a5e 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1754,7 +1754,7 @@ var _ = Describe("Podman play kube", func() { inspect.WaitWithDefaultTimeout() healthcheckcmd := inspect.OutputToString() // check if CMD-SHELL based equivalent health check is added to container - Expect(healthcheckcmd).To(ContainSubstring("[echo hello]")) + Expect(healthcheckcmd).To(ContainSubstring("[CMD echo hello]")) }) It("podman play kube liveness probe should fail", func() {