diff --git a/apis/monitor/v1alpha1/appdatasource_types.go b/apis/monitor/v1alpha1/appdatasource_types.go new file mode 100644 index 000000000000..b69804b0345e --- /dev/null +++ b/apis/monitor/v1alpha1/appdatasource_types.go @@ -0,0 +1,117 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +type MetricsConfig struct { + CollectionInterval string `json:"collectionInterval,omitempty"` + EnabledMetrics []string `json:"enabledMetrics,omitempty"` +} + +type MetricsDataSource struct { + Enable bool `json:"enable,omitempty"` + + MetricsCollector *MetricsConfig `json:"metricsCollector,omitempty"` +} + +type InputConfig struct { + Include []string `json:"include,omitempty"` +} + +type LogsDataSource struct { + Enable bool `json:"enable,omitempty"` + + LogCollector *InputConfig `json:"logCollector,omitempty"` +} + +// AppDataSourceSpec defines the desired state of AppDataSource +type AppDataSourceSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Mode represents how the OTeld should be deployed (deployment, daemonset, statefulset or sidecar) + // +optional + Mode Mode `json:"mode,omitempty"` + + // NodeSelector is the node selector of the data source + // +optional + NodeSelector v1.NodeSelector `json:"nodeSelector,omitempty"` + + // ClusterName is the cluster name of the data source + // +kubebuilder:validation:Required + ClusterName string `json:"clusterName,omitempty"` + + // ComponentName is the component name of the data source + // +kubebuilder:validation:Required + ComponentName string `json:"componentName,omitempty"` + + // ContainerName is the container name of the data source + // +kubebuilder:validation:Required + ContainerName string `json:"containerName,omitempty"` + + // MetricsConfig is the metrics config + Metrics *MetricsDataSource `json:"metrics,omitempty"` + + // LogsConfig is the logs config + Logs *LogsDataSource `json:"logs,omitempty"` + + ExternalLabels map[string]string `json:"externalLabels,omitempty"` + + // CollectionInterval is the interval of the data source + CollectionInterval string `json:"collectionInterval,omitempty"` +} + +// AppDataSourceStatus defines the observed state of AppDataSource +type AppDataSourceStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// AppDataSource is the Schema for the AppDataSources API +type AppDataSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AppDataSourceSpec `json:"spec,omitempty"` + Status AppDataSourceStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// AppDataSourceList contains a list of AppDataSource +type AppDataSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AppDataSource `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AppDataSource{}, &AppDataSourceList{}) +} diff --git a/apis/monitor/v1alpha1/zz_generated.deepcopy.go b/apis/monitor/v1alpha1/zz_generated.deepcopy.go index 23a5ca83d124..f4cadf9e5457 100644 --- a/apis/monitor/v1alpha1/zz_generated.deepcopy.go +++ b/apis/monitor/v1alpha1/zz_generated.deepcopy.go @@ -29,6 +29,113 @@ 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 *AppDataSource) DeepCopyInto(out *AppDataSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppDataSource. +func (in *AppDataSource) DeepCopy() *AppDataSource { + if in == nil { + return nil + } + out := new(AppDataSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AppDataSource) 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 *AppDataSourceList) DeepCopyInto(out *AppDataSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AppDataSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppDataSourceList. +func (in *AppDataSourceList) DeepCopy() *AppDataSourceList { + if in == nil { + return nil + } + out := new(AppDataSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AppDataSourceList) 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 *AppDataSourceSpec) DeepCopyInto(out *AppDataSourceSpec) { + *out = *in + in.NodeSelector.DeepCopyInto(&out.NodeSelector) + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = new(MetricsDataSource) + (*in).DeepCopyInto(*out) + } + if in.Logs != nil { + in, out := &in.Logs, &out.Logs + *out = new(LogsDataSource) + (*in).DeepCopyInto(*out) + } + if in.ExternalLabels != nil { + in, out := &in.ExternalLabels, &out.ExternalLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppDataSourceSpec. +func (in *AppDataSourceSpec) DeepCopy() *AppDataSourceSpec { + if in == nil { + return nil + } + out := new(AppDataSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AppDataSourceStatus) DeepCopyInto(out *AppDataSourceStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppDataSourceStatus. +func (in *AppDataSourceStatus) DeepCopy() *AppDataSourceStatus { + if in == nil { + return nil + } + out := new(AppDataSourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CollectorDataSource) DeepCopyInto(out *CollectorDataSource) { *out = *in @@ -159,6 +266,46 @@ func (in *ExporterRef) DeepCopy() *ExporterRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InputConfig) DeepCopyInto(out *InputConfig) { + *out = *in + if in.Include != nil { + in, out := &in.Include, &out.Include + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InputConfig. +func (in *InputConfig) DeepCopy() *InputConfig { + if in == nil { + return nil + } + out := new(InputConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogsDataSource) DeepCopyInto(out *LogsDataSource) { + *out = *in + if in.LogCollector != nil { + in, out := &in.LogCollector, &out.LogCollector + *out = new(InputConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogsDataSource. +func (in *LogsDataSource) DeepCopy() *LogsDataSource { + if in == nil { + return nil + } + out := new(LogsDataSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LogsExporterSink) DeepCopyInto(out *LogsExporterSink) { *out = *in @@ -275,6 +422,46 @@ func (in *LokiConfig) DeepCopy() *LokiConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsConfig) DeepCopyInto(out *MetricsConfig) { + *out = *in + if in.EnabledMetrics != nil { + in, out := &in.EnabledMetrics, &out.EnabledMetrics + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsConfig. +func (in *MetricsConfig) DeepCopy() *MetricsConfig { + if in == nil { + return nil + } + out := new(MetricsConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsDataSource) DeepCopyInto(out *MetricsDataSource) { + *out = *in + if in.MetricsCollector != nil { + in, out := &in.MetricsCollector, &out.MetricsCollector + *out = new(MetricsConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsDataSource. +func (in *MetricsDataSource) DeepCopy() *MetricsDataSource { + if in == nil { + return nil + } + out := new(MetricsDataSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MetricsExporterSink) DeepCopyInto(out *MetricsExporterSink) { *out = *in