From 01239b657fa6af6f807502da7dec07a10dfde4e6 Mon Sep 17 00:00:00 2001 From: hanpengfei01 Date: Tue, 14 Nov 2023 11:39:18 +0800 Subject: [PATCH] Change Probe to k8s definition --- spec/v1/application.go | 94 ++---------------------------------------- 1 file changed, 3 insertions(+), 91 deletions(-) diff --git a/spec/v1/application.go b/spec/v1/application.go index 1ad9a7f..1566e23 100644 --- a/spec/v1/application.go +++ b/spec/v1/application.go @@ -3,7 +3,7 @@ package v1 import ( "time" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" ) const ( @@ -114,7 +114,7 @@ type Service struct { Type string `json:"type,omitempty" yaml:"type,omitempty" default:"deployment"` // Probe describes a health check to be performed against a container to // determine whether it is alive or ready to receive traffic. - LivenessProbe *Probe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"` + LivenessProbe *v1.Probe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"` // Image pull policy. // One of Always, Never, IfNotPresent. ImagePullPolicy PullPolicy `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"` @@ -122,99 +122,11 @@ type Service struct { // If the ready probe fails, // the endpoint controller will remove the IP address of the Pod from the endpoints of all services that match it. // The ready state before the initial delay defaults to Failure. - ReadinessProbe *Probe `json:"readinessProbe,omitempty" yaml:"readinessProbe,omitempty"` + ReadinessProbe *v1.Probe `json:"readinessProbe,omitempty" yaml:"readinessProbe,omitempty"` } type PullPolicy string -type Probe struct { - // The action taken to determine the health of a container - ProbeHandler `json:",inline"` - // Number of seconds after the container has started before liveness probes are initiated. - InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"` - // Number of seconds after which the probe times out. - TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"` - // How often (in seconds) to perform the probe. - // Default to 10 seconds. Minimum value is 1. - PeriodSeconds int32 `json:"periodSeconds,omitempty"` - // Minimum consecutive successes for the probe to be considered successful after having failed. - // Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - SuccessThreshold int32 `json:"successThreshold,omitempty"` - // Minimum consecutive failures for the probe to be considered failed after having succeeded. - // Defaults to 3. Minimum value is 1. - FailureThreshold int32 `json:"failureThreshold,omitempty"` -} - -type ProbeHandler struct { - // HTTPGet specifies the http request to perform. - HTTPGet *HTTPGetAction `json:"httpGet,omitempty"` - // Exec specifies the action to take. - Exec *ExecAction `json:"exec,omitempty"` - // TCPSocket specifies an action involving a TCP port. - TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty"` -} - -type TCPSocketAction struct { - // Number or name 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 IntOrString `json:"port,omitempty"` - // Host name to connect to, defaults to the pod IP. - Host string `json:"host,omitempty"` -} - -type ExecAction struct { - // Command is the command line to execute inside the container, the working directory for the - // command is root ('/') in the container's filesystem. The command is simply exec'd, it is - // not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - // a shell, you need to explicitly call out to that shell. - // Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - Command []string `json:"command,omitempty"` -} - -type HTTPGetAction struct { - // Path to access on the HTTP server. - 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 IntOrString `json:"port,omitempty"` - // Host name to connect to, defaults to the pod IP. You probably want to set - Host string `json:"host,omitempty"` - // Scheme to use for connecting to the host. - Scheme URIScheme `json:"scheme,omitempty" default:"HTTP"` - // Custom headers to set in the request. HTTP allows repeated headers. - HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"` -} - -// URIScheme identifies the scheme used for connection to a host for Get actions -type URIScheme string - -const ( - // URISchemeHTTP means that the scheme used will be http:// - URISchemeHTTP URIScheme = "HTTP" - // URISchemeHTTPS means that the scheme used will be https:// - URISchemeHTTPS URIScheme = "HTTPS" -) - -type HTTPHeader struct { - Name string `json:"name"` - Value string `json:"value"` -} - -type IntOrString struct { - Type Type `json:"type"` - IntVal int32 `json:"intVal"` - StrVal string `json:"strVal"` -} - -type Type int64 - -const ( - Int Type = iota - String -) - type SecurityContext struct { Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"` }