Skip to content

Extend the Probe interface to support optional path, port and scheme properties #454

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions api/v1/openlibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ type OpenLibertyApplicationServiceAccount struct {
type OpenLibertyApplicationProbes struct {
// Periodic probe of container liveness. Container will be restarted if the probe fails.
// +operator-sdk:csv:customresourcedefinitions:order=49,type=spec,displayName="Liveness Probe"
Liveness *corev1.Probe `json:"liveness,omitempty"`
Liveness *common.BaseComponentProbe `json:"liveness,omitempty"`

// Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails.
// +operator-sdk:csv:customresourcedefinitions:order=50,type=spec,displayName="Readiness Probe"
Readiness *corev1.Probe `json:"readiness,omitempty"`
Readiness *common.BaseComponentProbe `json:"readiness,omitempty"`

// Probe to determine successful initialization. If specified, other probes are not executed until this completes successfully.
// +operator-sdk:csv:customresourcedefinitions:order=51,type=spec,displayName="Startup Probe"
Startup *corev1.Probe `json:"startup,omitempty"`
Startup *common.BaseComponentProbe `json:"startup,omitempty"`
}

// Configure pods to run on particular Nodes.
Expand Down Expand Up @@ -697,32 +697,32 @@ func (cr *OpenLibertyApplication) GetProbes() common.BaseComponentProbes {
}

// GetLivenessProbe returns liveness probe
func (p *OpenLibertyApplicationProbes) GetLivenessProbe() *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetLivenessProbe() *common.BaseComponentProbe {
return p.Liveness
}

// GetReadinessProbe returns readiness probe
func (p *OpenLibertyApplicationProbes) GetReadinessProbe() *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetReadinessProbe() *common.BaseComponentProbe {
return p.Readiness
}

// GetStartupProbe returns startup probe
func (p *OpenLibertyApplicationProbes) GetStartupProbe() *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetStartupProbe() *common.BaseComponentProbe {
return p.Startup
}

// GetDefaultLivenessProbe returns default values for liveness probe
func (p *OpenLibertyApplicationProbes) GetDefaultLivenessProbe(ba common.BaseComponent) *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetDefaultLivenessProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileLivenessProbe(ba)
}

// GetDefaultReadinessProbe returns default values for readiness probe
func (p *OpenLibertyApplicationProbes) GetDefaultReadinessProbe(ba common.BaseComponent) *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetDefaultReadinessProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileReadinessProbe(ba)
}

