Skip to content

fix(kube): export container healthcheck as LivenessProbe in generate kube#28415

Closed
DeveshB-1 wants to merge 2 commits into
containers:mainfrom
DeveshB-1:fix/generate-kube-healthcheck
Closed

fix(kube): export container healthcheck as LivenessProbe in generate kube#28415
DeveshB-1 wants to merge 2 commits into
containers:mainfrom
DeveshB-1:fix/generate-kube-healthcheck

Conversation

@DeveshB-1
Copy link
Copy Markdown
Contributor

When a container is created with --health-cmd, podman kube generate
did not include the healthcheck in the generated YAML. The LivenessProbe
field in the output pod spec was always absent.

Fix: add healthConfigToProbe() in libpod/kube.go that converts a
manifest.Schema2HealthConfig to a v1.Probe, and call it from
containerToV1Container to populate LivenessProbe.

The mapping is straightforward:

  • Test[1:] -> exec.command (Test[0] is the type: CMD or CMD-SHELL)
  • Interval -> periodSeconds
  • Timeout -> timeoutSeconds
  • Retries -> failureThreshold
  • StartPeriod -> initialDelaySeconds

Containers with NONE healthcheck (disabled) produce no probe.

Fixes: #22095
Signed-off-by: Devesh B 98201065+DeveshB-1@users.noreply.github.com

…kube

Signed-off-by: Devesh B <98201065+DeveshB-1@users.noreply.github.com>
Signed-off-by: Devesh B <98201065+DeveshB-1@users.noreply.github.com>
Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do a review after CI is green, except for flakes.

+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux
test/e2e/generate_kube_test.go:2037:1: File is not properly formatted (gofumpt)

^
test/e2e/generate_kube_test.go:2038:1: File is not properly formatted (goimports)
})
^

Comment thread libpod/kube.go
return nil
}
// Test[0] is the type: NONE, CMD, or CMD-SHELL. NONE means disabled.
if hc.Test[0] == define.HealthConfigTestNone {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine this with the first conditional

Comment thread libpod/kube.go
}
probe := &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{Command: hc.Test[1:]},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be handling CMD and CMD-SHELL separately here? In CMD-SHELL we want to wrap this with a shell

Expect(probe.InitialDelaySeconds).To(Equal(int32(2)))
})

}) No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ending newline

@givensuman
Copy link
Copy Markdown
Contributor

Hello @DeveshB-1, I'd love to see this feature merged. Would you be alright with me taking over the issue?

@Honny1
Copy link
Copy Markdown
Member

Honny1 commented Apr 29, 2026

Since the last activity was about a month ago, I think you can take this over, @givensuman.

@danishprakash
Copy link
Copy Markdown
Member

Closing in favor of #28664

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kube playbook doesn't contain healthchecks

5 participants