Add liveness and readiness probes (#598)

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/599/head
Anatolii Bazko 2020-12-30 12:51:46 +02:00 committed by GitHub
parent d37acdd92f
commit 39b7a1e7b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 8 deletions

View File

@ -35,6 +35,7 @@ import (
sdkVersion "github.com/operator-framework/operator-sdk/version" sdkVersion "github.com/operator-framework/operator-sdk/version"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals" "sigs.k8s.io/controller-runtime/pkg/manager/signals"
) )
@ -115,7 +116,11 @@ func main() {
defer r.Unset() defer r.Unset()
// Create a new Cmd to provide shared dependencies and start components // Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{Namespace: namespace}) options := manager.Options{
Namespace: namespace,
HealthProbeBindAddress: ":6789",
}
mgr, err := manager.New(cfg, options)
if err != nil { if err != nil {
log.Error(err, "") log.Error(err, "")
os.Exit(1) os.Exit(1)
@ -155,6 +160,16 @@ func main() {
os.Exit(1) os.Exit(1)
} }
// Setup health checks
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
log.Error(err, "Unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
log.Error(err, "Unable to set up ready check")
os.Exit(1)
}
logrus.Info("Starting the Cmd") logrus.Info("Starting the Cmd")
// Start the Cmd // Start the Cmd

View File

@ -84,13 +84,13 @@ metadata:
categories: Developer Tools categories: Developer Tools
certified: "false" certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2020-12-17T10:09:13Z" createdAt: "2020-12-29T12:54:43Z"
description: A Kube-native development solution that delivers portable and collaborative description: A Kube-native development solution that delivers portable and collaborative
developer workspaces. developer workspaces.
operatorframework.io/suggested-namespace: eclipse-che operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse/che-operator repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation support: Eclipse Foundation
name: eclipse-che-preview-kubernetes.v7.24.0-52.nightly name: eclipse-che-preview-kubernetes.v7.24.0-56.nightly
namespace: placeholder namespace: placeholder
spec: spec:
apiservicedefinitions: {} apiservicedefinitions: {}
@ -357,10 +357,28 @@ spec:
value: ca-certs value: ca-certs
image: quay.io/eclipse/che-operator:nightly image: quay.io/eclipse/che-operator:nightly
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
httpGet:
path: /readyz
port: 6789
initialDelaySeconds: 15
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: che-operator name: che-operator
ports: ports:
- containerPort: 60000 - containerPort: 60000
name: metrics name: metrics
readinessProbe:
failureThreshold: 10
httpGet:
path: /healthz
port: 6789
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources: {} resources: {}
restartPolicy: Always restartPolicy: Always
serviceAccountName: che-operator serviceAccountName: che-operator
@ -494,4 +512,4 @@ spec:
maturity: stable maturity: stable
provider: provider:
name: Eclipse Foundation name: Eclipse Foundation
version: 7.24.0-52.nightly version: 7.24.0-56.nightly

View File

@ -75,13 +75,13 @@ metadata:
categories: Developer Tools, OpenShift Optional categories: Developer Tools, OpenShift Optional
certified: "false" certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2020-12-17T10:09:20Z" createdAt: "2020-12-29T12:54:51Z"
description: A Kube-native development solution that delivers portable and collaborative description: A Kube-native development solution that delivers portable and collaborative
developer workspaces in OpenShift. developer workspaces in OpenShift.
operatorframework.io/suggested-namespace: eclipse-che operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse/che-operator repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.24.0-52.nightly name: eclipse-che-preview-openshift.v7.24.0-54.nightly
namespace: placeholder namespace: placeholder
spec: spec:
apiservicedefinitions: {} apiservicedefinitions: {}
@ -370,10 +370,28 @@ spec:
value: ca-certs value: ca-certs
image: quay.io/eclipse/che-operator:nightly image: quay.io/eclipse/che-operator:nightly
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
httpGet:
path: /readyz
port: 6789
initialDelaySeconds: 15
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: che-operator name: che-operator
ports: ports:
- containerPort: 60000 - containerPort: 60000
name: metrics name: metrics
readinessProbe:
failureThreshold: 10
httpGet:
path: /healthz
port: 6789
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources: {} resources: {}
restartPolicy: Always restartPolicy: Always
serviceAccountName: che-operator serviceAccountName: che-operator
@ -513,4 +531,4 @@ spec:
maturity: stable maturity: stable
provider: provider:
name: Eclipse Foundation name: Eclipse Foundation
version: 7.24.0-52.nightly version: 7.24.0-54.nightly

View File

@ -87,3 +87,21 @@ spec:
value: che-postgres-secret value: che-postgres-secret
- name: CHE_SERVER_TRUST_STORE_CONFIGMAP_NAME - name: CHE_SERVER_TRUST_STORE_CONFIGMAP_NAME
value: ca-certs value: ca-certs
livenessProbe:
httpGet:
path: /readyz
port: 6789
initialDelaySeconds: 15
periodSeconds: 10
failureThreshold: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /healthz
port: 6789
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 10
successThreshold: 1
timeoutSeconds: 5

View File

@ -86,6 +86,24 @@ spec:
value: che-postgres-secret value: che-postgres-secret
- name: CHE_SERVER_TRUST_STORE_CONFIGMAP_NAME - name: CHE_SERVER_TRUST_STORE_CONFIGMAP_NAME
value: ca-certs value: ca-certs
livenessProbe:
httpGet:
path: /readyz
port: 6789
initialDelaySeconds: 15
periodSeconds: 10
failureThreshold: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /healthz
port: 6789
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 10
successThreshold: 1
timeoutSeconds: 5
restartPolicy: Always restartPolicy: Always
serviceAccountName: che-operator serviceAccountName: che-operator
terminationGracePeriodSeconds: 5 terminationGracePeriodSeconds: 5

View File

@ -616,6 +616,18 @@ func getSpecKeycloakDeployment(
PeriodSeconds: 10, PeriodSeconds: 10,
SuccessThreshold: 1, SuccessThreshold: 1,
}, },
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
TCPSocket: &corev1.TCPSocketAction{
Port: intstr.FromInt(8080),
},
},
InitialDelaySeconds: 30,
FailureThreshold: 10,
TimeoutSeconds: 5,
PeriodSeconds: 10,
SuccessThreshold: 1,
},
Env: keycloakEnv, Env: keycloakEnv,
VolumeMounts: []corev1.VolumeMount{ VolumeMounts: []corev1.VolumeMount{
customPublicCertsVolumeMount, customPublicCertsVolumeMount,

View File

@ -18,6 +18,7 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
) )
@ -142,6 +143,18 @@ func getSpecPostgresDeployment(deployContext *deploy.DeployContext, clusterDeplo
PeriodSeconds: 10, PeriodSeconds: 10,
TimeoutSeconds: 5, TimeoutSeconds: 5,
}, },
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
TCPSocket: &corev1.TCPSocketAction{
Port: intstr.FromInt(5432),
},
},
InitialDelaySeconds: 30,
FailureThreshold: 10,
SuccessThreshold: 1,
PeriodSeconds: 10,
TimeoutSeconds: 5,
},
Env: []corev1.EnvVar{ Env: []corev1.EnvVar{
{ {
Name: "POSTGRESQL_DATABASE", Name: "POSTGRESQL_DATABASE",

View File

@ -99,8 +99,8 @@ func GetSpecRegistryDeployment(
InitialDelaySeconds: 3, InitialDelaySeconds: 3,
FailureThreshold: 10, FailureThreshold: 10,
TimeoutSeconds: 3, TimeoutSeconds: 3,
PeriodSeconds: 10,
SuccessThreshold: 1, SuccessThreshold: 1,
PeriodSeconds: 10,
}, },
LivenessProbe: &v1.Probe{ LivenessProbe: &v1.Probe{
Handler: v1.Handler{ Handler: v1.Handler{