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 Nov 2, 2023
1 parent fab0001 commit 69b75f4
Show file tree
Hide file tree
Showing 9 changed files with 1,011 additions and 28 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 \
JBOSS_BOOTABLE_HOME=/opt/jboss/container/wildfly-bootable-jar-server \
OPERATOR_NAME=wildfly-operator \
go run ./main.go

.PHONY: docker-build
docker-build: unit-test ## Build docker image with the manager.
Expand Down
47 changes: 47 additions & 0 deletions api/v1alpha1/wildflyserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,53 @@ 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. Notice these fields are not exposed to the user since they are an implementation detail
// that depends on the server image used to create the application image.
// +k8s:openapi-gen=true
type ProbeSpec struct {
// 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"`
// Depending on the kind of base application image, the Operator will configure an HTTP or Exec probe. For example, to keep compatibility mode with legacy servers, all non-Bootable JAR based application images
// will be configured to use Exec probes by default. This flag allows you to force switching the probe configuration to use an HTTP request instead of executing a script. Notice this flag works in one way only, configuring http:false
// does not imply the probe will be forced to switch to an Exec probe instead of HTTP one.
// +optional
Http bool `json:"http,omitempty"`
}

// StandaloneConfigMapSpec defines the desired configMap configuration to obtain the standalone configuration for WildFlyServer
Expand Down
30 changes: 30 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.

76 changes: 75 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 69b75f4

Please sign in to comment.