From 3b5f246f367e036731e1fc548b52666b48c17f20 Mon Sep 17 00:00:00 2001 From: Pavol Loffay Date: Thu, 22 May 2025 15:27:49 +0200 Subject: [PATCH] feat: add CRD scaffolding for cluster observability / signal manager Signed-off-by: Pavol Loffay --- ...bility-operator.clusterserviceversion.yaml | 22 +++- ...y.openshift.io_clusterobservabilities.yaml | 50 ++++++++ .../observability-operator-cluster-role.yaml | 20 ++- docs/api.md | 55 +++++++++ pkg/apis/observability/v1alpha1/register.go | 23 ++++ pkg/apis/observability/v1alpha1/types.go | 43 +++++++ .../v1alpha1/zz_generated.deepcopy.go | 114 ++++++++++++++++++ 7 files changed, 316 insertions(+), 11 deletions(-) create mode 100644 deploy/crds/common/observability.openshift.io_clusterobservabilities.yaml create mode 100644 pkg/apis/observability/v1alpha1/register.go create mode 100644 pkg/apis/observability/v1alpha1/types.go create mode 100644 pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go diff --git a/bundle/manifests/observability-operator.clusterserviceversion.yaml b/bundle/manifests/observability-operator.clusterserviceversion.yaml index c235daf84..57e2650fc 100644 --- a/bundle/manifests/observability-operator.clusterserviceversion.yaml +++ b/bundle/manifests/observability-operator.clusterserviceversion.yaml @@ -42,7 +42,7 @@ metadata: categories: Monitoring certified: "false" containerImage: observability-operator:1.2.0 - createdAt: "2025-05-19T10:04:30Z" + createdAt: "2025-05-22T15:10:07Z" description: A Go based Kubernetes operator to setup and manage highly available Monitoring Stack using Prometheus, Alertmanager and Thanos Querier. operatorframework.io/cluster-monitoring: "true" @@ -511,23 +511,33 @@ spec: - apiGroups: - observability.openshift.io resources: - - uiplugins + - clusterobservability verbs: - - create - - delete - get - list - - patch - - update - watch - apiGroups: - observability.openshift.io resources: + - clusterobservability/finalizers + - clusterobservability/status - uiplugins/finalizers - uiplugins/status verbs: - get - update + - apiGroups: + - observability.openshift.io + resources: + - uiplugins + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - operator.openshift.io resources: diff --git a/deploy/crds/common/observability.openshift.io_clusterobservabilities.yaml b/deploy/crds/common/observability.openshift.io_clusterobservabilities.yaml new file mode 100644 index 000000000..26c3542eb --- /dev/null +++ b/deploy/crds/common/observability.openshift.io_clusterobservabilities.yaml @@ -0,0 +1,50 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.2 + name: clusterobservabilities.observability.openshift.io +spec: + group: observability.openshift.io + names: + kind: ClusterObservability + listKind: ClusterObservabilityList + plural: clusterobservabilities + singular: clusterobservability + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ClusterObservability defines the desired state of the observability + stack. + 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 defines the desired state of the cluster observability. + type: object + status: + description: Status of the signal manager. + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/deploy/operator/observability-operator-cluster-role.yaml b/deploy/operator/observability-operator-cluster-role.yaml index 6b0b82ca1..df68a68e2 100644 --- a/deploy/operator/observability-operator-cluster-role.yaml +++ b/deploy/operator/observability-operator-cluster-role.yaml @@ -226,23 +226,33 @@ rules: - apiGroups: - observability.openshift.io resources: - - uiplugins + - clusterobservability verbs: - - create - - delete - get - list - - patch - - update - watch - apiGroups: - observability.openshift.io resources: + - clusterobservability/finalizers + - clusterobservability/status - uiplugins/finalizers - uiplugins/status verbs: - get - update +- apiGroups: + - observability.openshift.io + resources: + - uiplugins + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - operator.openshift.io resources: diff --git a/docs/api.md b/docs/api.md index 252338995..3997c7e10 100644 --- a/docs/api.md +++ b/docs/api.md @@ -3984,11 +3984,66 @@ Reference to the TLS private key for the web server. Resource Types: +- [ClusterObservability](#clusterobservability) + - [UIPlugin](#uiplugin) +## ClusterObservability +[↩ Parent](#observabilityopenshiftiov1alpha1 ) + + + + + + +ClusterObservability defines the desired state of the observability stack. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
apiVersionstringobservability.openshift.io/v1alpha1true
kindstringClusterObservabilitytrue
metadataobjectRefer to the Kubernetes API documentation for the fields of the `metadata` field.true
specobject + Spec defines the desired state of the cluster observability.
+
false
statusobject + Status of the signal manager.
+
false
+ ## UIPlugin [↩ Parent](#observabilityopenshiftiov1alpha1 ) diff --git a/pkg/apis/observability/v1alpha1/register.go b/pkg/apis/observability/v1alpha1/register.go new file mode 100644 index 000000000..d353548a0 --- /dev/null +++ b/pkg/apis/observability/v1alpha1/register.go @@ -0,0 +1,23 @@ +// +kubebuilder:object:generate=true +// +groupName=observability.openshift.io +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "observability.openshift.io", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +func init() { + SchemeBuilder.Register(&ClusterObservability{}, &ClusterObservabilityList{}) +} diff --git a/pkg/apis/observability/v1alpha1/types.go b/pkg/apis/observability/v1alpha1/types.go new file mode 100644 index 000000000..d641c3110 --- /dev/null +++ b/pkg/apis/observability/v1alpha1/types.go @@ -0,0 +1,43 @@ +// +groupName=observability.openshift.io +// +kubebuilder:rbac:groups=observability.openshift.io,resources=clusterobservability,verbs=list;get;watch +// +kubebuilder:rbac:groups=observability.openshift.io,resources=clusterobservability/status;clusterobservability/finalizers,verbs=get;update +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ClusterObservability defines the desired state of the observability stack. +// +// +k8s:openapi-gen=true +// +kubebuilder:object:root=true +// +kubebuilder:resource:shortName=clobs;clobs +// +kubebuilder:resource:scope=Cluster +// +kubebuilder:subresource:status +// +operator-sdk:csv:customresourcedefinitions:displayName="Cluster Observability" +type ClusterObservability struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the cluster observability. + Spec ClusterObservabilitySpec `json:"spec,omitempty"` + + // Status of the signal manager. + Status ClusterObservabilityStatus `json:"status,omitempty"` +} + +// +kubebuilder:resource +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ClusterObservabilityList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterObservability `json:"items"` +} + +type ClusterObservabilitySpec struct { +} + +// ClusterObservabilityStatus defines the observed state of ClusterObservability. +type ClusterObservabilityStatus struct{} diff --git a/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..18a20869a --- /dev/null +++ b/pkg/apis/observability/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,114 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2021. + +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterObservability) DeepCopyInto(out *ClusterObservability) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterObservability. +func (in *ClusterObservability) DeepCopy() *ClusterObservability { + if in == nil { + return nil + } + out := new(ClusterObservability) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterObservability) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterObservabilityList) DeepCopyInto(out *ClusterObservabilityList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterObservability, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterObservabilityList. +func (in *ClusterObservabilityList) DeepCopy() *ClusterObservabilityList { + if in == nil { + return nil + } + out := new(ClusterObservabilityList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterObservabilityList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterObservabilitySpec) DeepCopyInto(out *ClusterObservabilitySpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterObservabilitySpec. +func (in *ClusterObservabilitySpec) DeepCopy() *ClusterObservabilitySpec { + if in == nil { + return nil + } + out := new(ClusterObservabilitySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterObservabilityStatus) DeepCopyInto(out *ClusterObservabilityStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterObservabilityStatus. +func (in *ClusterObservabilityStatus) DeepCopy() *ClusterObservabilityStatus { + if in == nil { + return nil + } + out := new(ClusterObservabilityStatus) + in.DeepCopyInto(out) + return out +}