Skip to content

Commit

Permalink
feat(health): Adding more health checks for Keycloak, Postgres, Grafa…
Browse files Browse the repository at this point in the history
…na, SolrCloud (#20294)

* feat(health): Add healtchcheck for acid.zalan.do/postgresql

Signed-off-by: Remo Zellmer <rze@vizrt.com>

* feat(health): Add healthcheck for grafana.integreatly.org/Grafana and GrafanaDatasource

Signed-off-by: Remo Zellmer <rze@vizrt.com>

* feat(health): Add healthcheck for k8s.keycloak.org/Keycloak

Signed-off-by: Remo Zellmer <rze@vizrt.com>

* feat(health): Add healthcheck for solr.apache.org/SolrCloud

Signed-off-by: Remo Zellmer <rze@vizrt.com>

---------

Signed-off-by: Remo Zellmer <rze@vizrt.com>
  • Loading branch information
rezellme authored Oct 9, 2024
1 parent e1472f3 commit 19d85aa
Show file tree
Hide file tree
Showing 28 changed files with 1,230 additions and 0 deletions.
30 changes: 30 additions & 0 deletions resource_customizations/acid.zalan.do/postgresql/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- Waiting for status info => Progressing
if obj.status == nil or obj.status.PostgresClusterStatus == nil then
return {
status = "Progressing",
message = "Waiting for postgres cluster status...",
}
end

-- Running => Healthy
if obj.status.PostgresClusterStatus == "Running" then
return {
status = "Healthy",
message = obj.status.PostgresClusterStatus,
}
end

-- Creating/Updating => Progressing
if obj.status.PostgresClusterStatus == "Creating" or obj.status.PostgresClusterStatus == "Updating" then
return {
status = "Progressing",
message = obj.status.PostgresClusterStatus,
}
end

-- CreateFailed/UpdateFailed/SyncFailed/Invalid/etc => Degraded
-- See https://github.com/zalando/postgres-operator/blob/0745ce7c/pkg/apis/acid.zalan.do/v1/const.go#L4-L13
return {
status = "Degraded",
message = obj.status.PostgresClusterStatus,
}
17 changes: 17 additions & 0 deletions resource_customizations/acid.zalan.do/postgresql/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for postgres cluster status..."
inputPath: testdata/provisioning.yaml
- healthStatus:
status: Progressing
message: "Updating"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Healthy
message: "Running"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "UpdateFailed"
inputPath: testdata/degraded.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: acid.zalan.do/v1
kind: postgresql
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-db:acid.zalan.do/postgresql:foo/foobar-db
creationTimestamp: '2024-10-07T09:06:07Z'
generation: 4
name: foobar-db
namespace: foo
resourceVersion: '242244'
uid: 741b63d5-8deb-45ef-af80-09d558d355a7
spec:
databases:
foobar: root
enableLogicalBackup: false
numberOfInstances: 1
postgresql:
parameters:
password_encryption: scram-sha-256
version: '15'
teamId: foobar
users: {}
volume:
size: 1Gi
status:
PostgresClusterStatus: UpdateFailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: acid.zalan.do/v1
kind: postgresql
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-db:acid.zalan.do/postgresql:foo/foobar-db
creationTimestamp: '2024-10-07T09:06:07Z'
generation: 4
name: foobar-db
namespace: foo
resourceVersion: '242244'
uid: 741b63d5-8deb-45ef-af80-09d558d355a7
spec:
databases:
foobar: root
enableLogicalBackup: false
numberOfInstances: 1
postgresql:
parameters:
password_encryption: scram-sha-256
version: '15'
teamId: foobar
users: {}
volume:
size: 1Gi
status:
PostgresClusterStatus: Running
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: acid.zalan.do/v1
kind: postgresql
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-db:acid.zalan.do/postgresql:foo/foobar-db
creationTimestamp: '2024-10-07T09:06:07Z'
generation: 4
name: foobar-db
namespace: foo
resourceVersion: '242244'
uid: 741b63d5-8deb-45ef-af80-09d558d355a7
spec:
databases:
foobar: root
enableLogicalBackup: false
numberOfInstances: 1
postgresql:
parameters:
password_encryption: scram-sha-256
version: '15'
teamId: foobar
users: {}
volume:
size: 1Gi
status:
PostgresClusterStatus: Updating
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: acid.zalan.do/v1
kind: postgresql
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-db:acid.zalan.do/postgresql:foo/foobar-db
name: foobar-db
namespace: foo
spec:
databases:
foobar: root
enableLogicalBackup: false
numberOfInstances: 1
postgresql:
parameters:
password_encryption: scram-sha-256
version: '15'
teamId: foobar
users: {}
volume:
size: 1Gi
30 changes: 30 additions & 0 deletions resource_customizations/grafana.integreatly.org/Grafana/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

-- if no status info available yet, assume progressing
if obj.status == nil or obj.status.stageStatus == nil then
return {
status = "Progressing",
message = "Waiting for Grafana status info",
}
end

-- if last stage failed, we are stuck here
if obj.status.stageStatus == "failed" then
return {
status = "Degraded",
message = "Failed at stage " .. obj.status.stage,
}
end

-- only if "complete" stage was successful, Grafana can be considered healthy
if obj.status.stage == "complete" and obj.status.stageStatus == "success" then
return {
status = "Healthy",
message = "",
}
end

-- no final status yet, assume progressing
return {
status = "Progressing",
message = obj.status.stage,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for Grafana status info"
inputPath: testdata/provisioning.yaml
- healthStatus:
status: Progressing
message: "deployment"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Healthy
message: ""
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failed at stage ingress"
inputPath: testdata/degraded.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-admin:grafana.integreatly.org/Grafana:foo/grafana
creationTimestamp: '2024-10-07T08:46:00Z'
generation: 3
labels:
dashboards: grafana
folders: grafana
name: grafana
namespace: foo
resourceVersion: '343511'
uid: d2f0496d-cd5c-46bf-8630-de827b6d59b0
spec:
deployment:
metadata: {}
spec:
template:
metadata: {}
spec:
containers:
- image: docker.io/grafana/grafana:11.1.4
name: grafana
volumeMounts:
- mountPath: /etc/ssl/certs/ca-certificates.crt
name: tls-ca-bundle
readOnly: true
subPath: tls-ca-bundle.pem
volumes:
- name: tls-ca-bundle
secret:
items:
- key: tls-ca-bundle.pem
path: tls-ca-bundle.pem
secretName: tls-ca-bundle-secret
version: 10.4.3
status:
adminUrl: http://grafana-service.foo:3000
dashboards:
- foo/dashboard-argocd/qPkgGHg7k
datasources:
- foo/cluster-local/927b3c23-e25f-4cbe-a82f-effbb0bbbf40
stage: ingress
stageStatus: failed
version: 11.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-admin:grafana.integreatly.org/Grafana:foo/grafana
creationTimestamp: '2024-10-07T08:46:00Z'
generation: 3
labels:
dashboards: grafana
folders: grafana
name: grafana
namespace: foo
resourceVersion: '343511'
uid: d2f0496d-cd5c-46bf-8630-de827b6d59b0
spec:
deployment:
metadata: {}
spec:
template:
metadata: {}
spec:
containers:
- image: docker.io/grafana/grafana:11.1.4
name: grafana
volumeMounts:
- mountPath: /etc/ssl/certs/ca-certificates.crt
name: tls-ca-bundle
readOnly: true
subPath: tls-ca-bundle.pem
volumes:
- name: tls-ca-bundle
secret:
items:
- key: tls-ca-bundle.pem
path: tls-ca-bundle.pem
secretName: tls-ca-bundle-secret
version: 10.4.3
status:
adminUrl: http://grafana-service.foo:3000
dashboards:
- foo/dashboard-argocd/qPkgGHg7k
datasources:
- foo/cluster-local/927b3c23-e25f-4cbe-a82f-effbb0bbbf40
stage: complete
stageStatus: success
version: 11.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-admin:grafana.integreatly.org/Grafana:foo/grafana
creationTimestamp: '2024-10-07T08:46:00Z'
generation: 3
labels:
dashboards: grafana
folders: grafana
name: grafana
namespace: foo
resourceVersion: '343511'
uid: d2f0496d-cd5c-46bf-8630-de827b6d59b0
spec:
deployment:
metadata: {}
spec:
template:
metadata: {}
spec:
containers:
- image: docker.io/grafana/grafana:11.1.4
name: grafana
volumeMounts:
- mountPath: /etc/ssl/certs/ca-certificates.crt
name: tls-ca-bundle
readOnly: true
subPath: tls-ca-bundle.pem
volumes:
- name: tls-ca-bundle
secret:
items:
- key: tls-ca-bundle.pem
path: tls-ca-bundle.pem
secretName: tls-ca-bundle-secret
version: 10.4.3
status:
adminUrl: http://grafana-service.foo:3000
dashboards:
- foo/dashboard-argocd/qPkgGHg7k
datasources:
- foo/cluster-local/927b3c23-e25f-4cbe-a82f-effbb0bbbf40
stage: deployment
stageStatus: success
version: 11.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
annotations:
argocd.argoproj.io/sync-wave: '1'
argocd.argoproj.io/tracking-id: foobar-admin:grafana.integreatly.org/Grafana:foo/grafana
creationTimestamp: '2024-10-07T08:46:00Z'
generation: 3
labels:
dashboards: grafana
folders: grafana
name: grafana
namespace: foo
resourceVersion: '343511'
uid: d2f0496d-cd5c-46bf-8630-de827b6d59b0
spec:
deployment:
metadata: {}
spec:
template:
metadata: {}
spec:
containers:
- image: docker.io/grafana/grafana:11.1.4
name: grafana
volumeMounts:
- mountPath: /etc/ssl/certs/ca-certificates.crt
name: tls-ca-bundle
readOnly: true
subPath: tls-ca-bundle.pem
volumes:
- name: tls-ca-bundle
secret:
items:
- key: tls-ca-bundle.pem
path: tls-ca-bundle.pem
secretName: tls-ca-bundle-secret
version: 10.4.3
status:
Loading

0 comments on commit 19d85aa

Please sign in to comment.