postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

ArgoCD "custom health check"

Open MPV opened this issue 4 years ago • 4 comments

Anyone else using ArgoCD to deploy this operator?

I'd like to suggest we create an ArgoCD "Custom Health Check" for this operator.

Read more about what that is here: https://argo-cd.readthedocs.io/en/stable/operator-manual/health/

And here's how to add one: https://argo-cd.readthedocs.io/en/stable/operator-manual/health/#way-2-contribute-a-custom-health-check

Essentially something like this:

$ cd github.com/argoproj/argo-cd
$ cat resource_customizations/acid.zalan.do/postgresql/health.lua
hs = {}
if obj.status == nil or obj.status.PostgresClusterStatus == nil then
  hs.status = "Progressing"
  hs.message = "Waiting for postgres cluster status..."
  return hs
end

if obj.status.PostgresClusterStatus == "Running" then
  hs.status = "Healthy"
  hs.message = obj.status.PostgresClusterStatus
  return hs
end

if obj.status.PostgresClusterStatus == "Creating" or obj.status.PostgresClusterStatus == "Updating" then
  hs.status = "Progressing"
  hs.message = obj.status.PostgresClusterStatus
  return hs
end

-- CreateFailed/UpdateFailed/SyncFailed/Invalid/etc
-- See: https://github.com/zalando/postgres-operator/blob/0745ce7cce63ab6431103d27eb08e54ec47d2b15/pkg/apis/acid.zalan.do/v1/const.go#L4-L13
hs.status = "Degraded"
hs.message = obj.status.PostgresClusterStatus
return hs

MPV avatar Nov 18 '21 13:11 MPV

How to show the resources created by the operator?

  • @MPV, how can I show the StatefulSets and Services associated with the Database?
    • ArgoCD is just showing the postgres crd...

Screen Shot 2022-01-31 at 4 26 22 PM

marcellodesales avatar Feb 01 '22 00:02 marcellodesales

How to show the resources created by the operator?

  • how can I show the StatefulSets and Services associated with the Database?

    • ArgoCD is just showing the postgres crd...

@marcellodesales https://github.com/zalando/postgres-operator/issues/498 is required for those resources to show up (as they’re not created by ArgoCD but by the operator — ArgoCD requires this owner reference link to understand that they are related).

MPV avatar Feb 06 '22 15:02 MPV

@MPV

According to https://github.com/zalando/postgres-operator/issues/1766#issuecomment-1028168636, we just need to add labels... (See Argo's latest discussion on the thread)... thank you!

marcellodesales avatar Feb 06 '22 19:02 marcellodesales

Anyone else using ArgoCD to deploy this operator?

I'd like to suggest we create an ArgoCD "Custom Health Check" for this operator.

Read more about what that is here: https://argo-cd.readthedocs.io/en/stable/operator-manual/health/

And here's how to add one: https://argo-cd.readthedocs.io/en/stable/operator-manual/health/#way-2-contribute-a-custom-health-check

Essentially something like this:

$ cd github.com/argoproj/argo-cd
$ cat resource_customizations/acid.zalan.do/postgresql/health.lua
hs = {}
if obj.status == nil or obj.status.PostgresClusterStatus == nil then
  hs.status = "Progressing"
  hs.message = "Waiting for postgres cluster status..."
  return hs
end

if obj.status.PostgresClusterStatus == "Running" then
  hs.status = "Healthy"
  hs.message = obj.status.PostgresClusterStatus
  return hs
end

if obj.status.PostgresClusterStatus == "Creating" or obj.status.PostgresClusterStatus == "Updating" then
  hs.status = "Progressing"
  hs.message = obj.status.PostgresClusterStatus
  return hs
end

-- CreateFailed/UpdateFailed/SyncFailed/Invalid/etc
-- See: https://github.com/zalando/postgres-operator/blob/0745ce7cce63ab6431103d27eb08e54ec47d2b15/pkg/apis/acid.zalan.do/v1/const.go#L4-L13
hs.status = "Degraded"
hs.message = obj.status.PostgresClusterStatus
return hs

Are there any plans to provide this health check to argo-cd?

alfsch avatar Oct 06 '22 11:10 alfsch