Skip to content

Commit

Permalink
Merge pull request #110 from kube-logging/fix/select-all-ns
Browse files Browse the repository at this point in the history
fix: select all log source namespaces
  • Loading branch information
csatib02 authored Dec 6, 2024
2 parents 8e64c0e + 63a4b7c commit 910ae7a
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 66 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ crddir
.DS_Store

go.work.sum

# Ignore DevSpace cache and log folder and DevSpace configuration file
.devspace/
devspace.yaml
12 changes: 10 additions & 2 deletions api/telemetry/v1alpha1/bridge_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ import (

// BridgeSpec defines the desired state of Bridge
type BridgeSpec struct {
// +kubebuilder:validation:Required

// The source tenant from which telemetry will be forwarded.
SourceTenant string `json:"sourceTenant"`

// +kubebuilder:validation:Required

// The target tenant to which telemetry will be forwarded.
TargetTenant string `json:"targetTenant"`
// The OTTL condition which must be satisfied in order to forward telemetry
// from the source tenant to the target tenant

// The condition which must be satisfied in order to forward telemetry
// from the source tenant to the target tenant.
Condition string `json:"condition"`
}

Expand Down
17 changes: 13 additions & 4 deletions api/telemetry/v1alpha1/collector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,22 @@ type MemoryLimiter struct {

// CollectorSpec defines the desired state of Collector
type CollectorSpec struct {
// TenantSelector is used to select tenants for which the collector should collect data.
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
// Namespace where OTel collector DaemonSet is deployed

// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable, please recreate the resource"

// Namespace where the Otel collector DaemonSet is deployed.
ControlNamespace string `json:"controlNamespace"`
// Enables debug logging for the collector

// Enables debug logging for the collector.
Debug bool `json:"debug,omitempty"`
// Setting memory limits for the Collector
MemoryLimiter *MemoryLimiter `json:"memoryLimiter,omitempty"`

// Setting memory limits for the Collector using the memory limiter processor.
MemoryLimiter *MemoryLimiter `json:"memoryLimiter,omitempty"`

// DaemonSetOverrides is used to override the default DaemonSet configuration.
DaemonSetOverrides *typeoverride.DaemonSet `json:"daemonSet,omitempty"`
}

Expand Down
7 changes: 6 additions & 1 deletion api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Batch processor configuration.
type Batch struct {
// From go.opentelemetry.io/collector/processor/batchprocessor

Expand Down Expand Up @@ -65,6 +66,7 @@ type OutputSpec struct {
Batch *Batch `json:"batch,omitempty"`
}

// Output Authentication configuration.
type OutputAuth struct {
BasicAuth *BasicAuthConfig `json:"basicauth,omitempty"`
BearerAuth *BearerAuthConfig `json:"bearerauth,omitempty"`
Expand All @@ -81,20 +83,23 @@ type BearerAuthConfig struct {
TokenField string `json:"tokenField,omitempty"`
}

// OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
// Configuration for the OTLP gRPC exporter.
// ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
type OTLPGRPC struct {
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline"`
GRPCClientConfig `json:",inline"`
}

// Configuration for the OTLP HTTP exporter.
type OTLPHTTP struct {
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
HTTPClientConfig `json:",inline"`
}

// Configuration for the fluentforward exporter.
type Fluentforward struct {
TCPClientSettings `json:",inline"`

Expand Down
11 changes: 9 additions & 2 deletions api/telemetry/v1alpha1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ import (

// SubscriptionSpec defines the desired state of Subscription
type SubscriptionSpec struct {
Condition string `json:"condition"`
Outputs []NamespacedName `json:"outputs,omitempty"`
// +kubebuilder:validation:Required

// The condition which must be satisfied in order to forward telemetry to the outputs.
Condition string `json:"condition"`

// +kubebuilder:validation:Required

// The outputs to which the logs will be routed if the condition evaluates to true.
Outputs []NamespacedName `json:"outputs"`
}

// SubscriptionStatus defines the observed state of Subscription
Expand Down
25 changes: 18 additions & 7 deletions api/telemetry/v1alpha1/tenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// TransformStatement represents a single statement in a Transform processor
// TransformStatement represents a single statement in a Transform processor.
// ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
type TransformStatement struct {
// +kubebuilder:validation:Enum:=resource;scope;span;spanevent;metric;datapoint;log

Context string `json:"context,omitempty"`
Conditions []string `json:"conditions,omitempty"`
Statements []string `json:"statements,omitempty"`
Expand All @@ -32,8 +33,8 @@ type Transform struct {
// Name of the Transform processor
Name string `json:"name,omitempty"`

// When FlattenData is true, the processor provides each log record with a distinct copy
// of its resource and scope. Then, after applying all transformations,
// When FlattenData is true, the processor provides each log record with
// a distinct copy of its resource and scope. Then, after applying all transformations,
// the log records are regrouped by resource and scope.
FlattenData bool `json:"flattenData,omitempty"`

Expand All @@ -51,22 +52,32 @@ type Transform struct {
// RouteConfig defines the routing configuration for a tenant
// it will be used to generate routing connectors
type RouteConfig struct {
// Contains the list of pipelines to use when a record does not meet any of specified conditions.
DefaultPipelines []string `json:"defaultPipelines,omitempty"` // TODO: Provide users with a guide to determine generated pipeline names

// +kubebuilder:validation:Enum:=ignore;silent;propagate

// ErrorMode specifies how errors are handled while processing a statement
// vaid options are: ignore, silent, propagate; (default: propagate)
ErrorMode string `json:"errorMode,omitempty"`
MatchOnce bool `json:"matchOnce,omitempty"`

// Determines whether the connector matches multiple statements or not.
// If enabled, the payload will be routed to the first pipeline in the table whose routing condition is met.
// May only be false when used with resource context.
MatchOnce bool `json:"matchOnce,omitempty"`
}

// TenantSpec defines the desired state of Tenant
type TenantSpec struct {
// Determines the namespaces from which subscriptions are collected by this tenant.
SubscriptionNamespaceSelectors []metav1.LabelSelector `json:"subscriptionNamespaceSelectors,omitempty"`
LogSourceNamespaceSelectors []metav1.LabelSelector `json:"logSourceNamespaceSelectors,omitempty"`
Transform Transform `json:"transform,omitempty"`
RouteConfig RouteConfig `json:"routeConfig,omitempty"`

// Determines the namespaces from which logs are collected by this tenant.
// If initialized with an empty list, logs from all namespaces are collected.
// If uninitialized, no logs are collected.
LogSourceNamespaceSelectors []metav1.LabelSelector `json:"logSourceNamespaceSelectors,omitempty"`
Transform `json:"transform,omitempty"`
RouteConfig `json:"routeConfig,omitempty"`
}

// TenantStatus defines the observed state of Tenant
Expand Down
14 changes: 9 additions & 5 deletions charts/telemetry-controller/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
apiVersion: v2
name: telemetry-controller
description: A Helm chart for deploying telemetry-controller

type: application

name: telemetry-controller
version: 0.0.0
appVersion: latest

kubeVersion: ">=1.26.0"
description: A Helm chart for deploying telemetry-controller
keywords:
- opentelemetry-collector
- telemetry-controller
- collector
sources:
- https://github.com/kube-logging/telemetry-controller
dependencies:
- name: opentelemetry-operator
version: 0.74.3
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ spec:
properties:
condition:
description: |-
The OTTL condition which must be satisfied in order to forward telemetry
from the source tenant to the target tenant
The condition which must be satisfied in order to forward telemetry
from the source tenant to the target tenant.
type: string
sourceTenant:
description: The source tenant from which telemetry will be forwarded.
type: string
targetTenant:
description: The target tenant to which telemetry will be forwarded.
type: string
required:
- condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ spec:
description: CollectorSpec defines the desired state of Collector
properties:
controlNamespace:
description: Namespace where OTel collector DaemonSet is deployed
description: Namespace where the Otel collector DaemonSet is deployed.
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
daemonSet:
description: DaemonSet is a subset of [DaemonSet in k8s.io/api/apps/v1](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#daemonset-v1-apps),
with [DaemonSetSpec replaced by the local variant](#daemonset-spec).
description: DaemonSetOverrides is used to override the default DaemonSet
configuration.
properties:
metadata:
description: ObjectMeta contains only a [subset of the fields
Expand Down Expand Up @@ -8049,10 +8052,11 @@ spec:
type: object
type: object
debug:
description: Enables debug logging for the collector
description: Enables debug logging for the collector.
type: boolean
memoryLimiter:
description: Setting memory limits for the Collector
description: Setting memory limits for the Collector using the memory
limiter processor.
properties:
check_interval:
description: |-
Expand Down Expand Up @@ -8093,10 +8097,8 @@ spec:
- spike_limit_percentage
type: object
tenantSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
description: TenantSelector is used to select tenants for which the
collector should collect data.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
description: OutputSpec defines the desired state of Output
properties:
authentication:
description: Output Authentication configuration.
properties:
basicauth:
properties:
Expand Down Expand Up @@ -87,6 +88,7 @@ spec:
type: object
type: object
batch:
description: Batch processor configuration.
properties:
metadata_cardinality_limit:
description: |-
Expand Down Expand Up @@ -132,6 +134,7 @@ spec:
type: string
type: object
fluentforward:
description: Configuration for the fluentforward exporter.
properties:
compress_gzip:
description: CompressGzip enables gzip compression for the payload.
Expand Down Expand Up @@ -293,7 +296,9 @@ spec:
type: object
type: object
otlp:
description: 'OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go'
description: |-
Configuration for the OTLP gRPC exporter.
ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
properties:
auth:
description: Auth configuration for outgoing RPCs.
Expand Down Expand Up @@ -497,6 +502,7 @@ spec:
- endpoint
type: object
otlphttp:
description: Configuration for the OTLP HTTP exporter.
properties:
auth:
description: Auth configuration for outgoing HTTP calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ spec:
description: SubscriptionSpec defines the desired state of Subscription
properties:
condition:
description: The condition which must be satisfied in order to forward
telemetry to the outputs.
type: string
outputs:
description: The outputs to which the logs will be routed if the condition
evaluates to true.
items:
properties:
name:
Expand All @@ -67,6 +71,7 @@ spec:
type: array
required:
- condition
- outputs
type: object
status:
description: SubscriptionStatus defines the observed state of Subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ spec:
description: TenantSpec defines the desired state of Tenant
properties:
logSourceNamespaceSelectors:
description: |-
Determines the namespaces from which logs are collected by this tenant.
If initialized with an empty list, logs from all namespaces are collected.
If uninitialized, no logs are collected.
items:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
Expand Down Expand Up @@ -111,6 +115,8 @@ spec:
it will be used to generate routing connectors
properties:
defaultPipelines:
description: Contains the list of pipelines to use when a record
does not meet any of specified conditions.
items:
type: string
type: array
Expand All @@ -124,9 +130,15 @@ spec:
- propagate
type: string
matchOnce:
description: |-
Determines whether the connector matches multiple statements or not.
If enabled, the payload will be routed to the first pipeline in the table whose routing condition is met.
May only be false when used with resource context.
type: boolean
type: object
subscriptionNamespaceSelectors:
description: Determines the namespaces from which subscriptions are
collected by this tenant.
items:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
Expand Down Expand Up @@ -192,14 +204,14 @@ spec:
type: string
flattenData:
description: |-
When FlattenData is true, the processor provides each log record with a distinct copy
of its resource and scope. Then, after applying all transformations,
When FlattenData is true, the processor provides each log record with
a distinct copy of its resource and scope. Then, after applying all transformations,
the log records are regrouped by resource and scope.
type: boolean
logStatements:
items:
description: |-
TransformStatement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor.
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand All @@ -225,7 +237,7 @@ spec:
metricStatements:
items:
description: |-
TransformStatement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor.
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down Expand Up @@ -254,7 +266,7 @@ spec:
traceStatements:
items:
description: |-
TransformStatement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor.
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down
Loading

0 comments on commit 910ae7a

Please sign in to comment.