From f66b81735279a523605e34afe3970838fa46f51f Mon Sep 17 00:00:00 2001 From: Julien Boulanger Date: Thu, 17 Oct 2024 20:11:53 +0200 Subject: [PATCH] feat: enable vector API --- Dockerfile | 2 +- apis/telemetry/v1alpha1/telemetry_types.go | 5 +++ .../v1alpha1/zz_generated.deepcopy.go | 25 +++++++++++ .../crds/k8ssandra-operator-crds.yaml | 45 +++++++++++++++++++ .../bases/k8ssandra.io_k8ssandraclusters.yaml | 30 +++++++++++++ .../bases/reaper.k8ssandra.io_reapers.yaml | 5 +++ .../stargate.k8ssandra.io_stargates.yaml | 10 +++++ pkg/telemetry/vector.go | 6 +++ 8 files changed, 127 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 466592ec2..77e116550 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.22 as builder +FROM golang:1.22 AS builder ARG TARGETOS ARG TARGETARCH diff --git a/apis/telemetry/v1alpha1/telemetry_types.go b/apis/telemetry/v1alpha1/telemetry_types.go index ec85f84f8..5d9b33293 100644 --- a/apis/telemetry/v1alpha1/telemetry_types.go +++ b/apis/telemetry/v1alpha1/telemetry_types.go @@ -43,6 +43,11 @@ type VectorSpec struct { ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` Components *VectorComponentsSpec `json:"components,omitempty"` + Api *ApiConfig `json:"api,omitempty"` +} + +type ApiConfig struct { + Enabled *bool `json:"enabled,omitempty"` } type VectorComponentsSpec struct { diff --git a/apis/telemetry/v1alpha1/zz_generated.deepcopy.go b/apis/telemetry/v1alpha1/zz_generated.deepcopy.go index cabc06a51..9b4869fc2 100644 --- a/apis/telemetry/v1alpha1/zz_generated.deepcopy.go +++ b/apis/telemetry/v1alpha1/zz_generated.deepcopy.go @@ -26,6 +26,26 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApiConfig) DeepCopyInto(out *ApiConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiConfig. +func (in *ApiConfig) DeepCopy() *ApiConfig { + if in == nil { + return nil + } + out := new(ApiConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CassandraAgentSpec) DeepCopyInto(out *CassandraAgentSpec) { *out = *in @@ -251,6 +271,11 @@ func (in *VectorSpec) DeepCopyInto(out *VectorSpec) { *out = new(VectorComponentsSpec) (*in).DeepCopyInto(*out) } + if in.Api != nil { + in, out := &in.Api, &out.Api + *out = new(ApiConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VectorSpec. diff --git a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml index 244e42f65..54ba6cc89 100644 --- a/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml +++ b/charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml @@ -13599,6 +13599,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -14144,6 +14149,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -16630,6 +16640,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -25536,6 +25551,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -29040,6 +29060,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -30803,6 +30828,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -35137,6 +35167,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -38523,6 +38558,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -39053,6 +39093,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: diff --git a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml index 49a466754..9d918ba36 100644 --- a/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml +++ b/config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml @@ -13537,6 +13537,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -14082,6 +14087,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -16568,6 +16578,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -25474,6 +25489,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -28978,6 +28998,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -30741,6 +30766,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: diff --git a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml index f32c358ae..22a61edbc 100644 --- a/config/crd/bases/reaper.k8ssandra.io_reapers.yaml +++ b/config/crd/bases/reaper.k8ssandra.io_reapers.yaml @@ -2565,6 +2565,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: diff --git a/config/crd/bases/stargate.k8ssandra.io_stargates.yaml b/config/crd/bases/stargate.k8ssandra.io_stargates.yaml index 6821b92c3..d44223519 100644 --- a/config/crd/bases/stargate.k8ssandra.io_stargates.yaml +++ b/config/crd/bases/stargate.k8ssandra.io_stargates.yaml @@ -2995,6 +2995,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: @@ -3525,6 +3530,11 @@ spec: type: object vector: properties: + api: + properties: + enabled: + type: boolean + type: object components: properties: sinks: diff --git a/pkg/telemetry/vector.go b/pkg/telemetry/vector.go index 4dccef017..67266d3d3 100644 --- a/pkg/telemetry/vector.go +++ b/pkg/telemetry/vector.go @@ -292,6 +292,12 @@ Clean: func BuildCustomVectorToml(telemetrySpec *telemetry.TelemetrySpec) string { vectorConfigToml := "" + + if telemetrySpec.Vector.Api != nil && telemetrySpec.Vector.Api.Enabled != nil && *telemetrySpec.Vector.Api.Enabled { + vectorConfigToml += "[api]\n" + vectorConfigToml += "enabled = true\n" + } + for _, source := range telemetrySpec.Vector.Components.Sources { vectorConfigToml += fmt.Sprintf("\n[sources.%s]\n", source.Name) vectorConfigToml += fmt.Sprintf("type = \"%s\"\n", source.Type)