diff options
author | Piotr <piotr.skoczylas@gmail.com> | 2022-09-28 09:22:18 +0200 |
---|---|---|
committer | Piotr <piotr.skoczylas@gmail.com> | 2022-09-28 09:56:56 +0200 |
commit | 66517d86a7ab05fc39b8764c2ed5f82d091f857f (patch) | |
tree | a09673a072bb13a2c15b30747c4a71c1cf9df1f4 /pkg | |
parent | dca5ead2d7ad8ac3b14fed6736c102b571d8baf1 (diff) | |
download | podman-66517d86a7ab05fc39b8764c2ed5f82d091f857f.tar.gz podman-66517d86a7ab05fc39b8764c2ed5f82d091f857f.tar.bz2 podman-66517d86a7ab05fc39b8764c2ed5f82d091f857f.zip |
fix: kube play liveness probe http path
Use the default / for http probe path.
Update to URI schemes ensuring lowercase
Signed-off-by: Piotr <piotr.skoczylas@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/k8s.io/api/core/v1/types.go | 10 | ||||
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 8 | ||||
-rw-r--r-- | pkg/specgen/generate/kube/play_test.go | 1 |
3 files changed, 11 insertions, 8 deletions
diff --git a/pkg/k8s.io/api/core/v1/types.go b/pkg/k8s.io/api/core/v1/types.go index 6f20cd351..4447847e3 100644 --- a/pkg/k8s.io/api/core/v1/types.go +++ b/pkg/k8s.io/api/core/v1/types.go @@ -939,15 +939,15 @@ type HTTPHeader struct { // HTTPGetAction describes an action based on HTTP Get requests. type HTTPGetAction struct { - // Path to access on the HTTP server. + // Path to access on the HTTP server. Defaults to /. // +optional Path string `json:"path,omitempty"` // Name or number of the port to access on the container. // Number must be in the range 1 to 65535. // Name must be an IANA_SVC_NAME. Port intstr.IntOrString `json:"port"` - // Host name to connect to, defaults to the pod IP. You probably want to set - // "Host" in httpHeaders instead. + // Host name to connect to. You probably want to set "Host" in httpHeaders instead. + // Defaults to the pod IP in Kubernetes, in case of Podman to localhost. // +optional Host string `json:"host,omitempty"` // Scheme to use for connecting to the host. @@ -964,9 +964,9 @@ type URIScheme string const ( // URISchemeHTTP means that the scheme used will be http:// - URISchemeHTTP URIScheme = "HTTP" + URISchemeHTTP URIScheme = "http" // URISchemeHTTPS means that the scheme used will be https:// - URISchemeHTTPS URIScheme = "HTTPS" + URISchemeHTTPS URIScheme = "https" ) // TCPSocketAction describes an action based on opening a socket diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 2a0d80cb8..5186a2f72 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -507,7 +507,7 @@ func setupLivenessProbe(s *specgen.SpecGenerator, containerYAML v1.Container, re commandString = fmt.Sprintf("%s || %s", execString, failureCmd) case probeHandler.HTTPGet != nil: // set defaults as in https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#http-probes - var uriScheme v1.URIScheme = "http" + uriScheme := v1.URISchemeHTTP if probeHandler.HTTPGet.Scheme != "" { uriScheme = probeHandler.HTTPGet.Scheme } @@ -515,7 +515,11 @@ func setupLivenessProbe(s *specgen.SpecGenerator, containerYAML v1.Container, re if probeHandler.HTTPGet.Host != "" { host = probeHandler.HTTPGet.Host } - commandString = fmt.Sprintf("curl -f %s://%s:%d%s || %s", uriScheme, host, probeHandler.HTTPGet.Port.IntValue(), probeHandler.HTTPGet.Path, failureCmd) + path := "/" + if probeHandler.HTTPGet.Path != "" { + path = probeHandler.HTTPGet.Path + } + commandString = fmt.Sprintf("curl -f %s://%s:%d%s || %s", uriScheme, host, probeHandler.HTTPGet.Port.IntValue(), path, failureCmd) case probeHandler.TCPSocket != nil: commandString = fmt.Sprintf("nc -z -v %s %d || %s", probeHandler.TCPSocket.Host, probeHandler.TCPSocket.Port.IntValue(), failureCmd) } diff --git a/pkg/specgen/generate/kube/play_test.go b/pkg/specgen/generate/kube/play_test.go index efe2e51b1..adf9b979a 100644 --- a/pkg/specgen/generate/kube/play_test.go +++ b/pkg/specgen/generate/kube/play_test.go @@ -897,7 +897,6 @@ func TestHttpLivenessProbe(t *testing.T) { Handler: v1.Handler{ HTTPGet: &v1.HTTPGetAction{ Port: intstr.FromInt(80), - Path: "/", }, }, }, |