Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Probe to k8s definition #455

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 3 additions & 91 deletions spec/v1/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import (
"time"

v1 "k8s.io/api/core/v1"
"k8s.io/api/core/v1"
)

const (
Expand Down Expand Up @@ -114,107 +114,19 @@ 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"`
// Indicates whether the container is ready for service requests.
// 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"`
}
Expand Down
Loading