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 19, 2022
1 parent 76a511d commit d33ead4
Show file tree
Hide file tree
Showing 8 changed files with 664 additions and 18 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
41 changes: 41 additions & 0 deletions api/v1alpha1/wildflyserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,47 @@ 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 liveness probes are initiated.
// It defaults to 60 seconds for liveness probe. It defaults to 10 seconds for readiness probe. it defaults to 0 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.
// +optional
FailureThreshold int32 `json:"failureThreshold,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.

69 changes: 68 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.

105 changes: 105 additions & 0 deletions config/crd/bases/wildfly.org_wildflyservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,73 @@ spec:
minItems: 1
type: array
x-kubernetes-list-type: atomic
livenessProbe:
description: LivenessProbe defines the periodic probe of container
liveness. Container will be restarted if the probe fails
properties:
failureThreshold:
description: Minimum consecutive failures for the probe to be
considered failed after having succeeded. Defaults to 3. Minimum
value is 1.
format: int32
type: integer
initialDelaySeconds:
description: Number of seconds after the container has started
before liveness probes are initiated. Defaults to 60 seconds.
Minimum value is 0.
format: int32
type: integer
periodSeconds:
description: How often (in seconds) to perform the probe. Default
to 10 seconds. Minimum value is 1.
format: int32
type: integer
successThreshold:
description: 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.
format: int32
type: integer
timeoutSeconds:
description: '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'
format: int32
type: integer
type: object
readinessProbe:
description: ReadinessProbe defines the periodic probe of container
service readiness. Container will be removed from service endpoints
if the probe fails.
properties:
failureThreshold:
description: Minimum consecutive failures for the probe to be
considered failed after having succeeded. Defaults to 3. Minimum
value is 1.
format: int32
type: integer
initialDelaySeconds:
description: Number of seconds after the container has started
before liveness probes are initiated. Defaults to 60 seconds.
Minimum value is 0.
format: int32
type: integer
periodSeconds:
description: How often (in seconds) to perform the probe. Default
to 10 seconds. Minimum value is 1.
format: int32
type: integer
successThreshold:
description: 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.
format: int32
type: integer
timeoutSeconds:
description: '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'
format: int32
type: integer
type: object
replicas:
description: Replicas is the desired number of replicas for the application
format: int32
Expand Down Expand Up @@ -270,6 +337,44 @@ spec:
required:
- name
type: object
startupProbe:
description: 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.
properties:
failureThreshold:
description: Minimum consecutive failures for the probe to be
considered failed after having succeeded. Defaults to 3. Minimum
value is 1.
format: int32
type: integer
initialDelaySeconds:
description: Number of seconds after the container has started
before liveness probes are initiated. Defaults to 60 seconds.
Minimum value is 0.
format: int32
type: integer
periodSeconds:
description: How often (in seconds) to perform the probe. Default
to 10 seconds. Minimum value is 1.
format: int32
type: integer
successThreshold:
description: 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.
format: int32
type: integer
timeoutSeconds:
description: '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'
format: int32
type: integer
type: object
storage:
description: StorageSpec defines specific storage required for the
server own data directory. If omitted, an EmptyDir is used (that
Expand Down
Loading

0 comments on commit d33ead4

Please sign in to comment.