Skip to content
Merged
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
7 changes: 7 additions & 0 deletions api/v1beta1/clusterpromotion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ type ProfileSpec struct {
// +optional
ValidateHealths []libsveltosv1beta1.ValidateHealth `json:"validateHealths,omitempty"`

// HealthMonitoring, when enabled, continuously monitors the health of the resources
// this profile deploys in each matching cluster. Unlike ValidateHealths, which are
// evaluated once during deployment, these checks run for as long as the profile
// is deployed. Results are available as HealthCheckReports.
// +optional
HealthMonitoring *HealthMonitoring `json:"healthMonitoring,omitempty"`

// Define additional Kustomize inline Patches applied for all resources on this profile
// Within the Patch Spec you can use templating
// +listType=atomic
Expand Down
56 changes: 56 additions & 0 deletions api/v1beta1/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,55 @@ type Clusters struct {
Clusters []corev1.ObjectReference `json:"clusters,omitempty"`
}

const (
// HealthMonitoringClusterSummaryUIDLabel is set, with the UID of the ClusterSummary as value, on the
// HealthCheck and ClusterHealthCheck instances created for a ClusterSummary when health monitoring is enabled.
HealthMonitoringClusterSummaryUIDLabel = "projectsveltos.io/health-monitoring-clustersummary-uid"

// HealthMonitoringClusterSummaryNamespaceAnnotation and HealthMonitoringClusterSummaryNameAnnotation
// are set on the same instances to identify the ClusterSummary they have been created for.
HealthMonitoringClusterSummaryNamespaceAnnotation = "projectsveltos.io/health-monitoring-clustersummary-namespace"
HealthMonitoringClusterSummaryNameAnnotation = "projectsveltos.io/health-monitoring-clustersummary-name"
)

// HealthMonitoring configures the continuous health monitoring of the resources a profile deploys.
// Both ClusterProfile and Profile can enable it with the default checks. Referencing additional
// HealthChecks (healthChecks) is reserved to ClusterProfile: see the field.
//
// +kubebuilder:validation:XValidation:rule="self.enabled || !has(self.healthChecks) || size(self.healthChecks) == 0",message="healthChecks can only be set when enabled is true"
// +kubebuilder:validation:XValidation:rule="!self.enabled || !has(self.defaultChecks) || self.defaultChecks || (has(self.healthChecks) && size(self.healthChecks) > 0)",message="defaultChecks cannot be false when healthChecks is empty: there would be nothing to monitor"
//
//nolint:lll // kubebuilder marker
type HealthMonitoring struct {
// Enabled turns health monitoring on for the resources deployed by this profile.
// When true, Sveltos creates a HealthCheck and a ClusterHealthCheck for each
// matching cluster once the profile is provisioned there, and removes them
// when monitoring is disabled or the cluster does not match anymore.
Enabled bool `json:"enabled"`

// DefaultChecks, when true (default), monitors the Deployments, StatefulSets, DaemonSets,
// Jobs and PersistentVolumeClaims deployed by this profile (raw resources and Helm charts).
// Set it to false to monitor only the HealthChecks listed in HealthChecks.
// +kubebuilder:default:=true
// +optional
DefaultChecks *bool `json:"defaultChecks,omitempty"`

// HealthChecks is a list of names of HealthCheck instances to monitor in addition
// to the default checks. Those are deployed as they are: selecting only the
// resources deployed by this profile is up to the HealthCheck.
//
// Only a ClusterProfile can set it. It is ignored for a (namespaced) Profile, which gets the
// default checks only. A HealthCheck is a cluster-scoped resource referenced by name, and the
// report it produces is shared by every profile that references it on a given cluster, with
// no filtering by namespace. Allowing a Profile to reference one would let a tenant name
// a HealthCheck it does not own, and learn about resources outside its namespace through
// the shared report. The default checks are safe for a Profile: they select only the
// resources that profile deployed.
// +listType=set
// +optional
HealthChecks []string `json:"healthChecks,omitempty"`
}

type Spec struct {
// ClusterSelector identifies clusters to associate to.
// +optional
Expand Down Expand Up @@ -1110,6 +1159,13 @@ type Spec struct {
// +optional
ValidateHealths []libsveltosv1beta1.ValidateHealth `json:"validateHealths,omitempty"`

// HealthMonitoring, when enabled, continuously monitors the health of the resources
// this profile deploys in each matching cluster. Unlike ValidateHealths, which are
// evaluated once during deployment, these checks run for as long as the profile
// is deployed. Results are available as HealthCheckReports.
// +optional
HealthMonitoring *HealthMonitoring `json:"healthMonitoring,omitempty"`

// Define additional Kustomize inline Patches applied for all resources on this profile
// Within the Patch Spec you can use templating
// +listType=atomic
Expand Down
35 changes: 35 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

49 changes: 49 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,55 @@ spec:
`ExtraLabels`, the value from `ExtraLabels` will override the existing value.
(Deprecated use Patches instead)
type: object
healthMonitoring:
description: |-
HealthMonitoring, when enabled, continuously monitors the health of the resources
this profile deploys in each matching cluster. Unlike ValidateHealths, which are
evaluated once during deployment, these checks run for as long as the profile
is deployed. Results are available as HealthCheckReports.
properties:
defaultChecks:
default: true
description: |-
DefaultChecks, when true (default), monitors the Deployments, StatefulSets, DaemonSets,
Jobs and PersistentVolumeClaims deployed by this profile (raw resources and Helm charts).
Set it to false to monitor only the HealthChecks listed in HealthChecks.
type: boolean
enabled:
description: |-
Enabled turns health monitoring on for the resources deployed by this profile.
When true, Sveltos creates a HealthCheck and a ClusterHealthCheck for each
matching cluster once the profile is provisioned there, and removes them
when monitoring is disabled or the cluster does not match anymore.
type: boolean
healthChecks:
description: |-
HealthChecks is a list of names of HealthCheck instances to monitor in addition
to the default checks. Those are deployed as they are: selecting only the
resources deployed by this profile is up to the HealthCheck.

Only a ClusterProfile can set it. It is ignored for a (namespaced) Profile, which gets the
default checks only. A HealthCheck is a cluster-scoped resource referenced by name, and the
report it produces is shared by every profile that references it on a given cluster, with
no filtering by namespace. Allowing a Profile to reference one would let a tenant name
a HealthCheck it does not own, and learn about resources outside its namespace through
the shared report. The default checks are safe for a Profile: they select only the
resources that profile deployed.
items:
type: string
type: array
x-kubernetes-list-type: set
required:
- enabled
type: object
x-kubernetes-validations:
- message: healthChecks can only be set when enabled is true
rule: self.enabled || !has(self.healthChecks) || size(self.healthChecks)
== 0
- message: 'defaultChecks cannot be false when healthChecks is empty:
there would be nothing to monitor'
rule: '!self.enabled || !has(self.defaultChecks) || self.defaultChecks
|| (has(self.healthChecks) && size(self.healthChecks) > 0)'
helmCharts:
description: Helm charts is a list of helm charts that need to be
deployed
Expand Down
49 changes: 49 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,55 @@ spec:
type: object
type: array
x-kubernetes-list-type: atomic
healthMonitoring:
description: |-
HealthMonitoring, when enabled, continuously monitors the health of the resources
this profile deploys in each matching cluster. Unlike ValidateHealths, which are
evaluated once during deployment, these checks run for as long as the profile
is deployed. Results are available as HealthCheckReports.
properties:
defaultChecks:
default: true
description: |-
DefaultChecks, when true (default), monitors the Deployments, StatefulSets, DaemonSets,
Jobs and PersistentVolumeClaims deployed by this profile (raw resources and Helm charts).
Set it to false to monitor only the HealthChecks listed in HealthChecks.
type: boolean
enabled:
description: |-
Enabled turns health monitoring on for the resources deployed by this profile.
When true, Sveltos creates a HealthCheck and a ClusterHealthCheck for each
matching cluster once the profile is provisioned there, and removes them
when monitoring is disabled or the cluster does not match anymore.
type: boolean
healthChecks:
description: |-
HealthChecks is a list of names of HealthCheck instances to monitor in addition
to the default checks. Those are deployed as they are: selecting only the
resources deployed by this profile is up to the HealthCheck.

Only a ClusterProfile can set it. It is ignored for a (namespaced) Profile, which gets the
default checks only. A HealthCheck is a cluster-scoped resource referenced by name, and the
report it produces is shared by every profile that references it on a given cluster, with
no filtering by namespace. Allowing a Profile to reference one would let a tenant name
a HealthCheck it does not own, and learn about resources outside its namespace through
the shared report. The default checks are safe for a Profile: they select only the
resources that profile deployed.
items:
type: string
type: array
x-kubernetes-list-type: set
required:
- enabled
type: object
x-kubernetes-validations:
- message: healthChecks can only be set when enabled is true
rule: self.enabled || !has(self.healthChecks) || size(self.healthChecks)
== 0
- message: 'defaultChecks cannot be false when healthChecks is
empty: there would be nothing to monitor'
rule: '!self.enabled || !has(self.defaultChecks) || self.defaultChecks
|| (has(self.healthChecks) && size(self.healthChecks) > 0)'
helmCharts:
description: Helm charts is a list of helm charts that need to
be deployed
Expand Down
49 changes: 49 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clustersummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,55 @@ spec:
`ExtraLabels`, the value from `ExtraLabels` will override the existing value.
(Deprecated use Patches instead)
type: object
healthMonitoring:
description: |-
HealthMonitoring, when enabled, continuously monitors the health of the resources
this profile deploys in each matching cluster. Unlike ValidateHealths, which are
evaluated once during deployment, these checks run for as long as the profile
is deployed. Results are available as HealthCheckReports.
properties:
defaultChecks:
default: true
description: |-
DefaultChecks, when true (default), monitors the Deployments, StatefulSets, DaemonSets,
Jobs and PersistentVolumeClaims deployed by this profile (raw resources and Helm charts).
Set it to false to monitor only the HealthChecks listed in HealthChecks.
type: boolean
enabled:
description: |-
Enabled turns health monitoring on for the resources deployed by this profile.
When true, Sveltos creates a HealthCheck and a ClusterHealthCheck for each
matching cluster once the profile is provisioned there, and removes them
when monitoring is disabled or the cluster does not match anymore.
type: boolean
healthChecks:
description: |-
HealthChecks is a list of names of HealthCheck instances to monitor in addition
to the default checks. Those are deployed as they are: selecting only the
resources deployed by this profile is up to the HealthCheck.

Only a ClusterProfile can set it. It is ignored for a (namespaced) Profile, which gets the
default checks only. A HealthCheck is a cluster-scoped resource referenced by name, and the
report it produces is shared by every profile that references it on a given cluster, with
no filtering by namespace. Allowing a Profile to reference one would let a tenant name
a HealthCheck it does not own, and learn about resources outside its namespace through
the shared report. The default checks are safe for a Profile: they select only the
resources that profile deployed.
items:
type: string
type: array
x-kubernetes-list-type: set
required:
- enabled
type: object
x-kubernetes-validations:
- message: healthChecks can only be set when enabled is true
rule: self.enabled || !has(self.healthChecks) || size(self.healthChecks)
== 0
- message: 'defaultChecks cannot be false when healthChecks is
empty: there would be nothing to monitor'
rule: '!self.enabled || !has(self.defaultChecks) || self.defaultChecks
|| (has(self.healthChecks) && size(self.healthChecks) > 0)'
helmCharts:
description: Helm charts is a list of helm charts that need to
be deployed
Expand Down
Loading
Loading