Skip to content

Commit

Permalink
Added liveness, readiness and startup Probe configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
yersan committed Oct 28, 2022
1 parent 76a511d commit 047d072
Show file tree
Hide file tree
Showing 9 changed files with 852 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.17.7 as builder
FROM golang:1.17.13 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ build: vendor generate fmt vet openapi ## Build manager binary.

.PHONY: run
run: manifests generate 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 SERVER_LIVENESS_SCRIPT=liveness.sh SERVER_READINESS_SCRIPT=readiness.sh go run ./main.go

# Run the manager with debug enabled
debug: dlv generate fmt vet manifests
Expand Down
48 changes: 48 additions & 0 deletions api/v1alpha1/wildflyserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,54 @@ type WildFlyServerSpec struct {
// ResourcesSpec defines the resources used by the WildFlyServer, ie CPU and memory, use limits and requests.
// More info: https://pkg.go.dev/k8s.io/[email protected]/core/v1#ResourceRequirements
Resources *corev1.ResourceRequirements `json:"resources,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
// +kubebuilder:default:=false
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 047d072

Please sign in to comment.