github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/pkg/apis/core/v1alpha1/probe.go (about) 1 /* 2 Copyright 2015 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha1 18 19 // Forked from 20 // https://github.com/kubernetes/api/blob/master/core/v1/types.go 21 22 // HTTPHeader describes a custom header to be used in HTTP probes 23 type HTTPHeader struct { 24 // The header field name 25 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 26 // The header field value 27 Value string `json:"value" protobuf:"bytes,2,opt,name=value"` 28 } 29 30 // HTTPGetAction describes an action based on HTTP Get requests. 31 type HTTPGetAction struct { 32 // Path to access on the HTTP server. 33 // +optional 34 Path string `json:"path,omitempty" protobuf:"bytes,1,opt,name=path"` 35 // Name or number of the port to access on the container. 36 // Number must be in the range 1 to 65535. 37 Port int32 `json:"port" protobuf:"bytes,2,opt,name=port"` 38 // Host name to connect to, defaults to the pod IP. You probably want to set 39 // "Host" in httpHeaders instead. 40 // +optional 41 Host string `json:"host,omitempty" protobuf:"bytes,3,opt,name=host"` 42 // Scheme to use for connecting to the host. 43 // Defaults to HTTP. 44 // +optional 45 Scheme URIScheme `json:"scheme,omitempty" protobuf:"bytes,4,opt,name=scheme,casttype=URIScheme"` 46 // Custom headers to set in the request. HTTP allows repeated headers. 47 // +optional 48 HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty" protobuf:"bytes,5,rep,name=httpHeaders"` 49 } 50 51 // URIScheme identifies the scheme used for connection to a host for Get actions 52 type URIScheme string 53 54 const ( 55 // URISchemeHTTP means that the scheme used will be http:// 56 URISchemeHTTP URIScheme = "HTTP" 57 // URISchemeHTTPS means that the scheme used will be https:// 58 URISchemeHTTPS URIScheme = "HTTPS" 59 ) 60 61 // TCPSocketAction describes an action based on opening a socket 62 type TCPSocketAction struct { 63 // Number or name of the port to access on the container. 64 // Number must be in the range 1 to 65535. 65 Port int32 `json:"port" protobuf:"bytes,1,opt,name=port"` 66 // Optional: Host name to connect to, defaults to the pod IP. 67 // +optional 68 Host string `json:"host,omitempty" protobuf:"bytes,2,opt,name=host"` 69 } 70 71 // ExecAction describes a "run in container" action. 72 type ExecAction struct { 73 // Command is the command line to execute inside the container, the working directory for the 74 // command is root ('/') in the container's filesystem. The command is simply exec'd, it is 75 // not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use 76 // a shell, you need to explicitly call out to that shell. 77 // Exit status of 0 is treated as live/healthy and non-zero is unhealthy. 78 // +optional 79 Command []string `json:"command,omitempty" protobuf:"bytes,1,rep,name=command"` 80 } 81 82 // Probe describes a health check to be performed to determine whether it is 83 // alive or ready to receive traffic. 84 type Probe struct { 85 // The action taken to determine the health of a container 86 Handler `json:",inline" protobuf:"bytes,1,opt,name=handler"` 87 // Number of seconds after the container has started before liveness probes are initiated. 88 // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes 89 // +optional 90 InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty" protobuf:"varint,2,opt,name=initialDelaySeconds"` 91 // Number of seconds after which the probe times out. 92 // Defaults to 1 second. Minimum value is 1. 93 // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes 94 // +optional 95 TimeoutSeconds int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,3,opt,name=timeoutSeconds"` 96 // How often (in seconds) to perform the probe. 97 // Default to 10 seconds. Minimum value is 1. 98 // +optional 99 PeriodSeconds int32 `json:"periodSeconds,omitempty" protobuf:"varint,4,opt,name=periodSeconds"` 100 // Minimum consecutive successes for the probe to be considered successful after having failed. 101 // Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. 102 // +optional 103 SuccessThreshold int32 `json:"successThreshold,omitempty" protobuf:"varint,5,opt,name=successThreshold"` 104 // Minimum consecutive failures for the probe to be considered failed after having succeeded. 105 // Defaults to 3. Minimum value is 1. 106 // +optional 107 FailureThreshold int32 `json:"failureThreshold,omitempty" protobuf:"varint,6,opt,name=failureThreshold"` 108 } 109 110 // Handler defines a specific action that should be taken in a probe. 111 type Handler struct { 112 // One and only one of the following should be specified. 113 // Exec specifies the action to take. 114 // +optional 115 Exec *ExecAction `json:"exec,omitempty" protobuf:"bytes,1,opt,name=exec"` 116 // HTTPGet specifies the http request to perform. 117 // +optional 118 HTTPGet *HTTPGetAction `json:"httpGet,omitempty" protobuf:"bytes,2,opt,name=httpGet"` 119 // TCPSocket specifies an action involving a TCP port. 120 // TCP hooks not yet supported 121 // TODO: implement a realistic TCP lifecycle hook 122 // +optional 123 TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty" protobuf:"bytes,3,opt,name=tcpSocket"` 124 }