// GetDefaultStartupProbe returns default values for startup probe
func (p *OpenLibertyApplicationProbes) GetDefaultStartupProbe(ba common.BaseComponent) *corev1.Probe {
func (p *OpenLibertyApplicationProbes) GetDefaultStartupProbe(ba common.BaseComponent) *common.BaseComponentProbe {
return common.GetDefaultMicroProfileStartupProbe(ba)
}

Expand Down
6 changes: 3 additions & 3 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion api/v1beta2/openlibertyapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1beta2
import (
"time"

"github.com/application-stacks/runtime-component-operator/common"
common "github.com/application-stacks/runtime-component-operator/common_v1beta2"
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3148,8 +3148,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3299,8 +3297,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3451,8 +3447,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/open-liberty.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ metadata:
categories: Application Runtime
certified: "true"
containerImage: icr.io/appcafe/open-liberty-operator:daily
createdAt: "2024-05-07T18:53:56Z"
createdAt: "2024-05-16T17:00:41Z"
description: Deploy and manage containerized Liberty applications
olm.skipRange: '>=0.8.0 <1.3.2'
operators.openshift.io/infrastructure-features: '["disconnected"]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3295,8 +3293,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3447,8 +3443,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down
62 changes: 61 additions & 1 deletion doc/user-guide-v1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ spec:
initialDelaySeconds: 90
----

When a probe **initialDelaySeconds** parameter is set to `0`, the default value is used. To set a probe initial delay to `0`, define the probe instead of using the default probe. The following example overrides the default value and sets the initial delay to `0`.
When a probe **initialDelaySeconds** parameter is set to `0`, the default value is used. To set a probe initial delay to `0`, define the probe instead of using the default probe. The following example overrides the default value and sets the initial delay to `0`. The same will also apply to properties **timeoutSeconds**, **periodSeconds**, **successThreshold**, and **failureThreshold**.

[source,yaml]
----
Expand All @@ -1063,6 +1063,66 @@ spec:
initialDelaySeconds: 0
----

Starting in version 1.4.0, you can now specify optional parameters for HTTPGetAction's under `.spec.probes.*.httpGet` for the `startup`, `liveness` and `readiness` probes.

- If `.spec.probes.*.httpGet.path` is not specified, the default paths listed above will be used.

- If `.spec.probes.*.httpGet.port` is not specified, the value of `.spec.service.port` will be used.

- If `.spec.probes.*.httpGet.scheme` is not specified, when `.spec.manageTLS` is `true` (or uninitialized) `HTTPS` will be used and when set to `false`, `HTTP` will be used.

For instance, when `.spec.manageTLS` is set to `true` (or uninitialized)
[source,yaml]
----
spec:
probes:
liveness:
httpGet: {}
manageTLS: true
service:
port: 9443
----
It produces a liveness probe configuration such as below:
[source,yaml]
----
livenessProbe:
httpGet:
path: /health/live # Default path for liveness probe
port: 9443 # Value of .spec.service.port
scheme: HTTPS # .spec.manageTLS is true
initialDelaySeconds: 60
timeoutSeconds: 2
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
----

Additionally, in a configuration where `.spec.manageTLS` is `false` and using `.service.port` as `9080`
[source,yaml]
----
spec:
probes:
liveness:
httpGet: {}
manageTLS: false
service:
port: 9080
----
The following liveness probe is generated:
[source,yaml]
----
livenessProbe:
httpGet:
path: /health/live # Default path for liveness probe
port: 9080 # Value of .spec.service.port
scheme: HTTP # .spec.manageTLS is false
initialDelaySeconds: 60
timeoutSeconds: 2
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
----

[[deploy-serverless-applications-with-knative]]
=== Deploy serverless applications with Knative (`.spec.createKnativeService`)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/OpenLiberty/open-liberty-operator
go 1.21

require (
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240506212440-64262a90d207
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240516142046-336488006a05
github.com/cert-manager/cert-manager v1.11.5
github.com/go-logr/logr v1.2.4
github.com/openshift/api v0.0.0-20230928134114-673ed0cfc7f1
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240506212440-64262a90d207 h1:qTK4Z4ICPukshCUW6oIyHmX22iWwd/CqF0WXjlZTPM4=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240506212440-64262a90d207/go.mod h1:SCojMAukVov6aOA8VEjpr0nLcheOrtoAVUGRvLT9qyI=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240514135533-812d07575e8c h1:XSLTxOd3Y76jE8bXMb/sIX6LEyH4MbsrKug/diVh7Wg=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240514135533-812d07575e8c/go.mod h1:SCojMAukVov6aOA8VEjpr0nLcheOrtoAVUGRvLT9qyI=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240515205711-ea15efc009bc h1:ZO6TmqetJSRPah1luUsyG9On5N9XRm3/IBKsbsLLOwM=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240515205711-ea15efc009bc/go.mod h1:SCojMAukVov6aOA8VEjpr0nLcheOrtoAVUGRvLT9qyI=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240516142046-336488006a05 h1:FPa3upDX4TvTDgRF+NXoUMhPsFb7YVhvld/pUN7r23A=
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20240516142046-336488006a05/go.mod h1:SCojMAukVov6aOA8VEjpr0nLcheOrtoAVUGRvLT9qyI=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down
6 changes: 0 additions & 6 deletions internal/deploy/kubectl/openliberty-app-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3147,8 +3147,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3298,8 +3296,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3450,8 +3446,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down
6 changes: 0 additions & 6 deletions internal/deploy/kustomize/daily/base/open-liberty-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3147,8 +3147,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3298,8 +3296,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down Expand Up @@ -3450,8 +3446,6 @@ spec:
description: Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
initialDelaySeconds:
description: 'Number of seconds after the container has started
Expand Down