mirror of https://github.com/containers/podman.git
Merge pull request #15968 from piotr-sk/fix/kube_play_liveness_probe_path
fix: kube play liveness probe http path
This commit is contained in:
commit
40b28dcf4d
|
@ -939,15 +939,15 @@ type HTTPHeader struct {
|
||||||
|
|
||||||
// HTTPGetAction describes an action based on HTTP Get requests.
|
// HTTPGetAction describes an action based on HTTP Get requests.
|
||||||
type HTTPGetAction struct {
|
type HTTPGetAction struct {
|
||||||
// Path to access on the HTTP server.
|
// Path to access on the HTTP server. Defaults to /.
|
||||||
// +optional
|
// +optional
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
// Name or number of the port to access on the container.
|
// Name or number of the port to access on the container.
|
||||||
// Number must be in the range 1 to 65535.
|
// Number must be in the range 1 to 65535.
|
||||||
// Name must be an IANA_SVC_NAME.
|
// Name must be an IANA_SVC_NAME.
|
||||||
Port intstr.IntOrString `json:"port"`
|
Port intstr.IntOrString `json:"port"`
|
||||||
// Host name to connect to, defaults to the pod IP. You probably want to set
|
// Host name to connect to. You probably want to set "Host" in httpHeaders instead.
|
||||||
// "Host" in httpHeaders instead.
|
// Defaults to the pod IP in Kubernetes, in case of Podman to localhost.
|
||||||
// +optional
|
// +optional
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
// Scheme to use for connecting to the host.
|
// Scheme to use for connecting to the host.
|
||||||
|
@ -964,9 +964,9 @@ type URIScheme string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// URISchemeHTTP means that the scheme used will be http://
|
// 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 means that the scheme used will be https://
|
||||||
URISchemeHTTPS URIScheme = "HTTPS"
|
URISchemeHTTPS URIScheme = "https"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TCPSocketAction describes an action based on opening a socket
|
// TCPSocketAction describes an action based on opening a socket
|
||||||
|
|
|
@ -507,7 +507,7 @@ func setupLivenessProbe(s *specgen.SpecGenerator, containerYAML v1.Container, re
|
||||||
commandString = fmt.Sprintf("%s || %s", execString, failureCmd)
|
commandString = fmt.Sprintf("%s || %s", execString, failureCmd)
|
||||||
case probeHandler.HTTPGet != nil:
|
case probeHandler.HTTPGet != nil:
|
||||||
// set defaults as in https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#http-probes
|
// 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 != "" {
|
if probeHandler.HTTPGet.Scheme != "" {
|
||||||
uriScheme = probeHandler.HTTPGet.Scheme
|
uriScheme = probeHandler.HTTPGet.Scheme
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,11 @@ func setupLivenessProbe(s *specgen.SpecGenerator, containerYAML v1.Container, re
|
||||||
if probeHandler.HTTPGet.Host != "" {
|
if probeHandler.HTTPGet.Host != "" {
|
||||||
host = 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:
|
case probeHandler.TCPSocket != nil:
|
||||||
commandString = fmt.Sprintf("nc -z -v %s %d || %s", probeHandler.TCPSocket.Host, probeHandler.TCPSocket.Port.IntValue(), failureCmd)
|
commandString = fmt.Sprintf("nc -z -v %s %d || %s", probeHandler.TCPSocket.Host, probeHandler.TCPSocket.Port.IntValue(), failureCmd)
|
||||||
}
|
}
|
||||||
|
|
|
@ -897,7 +897,6 @@ func TestHttpLivenessProbe(t *testing.T) {
|
||||||
Handler: v1.Handler{
|
Handler: v1.Handler{
|
||||||
HTTPGet: &v1.HTTPGetAction{
|
HTTPGet: &v1.HTTPGetAction{
|
||||||
Port: intstr.FromInt(80),
|
Port: intstr.FromInt(80),
|
||||||
Path: "/",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue