Skip to content

Commit

Permalink
add initial Monitoring CRD api
Browse files Browse the repository at this point in the history
Add UserDefinedMonitoring

Signed-off-by: Mario Fernandez <mariofer@redhat.com>
  • Loading branch information
marioferh committed Jul 2, 2024
1 parent 44d00ee commit d5ac7cc
Show file tree
Hide file tree
Showing 11 changed files with 689 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ImageDigestMirrorSetList{},
&ImageTagMirrorSet{},
&ImageTagMirrorSetList{},
&ClusterMonitoring{},
&ClusterMonitoringList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "ClusterMonitoring"
crdName: clustermonitoring.config.openshift.io
tests:
onCreate:
- name: Should be able to create a minimal ClusterMonitoring
initial: |
apiVersion: config.openshift.io/v1
kind: ClusterMonitoring
spec: {}
expected: |
apiVersion: config.openshift.io/v1
kind: ClusterMonitoring
spec: {}
85 changes: 85 additions & 0 deletions config/v1/types_cluster_monitoring.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
// +openshift:compatibility-gen:internal
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/1929
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=clustermonitoring,scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations=release.openshift.io/bootstrap-required=true
// ClusterMonitoring is the Schema for the clustermonitoringoperators API
type ClusterMonitoring struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec holds user settable values for configuration
// +kubebuilder:validation:Required
// +required
Spec ClusterMonitoringSpec `json:"spec,omitempty"`
// status holds observed values from the cluster. They may not be overridden.
// +optional
Status ClusterMonitoringStatus `json:"status,omitempty"`
}

// MonitoringOperatorStatus defines the observed state of MonitoringOperator
type ClusterMonitoringStatus struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
// +openshift:compatibility-gen:internal
type ClusterMonitoringList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterMonitoring `json:"items"`
}

// MonitoringOperatorSpec defines the desired state of MonitoringOperator
type ClusterMonitoringSpec struct {
// `UserWorkload` enables monitoring for user-defined projects.
// +kubebuilder:validation:Optional
// +optional

UserDefined UserDefinedMonitoring `json:"userDefinedMonitoring,omitempty"`
}

// UserDefinedMonitoring config for user-defined projects.
type UserDefinedMonitoring struct {
Mode UserDefinedMode `json:"mode,omitempty"`
}

type UserDefinedMode string

var (
// UserWorkloadEnabled enables monitoring for user-defined projects.
UserDefinedDisabled UserDefinedMode = "Disabled"
// UserWorkloadDisabled disables monitoring for user-defined projects.
UserDefinedNamespace UserDefinedMode = "SingleNamespace"
// To add more UWM config
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/1929
api.openshift.io/merged-by-featuregates: "true"
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
release.openshift.io/bootstrap-required: "true"
name: clustermonitoring.config.openshift.io
spec:
group: config.openshift.io
names:
kind: ClusterMonitoring
listKind: ClusterMonitoringList
plural: clustermonitoring
singular: clustermonitoring
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: 'Compatibility level 4: No compatibility is provided, the API
can change at any point for any reason. These capabilities should not be
used by applications needing long term support. ClusterMonitoring is the
Schema for the clustermonitoringoperators 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: spec holds user settable values for configuration
properties:
userDefinedMonitoring:
description: UserDefinedMonitoring config for user-defined projects.
properties:
mode:
type: string
type: object
type: object
status:
description: status holds observed values from the cluster. They may not
be overridden.
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
110 changes: 110 additions & 0 deletions config/v1/zz_generated.deepcopy.go

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

22 changes: 22 additions & 0 deletions config/v1/zz_generated.featuregated-crd-manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ builds.config.openshift.io:
TopLevelFeatureGates: []
Version: v1

clustermonitoring.config.openshift.io:
Annotations:
release.openshift.io/bootstrap-required: "true"
ApprovedPRNumber: https://github.com/openshift/api/pull/1929
CRDName: clustermonitoring.config.openshift.io
Capability: ""
Category: ""
FeatureGates: []
FilenameOperatorName: config-operator
FilenameOperatorOrdering: "01"
FilenameRunLevel: "0000_10"
GroupName: config.openshift.io
HasStatus: true
KindName: ClusterMonitoring
Labels: {}
PluralName: clustermonitoring
PrinterColumns: []
Scope: Cluster
ShortNames: null
TopLevelFeatureGates: []
Version: v1

clusteroperators.config.openshift.io:
Annotations:
include.release.openshift.io/self-managed-high-availability: "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/1929
api.openshift.io/filename-cvo-runlevel: "0000_10"
api.openshift.io/filename-operator: config-operator
api.openshift.io/filename-ordering: "01"
feature-gate.release.openshift.io/: "true"
release.openshift.io/bootstrap-required: "true"
name: clustermonitoring.config.openshift.io
spec:
group: config.openshift.io
names:
kind: ClusterMonitoring
listKind: ClusterMonitoringList
plural: clustermonitoring
singular: clustermonitoring
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: 'Compatibility level 4: No compatibility is provided, the API
can change at any point for any reason. These capabilities should not be
used by applications needing long term support. ClusterMonitoring is the
Schema for the clustermonitoringoperators 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: spec holds user settable values for configuration
properties:
userDefinedMonitoring:
description: UserDefinedMonitoring config for user-defined projects.
properties:
mode:
type: string
type: object
type: object
status:
description: status holds observed values from the cluster. They may not
be overridden.
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
Loading

0 comments on commit d5ac7cc

Please # to comment.