Skip to content

Commit

Permalink
[234] Add the ability to configure the Readiness, Liveness and Startu…
Browse files Browse the repository at this point in the history
…p probes
  • Loading branch information
yersan committed Dec 14, 2023
1 parent a157f50 commit a4764d0
Show file tree
Hide file tree
Showing 9 changed files with 1,577 additions and 50 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ build: manifests generate openapi fmt vet ## Build manager binary.

.PHONY: run
run: manifests generate openapi fmt vet ## Run a controller from your host.
go run ./main.go
JBOSS_HOME=/wildfly \
JBOSS_BOOTABLE_DATA_DIR=/opt/jboss/container/wildfly-bootable-jar-data \
OPERATOR_NAME=wildfly-operator \
JBOSS_BOOTABLE_HOME=/opt/jboss/container/wildfly-bootable-jar-server \
go run ./main.go

.PHONY: docker-build
docker-build: unit-test ## Build docker image with the manager.
Expand Down
55 changes: 55 additions & 0 deletions api/v1alpha1/wildflyserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,61 @@ type WildFlyServerSpec struct {
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
// SecurityContext defines the security capabilities required to run the application.
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
// LivenessProbe defines the periodic probe of container liveness. Container will be restarted if the probe fails.
LivenessProbe *ProbeSpec `json:"livenessProbe,omitempty"`
// ReadinessProbe defines the periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails.
ReadinessProbe *ProbeSpec `json:"readinessProbe,omitempty"`
// StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully.
// If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod's lifecycle,
// when it might take a long time to load data or warm a cache, than during steady-state operation.
StartupProbe *ProbeSpec `json:"startupProbe,omitempty"`
}

// ProbeSpec describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.
// The Operator will configure the exec/httpGet fields if they are not explicitly defined in the probe.
// +k8s:openapi-gen=true
type ProbeSpec struct {
// The action taken to determine the health of a container
ProbeHandler `json:",inline,omitempty" protobuf:"bytes,1,opt,name=handler"`
// Number of seconds after the container has started before probes are initiated.
// It defaults to 60 seconds for liveness probe. It defaults to 10 seconds for readiness probe. It defaults to 0 seconds for startup probe.
// Minimum value is 0.
// +kubebuilder:validation:Minimum=0
// +optional
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
// Number of seconds after which the probe times out.
// Defaults to 1 second. Minimum value is 1.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
// +kubebuilder:validation:Minimum=1
// +optional
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
// How often (in seconds) to perform the probe.
// Default to 10 seconds. Minimum value is 1.
// +kubebuilder:validation:Minimum=1
// +optional
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.
// +kubebuilder:validation:Minimum=1
// +optional
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.
// +kubebuilder:validation:Minimum=1
// +optional
FailureThreshold int32 `json:"failureThreshold,omitempty"`
}

// ProbeHandler defines a specific action between Exec or HTTPGet that should be taken in a probe.
// If Exec and HTTPGet handlers are both defined, the Operator will configure the Exec handler and will ignore the
// HTTPGet one.
type ProbeHandler struct {
// Exec specifies a command action to take.
// +optional
Exec *corev1.ExecAction `json:"exec,omitempty" protobuf:"bytes,1,opt,name=exec"`
// HTTPGet specifies the http request to perform.
// +optional
HTTPGet *corev1.HTTPGetAction `json:"httpGet,omitempty" protobuf:"bytes,2,opt,name=httpGet"`
}

// StandaloneConfigMapSpec defines the desired configMap configuration to obtain the standalone configuration for WildFlyServer
Expand Down
56 changes: 56 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 82 additions & 1 deletion api/v1alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a4764d0

Please sign in to comment.