diff --git a/PROJECT b/PROJECT index ecd6e968..b6f49913 100644 --- a/PROJECT +++ b/PROJECT @@ -39,7 +39,7 @@ resources: namespaced: true domain: kube-logging.dev group: telemetry - kind: OtelOutput + kind: Output path: github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1 version: v1alpha1 version: "3" diff --git a/api/telemetry/v1alpha1/oteloutput_types.go b/api/telemetry/v1alpha1/output_types.go similarity index 83% rename from api/telemetry/v1alpha1/oteloutput_types.go rename to api/telemetry/v1alpha1/output_types.go index b8d416a8..6261730b 100644 --- a/api/telemetry/v1alpha1/oteloutput_types.go +++ b/api/telemetry/v1alpha1/output_types.go @@ -23,12 +23,11 @@ import ( // 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. -// OtelOutputSpec defines the desired state of OtelOutput -type OtelOutputSpec struct { +// OutputSpec defines the desired state of Output +type OutputSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - // Foo is an example field of OtelOutput. Edit oteloutput_types.go to remove/update OTLP *OTLP `json:"otlp,omitempty"` Loki *Loki `json:"loki,omitempty"` Fluentforward *Fluentforward `json:"fluentforward,omitempty"` @@ -88,38 +87,36 @@ type TCPClientSettings struct { SharedKey string `json:"shared_key,omitempty" yaml:"shared_key,omitempty"` } -// OtelOutputStatus defines the observed state of OtelOutput -type OtelOutputStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file +// OutputStatus defines the observed state of Output +type OutputStatus struct { } // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:categories=telemetry-all -// OtelOutput is the Schema for the oteloutputs API -type OtelOutput struct { +// Output is the Schema for the outputs API +type Output struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec OtelOutputSpec `json:"spec,omitempty" yaml:"spec,omitempty"` - Status OtelOutputStatus `json:"status,omitempty" ` + Spec OutputSpec `json:"spec,omitempty" yaml:"spec,omitempty"` + Status OutputStatus `json:"status,omitempty" ` } // +kubebuilder:object:root=true -// OtelOutputList contains a list of OtelOutput -type OtelOutputList struct { +// OutputList contains a list of Output +type OutputList struct { metav1.TypeMeta `json:",inline" yaml:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []OtelOutput `json:"items"` + Items []Output `json:"items"` } func init() { - SchemeBuilder.Register(&OtelOutput{}, &OtelOutputList{}) + SchemeBuilder.Register(&Output{}, &OutputList{}) } -func (o *OtelOutput) NamespacedName() NamespacedName { +func (o *Output) NamespacedName() NamespacedName { return NamespacedName{Namespace: o.Namespace, Name: o.Name} } diff --git a/api/telemetry/v1alpha1/zz_generated.deepcopy.go b/api/telemetry/v1alpha1/zz_generated.deepcopy.go index 3fb54695..c5d7ff60 100644 --- a/api/telemetry/v1alpha1/zz_generated.deepcopy.go +++ b/api/telemetry/v1alpha1/zz_generated.deepcopy.go @@ -345,7 +345,7 @@ func (in *OTLP) DeepCopy() *OTLP { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OtelOutput) DeepCopyInto(out *OtelOutput) { +func (in *Output) DeepCopyInto(out *Output) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -353,18 +353,18 @@ func (in *OtelOutput) DeepCopyInto(out *OtelOutput) { out.Status = in.Status } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OtelOutput. -func (in *OtelOutput) DeepCopy() *OtelOutput { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Output. +func (in *Output) DeepCopy() *Output { if in == nil { return nil } - out := new(OtelOutput) + out := new(Output) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OtelOutput) DeepCopyObject() runtime.Object { +func (in *Output) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -372,31 +372,31 @@ func (in *OtelOutput) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OtelOutputList) DeepCopyInto(out *OtelOutputList) { +func (in *OutputList) DeepCopyInto(out *OutputList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]OtelOutput, len(*in)) + *out = make([]Output, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OtelOutputList. -func (in *OtelOutputList) DeepCopy() *OtelOutputList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputList. +func (in *OutputList) DeepCopy() *OutputList { if in == nil { return nil } - out := new(OtelOutputList) + out := new(OutputList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OtelOutputList) DeepCopyObject() runtime.Object { +func (in *OutputList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -404,7 +404,7 @@ func (in *OtelOutputList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OtelOutputSpec) DeepCopyInto(out *OtelOutputSpec) { +func (in *OutputSpec) DeepCopyInto(out *OutputSpec) { *out = *in if in.OTLP != nil { in, out := &in.OTLP, &out.OTLP @@ -423,27 +423,27 @@ func (in *OtelOutputSpec) DeepCopyInto(out *OtelOutputSpec) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OtelOutputSpec. -func (in *OtelOutputSpec) DeepCopy() *OtelOutputSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputSpec. +func (in *OutputSpec) DeepCopy() *OutputSpec { if in == nil { return nil } - out := new(OtelOutputSpec) + out := new(OutputSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OtelOutputStatus) DeepCopyInto(out *OtelOutputStatus) { +func (in *OutputStatus) DeepCopyInto(out *OutputStatus) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OtelOutputStatus. -func (in *OtelOutputStatus) DeepCopy() *OtelOutputStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputStatus. +func (in *OutputStatus) DeepCopy() *OutputStatus { if in == nil { return nil } - out := new(OtelOutputStatus) + out := new(OutputStatus) in.DeepCopyInto(out) return out } diff --git a/config/crd/bases/telemetry.kube-logging.dev_oteloutputs.yaml b/config/crd/bases/telemetry.kube-logging.dev_outputs.yaml similarity index 98% rename from config/crd/bases/telemetry.kube-logging.dev_oteloutputs.yaml rename to config/crd/bases/telemetry.kube-logging.dev_outputs.yaml index a5d9988a..d7a5f1af 100644 --- a/config/crd/bases/telemetry.kube-logging.dev_oteloutputs.yaml +++ b/config/crd/bases/telemetry.kube-logging.dev_outputs.yaml @@ -4,22 +4,22 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 - name: oteloutputs.telemetry.kube-logging.dev + name: outputs.telemetry.kube-logging.dev spec: group: telemetry.kube-logging.dev names: categories: - telemetry-all - kind: OtelOutput - listKind: OtelOutputList - plural: oteloutputs - singular: oteloutput + kind: Output + listKind: OutputList + plural: outputs + singular: output scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: OtelOutput is the Schema for the oteloutputs API + description: Output is the Schema for the outputs API properties: apiVersion: description: |- @@ -39,7 +39,7 @@ spec: metadata: type: object spec: - description: OtelOutputSpec defines the desired state of OtelOutput + description: OutputSpec defines the desired state of Output properties: fluentforward: properties: @@ -409,8 +409,7 @@ spec: type: integer type: object otlp: - description: Foo is an example field of OtelOutput. Edit oteloutput_types.go - to remove/update + description: 'OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go' properties: auth: description: Auth configuration for outgoing RPCs. @@ -610,7 +609,7 @@ spec: type: object type: object status: - description: OtelOutputStatus defines the observed state of OtelOutput + description: OutputStatus defines the observed state of Output type: object type: object served: true diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 03f11d3b..42cacb5b 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -5,7 +5,7 @@ resources: - bases/telemetry.kube-logging.dev_collectors.yaml - bases/telemetry.kube-logging.dev_subscriptions.yaml - bases/telemetry.kube-logging.dev_tenants.yaml -- bases/telemetry.kube-logging.dev_oteloutputs.yaml +- bases/telemetry.kube-logging.dev_outputs.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -14,7 +14,7 @@ patches: #- path: patches/webhook_in_collectors.yaml #- path: patches/webhook_in_telemetry_subscriptions.yaml #- path: patches/webhook_in_telemetry_tenants.yaml -#- path: patches/webhook_in_telemetry_oteloutputs.yaml +#- path: patches/webhook_in_telemetry_outputs.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. @@ -22,7 +22,7 @@ patches: #- path: patches/cainjection_in_collectors.yaml #- path: patches/cainjection_in_telemetry_subscriptions.yaml #- path: patches/cainjection_in_telemetry_tenants.yaml -#- path: patches/cainjection_in_telemetry_oteloutputs.yaml +#- path: patches/cainjection_in_telemetry_outputs.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index b5ef39bf..cc5954ab 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,8 +1,8 @@ resources: -- manager.yaml + - manager.yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: -- name: controller - newName: ghcr.io/kube-logging/telemetry-controller - newTag: 0.0.8 + - name: controller + newName: ghcr.io/kube-logging/telemetry-controller + newTag: 0.0.9 diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 563c7629..1bfed555 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -75,7 +75,7 @@ rules: - telemetry.kube-logging.dev resources: - collectors - - oteloutputs + - outputs - subscriptions - tenants verbs: @@ -96,7 +96,7 @@ rules: - telemetry.kube-logging.dev resources: - collectors/status - - oteloutputs/status + - outputs/status - subscriptions/status - tenants/status verbs: diff --git a/config/rbac/telemetry_oteloutput_viewer_role.yaml b/config/rbac/telemetry_oteloutput_viewer_role.yaml index 14445330..fd342aeb 100644 --- a/config/rbac/telemetry_oteloutput_viewer_role.yaml +++ b/config/rbac/telemetry_oteloutput_viewer_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to view oteloutputs. +# permissions for end users to view outputs. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: oteloutput-viewer-role + app.kubernetes.io/instance: output-viewer-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: telemetry-controller app.kubernetes.io/part-of: telemetry-controller app.kubernetes.io/managed-by: kustomize - name: oteloutput-viewer-role + name: output-viewer-role rules: - apiGroups: - telemetry.kube-logging.dev resources: - - oteloutputs + - outputs verbs: - get - list @@ -22,6 +22,6 @@ rules: - apiGroups: - telemetry.kube-logging.dev resources: - - oteloutputs/status + - outputs/status verbs: - get diff --git a/config/rbac/telemetry_oteloutput_editor_role.yaml b/config/rbac/telemetry_output_editor_role.yaml similarity index 76% rename from config/rbac/telemetry_oteloutput_editor_role.yaml rename to config/rbac/telemetry_output_editor_role.yaml index 0838893b..74193f68 100644 --- a/config/rbac/telemetry_oteloutput_editor_role.yaml +++ b/config/rbac/telemetry_output_editor_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to edit oteloutputs. +# permissions for end users to edit outputs. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: oteloutput-editor-role + app.kubernetes.io/instance: output-editor-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: telemetry-controller app.kubernetes.io/part-of: telemetry-controller app.kubernetes.io/managed-by: kustomize - name: oteloutput-editor-role + name: output-editor-role rules: - apiGroups: - telemetry.kube-logging.dev resources: - - oteloutputs + - outputs verbs: - create - delete @@ -26,6 +26,6 @@ rules: - apiGroups: - telemetry.kube-logging.dev resources: - - oteloutputs/status + - outputs/status verbs: - get diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index bb84a7f9..fc2a569a 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -3,5 +3,5 @@ resources: - telemetry_v1alpha1_collector.yaml - telemetry_v1alpha1_subscription.yaml - telemetry_v1alpha1_tenant.yaml -- telemetry_v1alpha1_oteloutput.yaml +- telemetry_v1alpha1_output.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/samples/telemetry_v1alpha1_oteloutput.yaml b/config/samples/telemetry_v1alpha1_output.yaml similarity index 70% rename from config/samples/telemetry_v1alpha1_oteloutput.yaml rename to config/samples/telemetry_v1alpha1_output.yaml index 2c74c947..6c6b7108 100644 --- a/config/samples/telemetry_v1alpha1_oteloutput.yaml +++ b/config/samples/telemetry_v1alpha1_output.yaml @@ -1,13 +1,13 @@ apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: labels: - app.kubernetes.io/name: oteloutput - app.kubernetes.io/instance: oteloutput-sample + app.kubernetes.io/name: output + app.kubernetes.io/instance: output-sample app.kubernetes.io/part-of: telemetry-controller app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: telemetry-controller - name: oteloutput-sample + name: output-sample spec: otlp: endpoint: receiver.svc.cluster.local:4317 diff --git a/config/samples/telemetry_v1alpha1_subscription.yaml b/config/samples/telemetry_v1alpha1_subscription.yaml index 49391f35..6c40b6f9 100644 --- a/config/samples/telemetry_v1alpha1_subscription.yaml +++ b/config/samples/telemetry_v1alpha1_subscription.yaml @@ -10,5 +10,5 @@ metadata: name: subscription-sample spec: outputs: - - name: oteloutput-sample + - name: output-sample namespace: collector diff --git a/docs/demos/loki/manifests.yaml b/docs/demos/loki/manifests.yaml index 8f8f50c6..2d89535c 100644 --- a/docs/demos/loki/manifests.yaml +++ b/docs/demos/loki/manifests.yaml @@ -56,7 +56,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: loki namespace: collector @@ -94,7 +94,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: openobserve-1 namespace: collector @@ -109,7 +109,7 @@ spec: insecure: true --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: openobserve-2 namespace: collector diff --git a/docs/demos/openobserve/demo.yaml b/docs/demos/openobserve/demo.yaml index 5e42cc38..162073dd 100644 --- a/docs/demos/openobserve/demo.yaml +++ b/docs/demos/openobserve/demo.yaml @@ -57,7 +57,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-openobserve namespace: collector diff --git a/docs/examples/fluent-forward/telemetry-controller.yaml b/docs/examples/fluent-forward/telemetry-controller.yaml index 5ea1605b..58664935 100644 --- a/docs/examples/fluent-forward/telemetry-controller.yaml +++ b/docs/examples/fluent-forward/telemetry-controller.yaml @@ -36,7 +36,7 @@ spec: namespace: default --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: fluent namespace: default diff --git a/docs/examples/simple-demo/one_tenant_two_subscriptions.yaml b/docs/examples/simple-demo/one_tenant_two_subscriptions.yaml index 5b4ea4a4..d78b78a1 100644 --- a/docs/examples/simple-demo/one_tenant_two_subscriptions.yaml +++ b/docs/examples/simple-demo/one_tenant_two_subscriptions.yaml @@ -57,7 +57,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output-1 namespace: collector @@ -72,7 +72,7 @@ spec: insecure: true --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output-2 namespace: collector diff --git a/docs/examples/two_tenants_one_subscription_each.yaml b/docs/examples/two_tenants_one_subscription_each.yaml index e7c9bf47..44bb7dfd 100644 --- a/docs/examples/two_tenants_one_subscription_each.yaml +++ b/docs/examples/two_tenants_one_subscription_each.yaml @@ -88,7 +88,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output-1 namespace: collector @@ -99,7 +99,7 @@ spec: insecure: true --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output-2 namespace: collector diff --git a/e2e/testdata/one_tenant_two_subscriptions/one_tenant_two_subscriptions.yaml b/e2e/testdata/one_tenant_two_subscriptions/one_tenant_two_subscriptions.yaml index 773ed447..86d5fa68 100644 --- a/e2e/testdata/one_tenant_two_subscriptions/one_tenant_two_subscriptions.yaml +++ b/e2e/testdata/one_tenant_two_subscriptions/one_tenant_two_subscriptions.yaml @@ -57,7 +57,7 @@ spec: namespace: collector --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output namespace: collector @@ -68,7 +68,7 @@ spec: insecure: true --- apiVersion: telemetry.kube-logging.dev/v1alpha1 -kind: OtelOutput +kind: Output metadata: name: otlp-test-output-2 namespace: collector diff --git a/internal/controller/telemetry/collector_controller.go b/internal/controller/telemetry/collector_controller.go index efc1ace8..4cd33547 100644 --- a/internal/controller/telemetry/collector_controller.go +++ b/internal/controller/telemetry/collector_controller.go @@ -64,7 +64,7 @@ func (r *CollectorReconciler) buildConfigInputForCollector(ctx context.Context, tenants, err := r.getTenantsMatchingSelectors(ctx, collector.Spec.TenantSelector) subscriptions := make(map[v1alpha1.NamespacedName]v1alpha1.Subscription) - outputs := []v1alpha1.OtelOutput{} + outputs := []v1alpha1.Output{} if err != nil { logger.Error(errors.WithStack(err), "failed listing tenants") @@ -96,7 +96,7 @@ func (r *CollectorReconciler) buildConfigInputForCollector(ctx context.Context, subscriptionOutputMap[subscription.NamespacedName()] = outputNames for _, outputName := range outputNames { - queriedOutput := &v1alpha1.OtelOutput{} + queriedOutput := &v1alpha1.Output{} if err = r.Client.Get(ctx, types.NamespacedName(outputName), queriedOutput); err != nil { logger.Error(errors.WithStack(err), "failed getting outputs for subscription", "subscription", subscription.NamespacedName().String()) return OtelColConfigInput{}, err @@ -118,8 +118,8 @@ func (r *CollectorReconciler) buildConfigInputForCollector(ctx context.Context, return otelConfigInput, nil } -// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors;tenants;subscriptions;oteloutputs;,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/status;tenants/status;subscriptions/status;oteloutputs/status;,verbs=get;update;patch +// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors;tenants;subscriptions;outputs;,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/status;tenants/status;subscriptions/status;outputs/status;,verbs=get;update;patch // +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/finalizers,verbs=update // +kubebuilder:rbac:groups="",resources=nodes;namespaces;endpoints;nodes/proxy,verbs=get;list;watch // +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=clusterroles;clusterrolebindings;roles;rolebindings,verbs=get;list;watch;create;update;patch;delete @@ -282,7 +282,7 @@ func (r *CollectorReconciler) SetupWithManager(mgr ctrl.Manager) error { return })). - Watches(&v1alpha1.OtelOutput{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) (requests []reconcile.Request) { + Watches(&v1alpha1.Output{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) (requests []reconcile.Request) { logger := log.FromContext(ctx) collectors := &v1alpha1.CollectorList{} diff --git a/internal/controller/telemetry/controller_integration_test.go b/internal/controller/telemetry/controller_integration_test.go index b5623f24..7e783f82 100644 --- a/internal/controller/telemetry/controller_integration_test.go +++ b/internal/controller/telemetry/controller_integration_test.go @@ -168,13 +168,13 @@ var _ = Describe("Telemetry controller integration test", func() { It("Outputs should be created", func() { - outputs := []v1alpha1.OtelOutput{ + outputs := []v1alpha1.Output{ { ObjectMeta: metav1.ObjectMeta{ Name: "otlp-test-output-1", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ OTLP: &v1alpha1.OTLP{ GRPCClientConfig: v1alpha1.GRPCClientConfig{ Endpoint: "receiver-collector.example-tenant-ns.svc.cluster.local:4317", @@ -190,7 +190,7 @@ var _ = Describe("Telemetry controller integration test", func() { Name: "otlp-test-output-2", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ OTLP: &v1alpha1.OTLP{ GRPCClientConfig: v1alpha1.GRPCClientConfig{ Endpoint: "receiver-collector.example-tenant-ns.svc.cluster.local:4317", diff --git a/internal/controller/telemetry/otel_conf_gen.go b/internal/controller/telemetry/otel_conf_gen.go index 612573a6..9bad70eb 100644 --- a/internal/controller/telemetry/otel_conf_gen.go +++ b/internal/controller/telemetry/otel_conf_gen.go @@ -38,7 +38,7 @@ type OtelColConfigInput struct { // These must only include resources that are selected by the collector, tenant labelselectors, and listed outputs in the subscriptions Tenants []v1alpha1.Tenant Subscriptions map[v1alpha1.NamespacedName]v1alpha1.Subscription - Outputs []v1alpha1.OtelOutput + Outputs []v1alpha1.Output MemoryLimiter v1alpha1.MemoryLimiter // Subscriptions map, where the key is the Tenants' name, value is a slice of subscriptions' namespaced name @@ -261,7 +261,7 @@ func (cfgInput *OtelColConfigInput) generateOTLPExporters(ctx context.Context) m for _, output := range cfgInput.Outputs { if output.Spec.OTLP != nil { - name := GetExporterNameForOtelOutput(output) + name := GetExporterNameForOutput(output) otlpGrpcValuesMarshaled, err := yaml.Marshal(output.Spec.OTLP) if err != nil { logger.Error(errors.New("failed to compile config for output"), "failed to compile config for output %q", output.NamespacedName().String()) @@ -286,7 +286,7 @@ func (cfgInput *OtelColConfigInput) generateLokiExporters(ctx context.Context) m for _, output := range cfgInput.Outputs { if output.Spec.Loki != nil { - name := GetExporterNameForOtelOutput(output) + name := GetExporterNameForOutput(output) lokiHTTPValuesMarshaled, err := yaml.Marshal(output.Spec.Loki) if err != nil { logger.Error(errors.New("failed to compile config for output"), "failed to compile config for output %q", output.NamespacedName().String()) @@ -547,12 +547,12 @@ func (cfgInput *OtelColConfigInput) generateProcessors() map[string]any { return processors } -func generateOutputExporterNameProcessor(output v1alpha1.OtelOutput) AttributesProcessor { +func generateOutputExporterNameProcessor(output v1alpha1.Output) AttributesProcessor { processor := AttributesProcessor{ Actions: []AttributesProcessorAction{{ Action: "insert", Key: "exporter", - Value: GetExporterNameForOtelOutput(output), + Value: GetExporterNameForOutput(output), }}, } @@ -689,7 +689,7 @@ func (cfgInput *OtelColConfigInput) generateNamedPipelines() map[string]*otelv1b for _, outputRef := range cfgInput.SubscriptionOutputMap[subscription] { outputPipelineName := fmt.Sprintf("logs/output_%s_%s_%s_%s", subscription.Namespace, subscription.Name, outputRef.Namespace, outputRef.Name) - idx := slices.IndexFunc(cfgInput.Outputs, func(elem v1alpha1.OtelOutput) bool { + idx := slices.IndexFunc(cfgInput.Outputs, func(elem v1alpha1.Output) bool { return outputRef == elem.NamespacedName() }) @@ -704,15 +704,15 @@ func (cfgInput *OtelColConfigInput) generateNamedPipelines() map[string]*otelv1b processors = append(processors, fmt.Sprintf("attributes/loki_exporter_%s", output.Name), fmt.Sprintf("resource/loki_exporter_%s", output.Name)) - exporters = []string{GetExporterNameForOtelOutput(output), outputCountConnectorName} + exporters = []string{GetExporterNameForOutput(output), outputCountConnectorName} } if output.Spec.OTLP != nil { - exporters = []string{GetExporterNameForOtelOutput(output), outputCountConnectorName} + exporters = []string{GetExporterNameForOutput(output), outputCountConnectorName} } if output.Spec.Fluentforward != nil { - exporters = []string{GetExporterNameForOtelOutput(output), outputCountConnectorName} + exporters = []string{GetExporterNameForOutput(output), outputCountConnectorName} } if cfgInput.Debug { exporters = append(exporters, "logging/debug") diff --git a/internal/controller/telemetry/otel_conf_gen_test.go b/internal/controller/telemetry/otel_conf_gen_test.go index 7c9db944..7ce43f69 100644 --- a/internal/controller/telemetry/otel_conf_gen_test.go +++ b/internal/controller/telemetry/otel_conf_gen_test.go @@ -168,13 +168,13 @@ func TestOtelColConfComplex(t *testing.T) { }, }, }, - Outputs: []v1alpha1.OtelOutput{ + Outputs: []v1alpha1.Output{ { ObjectMeta: metav1.ObjectMeta{ Name: "otlp-test-output", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ OTLP: &v1alpha1.OTLP{ GRPCClientConfig: v1alpha1.GRPCClientConfig{ Endpoint: "receiver-collector.example-tenant-a-ns.svc.cluster.local:4317", @@ -190,7 +190,7 @@ func TestOtelColConfComplex(t *testing.T) { Name: "otlp-test-output-2", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ OTLP: &v1alpha1.OTLP{ GRPCClientConfig: v1alpha1.GRPCClientConfig{ Endpoint: "receiver-collector.example-tenant-a-ns.svc.cluster.local:4317", @@ -206,7 +206,7 @@ func TestOtelColConfComplex(t *testing.T) { Name: "loki-test-output", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ Loki: &v1alpha1.Loki{ HTTPClientConfig: v1alpha1.HTTPClientConfig{ Endpoint: "loki.example-tenant-a-ns.svc.cluster.local:4317", @@ -222,7 +222,7 @@ func TestOtelColConfComplex(t *testing.T) { Name: "fluentforward-test-output", Namespace: "collector", }, - Spec: v1alpha1.OtelOutputSpec{ + Spec: v1alpha1.OutputSpec{ Fluentforward: &v1alpha1.Fluentforward{ TCPClientSettings: v1alpha1.TCPClientSettings{ Endpoint: "fluentforward.example-tenant-ns.svc.cluster.local:8888", @@ -295,7 +295,7 @@ func TestOtelColConfigInput_generateRoutingConnectorForTenantsSubscription(t *te type fields struct { Tenants []v1alpha1.Tenant Subscriptions map[v1alpha1.NamespacedName]v1alpha1.Subscription - Outputs []v1alpha1.OtelOutput + Outputs []v1alpha1.Output TenantSubscriptionMap map[string][]v1alpha1.NamespacedName SubscriptionOutputMap map[v1alpha1.NamespacedName][]v1alpha1.NamespacedName } @@ -354,7 +354,7 @@ func TestOtelColConfigInput_generateRoutingConnectorForTenantsSubscription(t *te }, OTTL: `set(attributes["subscription"], "subscriptionB")`}, }, }, - Outputs: []v1alpha1.OtelOutput{}, + Outputs: []v1alpha1.Output{}, TenantSubscriptionMap: map[string][]v1alpha1.NamespacedName{ "tenantA": { { diff --git a/internal/controller/telemetry/route_controller.go b/internal/controller/telemetry/route_controller.go index 9cfcf40c..d11f6417 100644 --- a/internal/controller/telemetry/route_controller.go +++ b/internal/controller/telemetry/route_controller.go @@ -42,8 +42,8 @@ type RouteReconciler struct { Scheme *runtime.Scheme } -// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors;tenants;subscriptions;oteloutputs;,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/status;tenants/status;subscriptions/status;oteloutputs/status;,verbs=get;update;patch +// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors;tenants;subscriptions;outputs;,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/status;tenants/status;subscriptions/status;outputs/status;,verbs=get;update;patch // +kubebuilder:rbac:groups=telemetry.kube-logging.dev,resources=collectors/finalizers,verbs=update // +kubebuilder:rbac:groups="",resources=nodes;namespaces;endpoints;nodes/proxy,verbs=get;list;watch // +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=clusterroles;clusterrolebindings;roles;rolebindings,verbs=get;list;watch;create;update;patch;delete @@ -100,7 +100,7 @@ func (r *RouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl originalSubscriptionStatus := subscription.Status.DeepCopy() validOutputs := []v1alpha1.NamespacedName{} for _, outputRef := range subscription.Spec.Outputs { - checkedOutput := &v1alpha1.OtelOutput{} + checkedOutput := &v1alpha1.Output{} if err := r.Client.Get(ctx, types.NamespacedName(outputRef), checkedOutput); err != nil { logger.Error(err, "referred output invalid", "output", outputRef.String()) } else { @@ -184,7 +184,7 @@ func (r *RouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return })). - Watches(&v1alpha1.OtelOutput{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) (requests []reconcile.Request) { + Watches(&v1alpha1.Output{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) (requests []reconcile.Request) { logger := log.FromContext(ctx) tenants := &v1alpha1.TenantList{} diff --git a/internal/controller/telemetry/utils.go b/internal/controller/telemetry/utils.go index 6b11d4d4..2a242f2d 100644 --- a/internal/controller/telemetry/utils.go +++ b/internal/controller/telemetry/utils.go @@ -20,7 +20,7 @@ import ( "github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1" ) -func GetExporterNameForOtelOutput(output v1alpha1.OtelOutput) string { +func GetExporterNameForOutput(output v1alpha1.Output) string { var exporterName string if output.Spec.Loki != nil { exporterName = fmt.Sprintf("loki/%s_%s", output.Namespace, output.Name)