-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
476 additions
and
5 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
packages/system/cozystack-workload-controller/api/v1alpha1/workloadmonitor_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// WorkloadMonitorSpec defines the desired state of WorkloadMonitor | ||
type WorkloadMonitorSpec struct { | ||
// Selector is a label selector to find workloads to monitor | ||
// +required | ||
Selector map[string]string `json:"selector"` | ||
|
||
// Version specifies the version of the workload | ||
// +optional | ||
Version string `json:"version,omitempty"` | ||
|
||
// MinReplicas specifies the minimum number of replicas that should be available | ||
// +kubebuilder:validation:Minimum=0 | ||
// +optional | ||
MinReplicas *int32 `json:"minReplicas,omitempty"` | ||
|
||
// Replicas is the desired number of replicas | ||
// If not specified, will use observedReplicas as the target | ||
// +kubebuilder:validation:Minimum=0 | ||
// +optional | ||
Replicas *int32 `json:"replicas,omitempty"` | ||
} | ||
|
||
// WorkloadMonitorStatus defines the observed state of WorkloadMonitor | ||
type WorkloadMonitorStatus struct { | ||
// Operational indicates if the workload meets all operational requirements | ||
// +optional | ||
Operational bool `json:"operational"` | ||
|
||
// AvailableReplicas is the number of ready replicas | ||
// +optional | ||
AvailableReplicas int32 `json:"availableReplicas"` | ||
|
||
// ObservedReplicas is the total number of pods observed | ||
// +optional | ||
ObservedReplicas int32 `json:"observedReplicas"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version" | ||
// +kubebuilder:printcolumn:name="MinReplicas",type="integer",JSONPath=".spec.minReplicas" | ||
// +kubebuilder:printcolumn:name="Available",type="integer",JSONPath=".status.availableReplicas" | ||
// +kubebuilder:printcolumn:name="Observed",type="integer",JSONPath=".status.observedReplicas" | ||
// +kubebuilder:printcolumn:name="Operational",type="boolean",JSONPath=".status.operational" | ||
|
||
// WorkloadMonitor is the Schema for the workloadmonitors API | ||
type WorkloadMonitor struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec WorkloadMonitorSpec `json:"spec,omitempty"` | ||
Status WorkloadMonitorStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// WorkloadMonitorList contains a list of WorkloadMonitor | ||
type WorkloadMonitorList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []WorkloadMonitor `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&WorkloadMonitor{}, &WorkloadMonitorList{}) | ||
} | ||
|
||
// GetSelector returns the label selector from metadata | ||
func (w *WorkloadMonitor) GetSelector() map[string]string { | ||
return w.Spec.Selector | ||
} | ||
|
||
// Selector specifies the label selector for workloads | ||
type Selector map[string]string |
121 changes: 116 additions & 5 deletions
121
packages/system/cozystack-workload-controller/api/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
.../system/cozystack-workload-controller/config/crd/bases/cozystack.io_workloadmonitors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.16.4 | ||
name: workloadmonitors.cozystack.io | ||
spec: | ||
group: cozystack.io | ||
names: | ||
kind: WorkloadMonitor | ||
listKind: WorkloadMonitorList | ||
plural: workloadmonitors | ||
singular: workloadmonitor | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .spec.version | ||
name: Version | ||
type: string | ||
- jsonPath: .spec.minReplicas | ||
name: MinReplicas | ||
type: integer | ||
- jsonPath: .status.availableReplicas | ||
name: Available | ||
type: integer | ||
- jsonPath: .status.observedReplicas | ||
name: Observed | ||
type: integer | ||
- jsonPath: .status.operational | ||
name: Operational | ||
type: boolean | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: WorkloadMonitor is the Schema for the workloadmonitors API | ||
properties: | ||
apiVersion: | ||
description: |- | ||
APIVersion defines the versioned schema of this representation of an object. | ||
Servers should convert recognized schemas to the latest internal value, and | ||
may reject unrecognized values. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
type: string | ||
kind: | ||
description: |- | ||
Kind is a string value representing the REST resource this object represents. | ||
Servers may infer this from the endpoint the client submits requests to. | ||
Cannot be updated. | ||
In CamelCase. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: WorkloadMonitorSpec defines the desired state of WorkloadMonitor | ||
properties: | ||
minReplicas: | ||
description: MinReplicas specifies the minimum number of replicas | ||
that should be available | ||
format: int32 | ||
minimum: 0 | ||
type: integer | ||
replicas: | ||
description: |- | ||
Replicas is the desired number of replicas | ||
If not specified, will use observedReplicas as the target | ||
format: int32 | ||
minimum: 0 | ||
type: integer | ||
selector: | ||
additionalProperties: | ||
type: string | ||
description: Selector is a label selector to find workloads to monitor | ||
type: object | ||
version: | ||
description: Version specifies the version of the workload | ||
type: string | ||
required: | ||
- selector | ||
type: object | ||
status: | ||
description: WorkloadMonitorStatus defines the observed state of WorkloadMonitor | ||
properties: | ||
availableReplicas: | ||
description: AvailableReplicas is the number of ready replicas | ||
format: int32 | ||
type: integer | ||
observedReplicas: | ||
description: ObservedReplicas is the total number of pods observed | ||
format: int32 | ||
type: integer | ||
operational: | ||
description: Operational indicates if the workload meets all operational | ||
requirements | ||
type: boolean | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.