Skip to content
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

(feat) SveltosCluster Readniness and Liveness Checks #279

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

gianlucam76
Copy link
Member

@gianlucam76 gianlucam76 commented Feb 15, 2025

Introduce ReadinessChecks and LivenessChecks.

ReadinessChecks are evaluated till SveltosCluster moves to ready. LivenessCheckes are periodically evelauated after that.

This is an example of ReadinessChecks waiting for at least one worker node to exist in the cluster

apiVersion: lib.projectsveltos.io/v1beta1
kind: SveltosCluster
metadata:
  name: staging
  namespace: default
spec:
  consecutiveFailureThreshold: 3
  kubeconfigName: clusterapi-workload-sveltos-kubeconfig
  readinessChecks:
  - condition: |-
      function evaluate()
        hs = {}
        hs.pass = false

        for _, resource in ipairs(resources) do
          if  not (resource.metadata.labels and resource.metadata.labels["node-role.kubernetes.io/control-plane"]) then
            hs.pass = true
          end
        end

        return hs
      end
    name: namespace-bar-check
  resourceSelectors:
  - group: ""
    kind: Node
    version: v1
status:
  connectionStatus: Down
  failureMessage: cluster check namespace-bar-check failed

This PR also makes sure a SveltosCluster instance is reconciled only
on Create, Delete and Update when Spec changes (so Status changes do not
cause a reconciliation)

@gianlucam76 gianlucam76 force-pushed the checks branch 3 times, most recently from 5f8b825 to 3d9e302 Compare February 15, 2025 11:02
Introduce ReadinessChecks and LivenessChecks.

ReadinessChecks are evaluated till SveltosCluster moves to ready.
LivenessCheckes are periodically evelauated after that.

This is an example of ReadinessChecks waiting for at least
one worker node to exist in the cluster

```yaml
apiVersion: lib.projectsveltos.io/v1beta1
kind: SveltosCluster
metadata:
  name: staging
  namespace: default
spec:
  consecutiveFailureThreshold: 3
  kubeconfigName: clusterapi-workload-sveltos-kubeconfig
  readinessChecks:
  - condition: |-
      function evaluate()
        hs = {}
        hs.pass = false

        for _, resource in ipairs(resources) do
          if  not (resource.metadata.labels and resource.metadata.labels["node-role.kubernetes.io/control-plane"]) then
            hs.pass = true
          end
        end

        return hs
      end
    name: namespace-bar-check
    resourceSelectors:
    - group: ""
      kind: Namespace
      name: bar
      version: v1
status:
  connectionStatus: Down
  failureMessage: cluster check namespace-bar-check failed
```

This PR also makes sure a SveltosCluster instance is reconciled only
on Create, Delete and Update when Spec changes (so Status changes do not
cause a reconciliation)
@gianlucam76 gianlucam76 merged commit 504a43c into projectsveltos:main Feb 15, 2025
3 checks passed
@gianlucam76 gianlucam76 deleted the checks branch February 15, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant