Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 05ef79d

Browse files
authored
Add base support to deploy gateway collectors (#184)
* Add base support to deploy gateway collectors
1 parent 2d18e22 commit 05ef79d

23 files changed

+1077
-58
lines changed

apis/otel/v1alpha1/defaults.go

Lines changed: 175 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,181 @@ service:
397397

398398
defaultGatewayCPU = "4"
399399
defaultGatewayMemory = "8Gi"
400-
400+
defaultGatewayConfig = `
401+
exporters:
402+
sapm:
403+
access_token: ${SPLUNK_ACCESS_TOKEN}
404+
endpoint: https://ingest.${SPLUNK_REALM}.signalfx.com/v2/trace
405+
signalfx:
406+
access_token: ${SPLUNK_ACCESS_TOKEN}
407+
api_url: https://api.${SPLUNK_REALM}.signalfx.com
408+
ingest_url: https://ingest.${SPLUNK_REALM}.signalfx.com
409+
extensions:
410+
health_check: null
411+
http_forwarder:
412+
egress:
413+
endpoint: https://api.${SPLUNK_REALM}.signalfx.com
414+
memory_ballast:
415+
size_mib: ${SPLUNK_BALLAST_SIZE_MIB}
416+
zpages: null
417+
processors:
418+
batch: null
419+
filter/logs:
420+
logs:
421+
exclude:
422+
match_type: strict
423+
resource_attributes:
424+
- key: splunk.com/exclude
425+
value: "true"
426+
k8sattributes:
427+
extract:
428+
annotations:
429+
- from: pod
430+
key: splunk.com/sourcetype
431+
- from: namespace
432+
key: splunk.com/exclude
433+
tag_name: splunk.com/exclude
434+
- from: pod
435+
key: splunk.com/exclude
436+
tag_name: splunk.com/exclude
437+
- from: namespace
438+
key: splunk.com/index
439+
tag_name: com.splunk.index
440+
- from: pod
441+
key: splunk.com/index
442+
tag_name: com.splunk.index
443+
labels:
444+
- key: app
445+
metadata:
446+
- k8s.namespace.name
447+
- k8s.node.name
448+
- k8s.pod.name
449+
- k8s.pod.uid
450+
pod_association:
451+
- from: resource_attribute
452+
name: k8s.pod.uid
453+
- from: resource_attribute
454+
name: k8s.pod.ip
455+
- from: resource_attribute
456+
name: ip
457+
- from: connection
458+
- from: resource_attribute
459+
name: host.name
460+
memory_limiter:
461+
check_interval: 2s
462+
limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB}
463+
resource/add_cluster_name:
464+
attributes:
465+
- action: upsert
466+
key: k8s.cluster.name
467+
value: ${MY_CLUSTER_NAME}
468+
resource/add_collector_k8s:
469+
attributes:
470+
- action: insert
471+
key: k8s.node.name
472+
value: ${K8S_NODE_NAME}
473+
- action: insert
474+
key: k8s.pod.name
475+
value: ${K8S_POD_NAME}
476+
- action: insert
477+
key: k8s.pod.uid
478+
value: ${K8S_POD_UID}
479+
- action: insert
480+
key: k8s.namespace.name
481+
value: ${K8S_NAMESPACE}
482+
resource/logs:
483+
attributes:
484+
- action: upsert
485+
from_attribute: k8s.pod.annotations.splunk.com/sourcetype
486+
key: com.splunk.sourcetype
487+
- action: delete
488+
key: k8s.pod.annotations.splunk.com/sourcetype
489+
- action: delete
490+
key: splunk.com/exclude
491+
resourcedetection:
492+
detectors:
493+
- env
494+
- system
495+
override: true
496+
timeout: 10s
497+
receivers:
498+
jaeger:
499+
protocols:
500+
grpc:
501+
endpoint: 0.0.0.0:14250
502+
thrift_http:
503+
endpoint: 0.0.0.0:14268
504+
otlp:
505+
protocols:
506+
grpc:
507+
endpoint: 0.0.0.0:4317
508+
http:
509+
endpoint: 0.0.0.0:4318
510+
prometheus/collector:
511+
config:
512+
scrape_configs:
513+
- job_name: otel-collector
514+
scrape_interval: 10s
515+
static_configs:
516+
- targets:
517+
- ${K8S_POD_IP}:8889
518+
signalfx:
519+
access_token_passthrough: true
520+
endpoint: 0.0.0.0:9943
521+
zipkin:
522+
endpoint: 0.0.0.0:9411
523+
service:
524+
extensions:
525+
- health_check
526+
- memory_ballast
527+
- zpages
528+
- http_forwarder
529+
pipelines:
530+
logs/signalfx-events:
531+
exporters:
532+
- signalfx
533+
processors:
534+
- memory_limiter
535+
- batch
536+
receivers:
537+
- signalfx
538+
metrics:
539+
exporters:
540+
- signalfx
541+
processors:
542+
- memory_limiter
543+
- batch
544+
- resource/add_cluster_name
545+
receivers:
546+
- otlp
547+
- signalfx
548+
metrics/collector:
549+
exporters:
550+
- signalfx
551+
processors:
552+
- memory_limiter
553+
- batch
554+
- resource/add_collector_k8s
555+
- resourcedetection
556+
- resource/add_cluster_name
557+
receivers:
558+
- prometheus/collector
559+
traces:
560+
exporters:
561+
- sapm
562+
processors:
563+
- memory_limiter
564+
- batch
565+
- k8sattributes
566+
- resource/add_cluster_name
567+
receivers:
568+
- otlp
569+
- jaeger
570+
- zipkin
571+
telemetry:
572+
metrics:
573+
address: 0.0.0.0:8889
574+
`
401575
// the javaagent version is managed by the update-javaagent-version.sh script.
402576
defaultJavaAgentVersion = "v1.14.1"
403577
defaultJavaAgentImage = "quay.io/signalfx/splunk-otel-instrumentation-java:" + defaultJavaAgentVersion

apis/otel/v1alpha1/splunkotelagent_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ type AgentSpec struct {
156156
// +operator-sdk:csv:customresourcedefinitions:type=spec
157157
ClusterReceiver CollectorSpec `json:"clusterReceiver,omitempty"`
158158

159-
// ClusterReceiver is a Splunk OpenTelemetry Collector deployment used to export data to Splunk APM.
159+
// Gateway is a Splunk OpenTelemetry Collector deployment used to export data to Splunk APM.
160160
// +kubebuilder:validation:Optional
161161
// +operator-sdk:csv:customresourcedefinitions:type=spec
162162
Gateway CollectorSpec `json:"gateway,omitempty"`
@@ -187,7 +187,7 @@ type Agent struct {
187187
Status AgentStatus `json:"status,omitempty"`
188188
}
189189

190-
//+kubebuilder:object:root=true
190+
// +kubebuilder:object:root=true
191191

192192
// AgentList contains a list of SplunkOtelAgent.
193193
type AgentList struct {

apis/otel/v1alpha1/splunkotelagent_webhook.go

Lines changed: 110 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (r *Agent) validateCRDAgentSpec() error {
119119
spec := r.Spec.Agent
120120

121121
if spec.Replicas != nil {
122-
return fmt.Errorf("`replicas` is not supported by clusterReceiver")
122+
return fmt.Errorf("`replicas` is not supported by the agent")
123123
}
124124

125125
return nil
@@ -129,11 +129,11 @@ func (r *Agent) validateCRDClusterReceiverSpec() error {
129129
spec := r.Spec.ClusterReceiver
130130

131131
if spec.Replicas != nil {
132-
return fmt.Errorf("`replicas` is not supported by clusterReceiver")
132+
return fmt.Errorf("`replicas` is not supported by the clusterReceiver")
133133
}
134134

135135
if spec.HostNetwork {
136-
return fmt.Errorf("`hostNetwork` cannot be true for clusterReceiver")
136+
return fmt.Errorf("`hostNetwork` cannot be true for the clusterReceiver")
137137
}
138138

139139
return nil
@@ -142,10 +142,6 @@ func (r *Agent) validateCRDClusterReceiverSpec() error {
142142
func (r *Agent) validateCRDGatewaySpec() error {
143143
spec := r.Spec.Gateway
144144

145-
if r.Spec.Gateway.Enabled != nil && *r.Spec.Gateway.Enabled {
146-
return fmt.Errorf("gateway is not supported at the moment")
147-
}
148-
149145
if spec.HostNetwork {
150146
return fmt.Errorf("`hostNetwork` cannot be true for clusterReceiver")
151147
}
@@ -249,8 +245,6 @@ func (r *Agent) defaultClusterReceiver() {
249245

250246
func (r *Agent) defaultGateway() {
251247
spec := &r.Spec.Gateway
252-
// TODO(splunk): forcibly disable gateway until we add support for it.
253-
spec.Enabled = &[]bool{false}[0]
254248
spec.HostNetwork = false
255249

256250
// The gateway is not enabled by default
@@ -259,8 +253,115 @@ func (r *Agent) defaultGateway() {
259253
spec.Enabled = &s
260254
}
261255

256+
if spec.Replicas == nil {
257+
s := int32(3)
258+
spec.Replicas = &s
259+
}
260+
261+
if spec.Ports == nil {
262+
spec.Ports = []v1.ServicePort{
263+
{
264+
Name: "otlp",
265+
Protocol: "TCP",
266+
Port: 4317,
267+
},
268+
{
269+
Name: "otlp-http",
270+
Protocol: "TCP",
271+
Port: 4318,
272+
},
273+
{
274+
Protocol: "TCP",
275+
Port: 55681,
276+
},
277+
{
278+
Name: "jaeger-thrift",
279+
Protocol: "TCP",
280+
Port: 14268,
281+
},
282+
{
283+
Name: "jaeger-grpc",
284+
Protocol: "TCP",
285+
Port: 14250,
286+
},
287+
{
288+
Name: "zipkin",
289+
Protocol: "TCP",
290+
Port: 9411,
291+
},
292+
{
293+
Name: "signalfx",
294+
Protocol: "TCP",
295+
Port: 9943,
296+
},
297+
{
298+
Name: "http-forwarder",
299+
Protocol: "TCP",
300+
Port: 6060,
301+
},
302+
}
303+
}
304+
305+
if spec.Enabled == nil {
306+
s := false
307+
spec.Enabled = &s
308+
}
309+
310+
if spec.Replicas == nil {
311+
s := int32(3)
312+
spec.Replicas = &s
313+
}
314+
315+
if spec.Ports == nil {
316+
spec.Ports = []v1.ServicePort{
317+
{
318+
Name: "otlp",
319+
Protocol: "TCP",
320+
Port: 4317,
321+
},
322+
{
323+
Name: "otlp-http",
324+
Protocol: "TCP",
325+
Port: 4318,
326+
},
327+
{
328+
Protocol: "TCP",
329+
Port: 55681,
330+
},
331+
{
332+
Name: "jaeger-thrift",
333+
Protocol: "TCP",
334+
Port: 14268,
335+
},
336+
{
337+
Name: "jaeger-grpc",
338+
Protocol: "TCP",
339+
Port: 14250,
340+
},
341+
{
342+
Name: "zipkin",
343+
Protocol: "TCP",
344+
Port: 9411,
345+
},
346+
{
347+
Name: "signalfx",
348+
Protocol: "TCP",
349+
Port: 9943,
350+
},
351+
{
352+
Name: "http-forwarder",
353+
Protocol: "TCP",
354+
Port: 6060,
355+
},
356+
}
357+
}
358+
262359
setDefaultResources(spec, defaultGatewayCPU, defaultGatewayMemory)
263360
setDefaultEnvVars(spec, r.Spec.Realm, r.Spec.ClusterName)
361+
362+
if spec.Config == "" {
363+
spec.Config = defaultGatewayConfig
364+
}
264365
}
265366

266367
func setDefaultResources(spec *CollectorSpec, defaultCPU string,

bundle/manifests/otel.splunk.com_agents.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4222,7 +4222,7 @@ spec:
42224222
x-kubernetes-list-type: atomic
42234223
type: object
42244224
gateway:
4225-
description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
4225+
description: Gateway is a Splunk OpenTelemetry Collector deployment
42264226
used to export data to Splunk APM.
42274227
properties:
42284228
args:

bundle/manifests/splunk-otel-collector-operator.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ spec:
167167
deployment(s).
168168
displayName: Volumes
169169
path: clusterReceiver.volumes
170-
- description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
171-
used to export data to Splunk APM.
170+
- description: Gateway is a Splunk OpenTelemetry Collector deployment used to
171+
export data to Splunk APM.
172172
displayName: Gateway
173173
path: gateway
174174
- description: Args is the set of arguments to pass to the OpenTelemetry Collector

config/crd/bases/otel.splunk.com_agents.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,7 @@ spec:
42124212
x-kubernetes-list-type: atomic
42134213
type: object
42144214
gateway:
4215-
description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
4215+
description: Gateway is a Splunk OpenTelemetry Collector deployment
42164216
used to export data to Splunk APM.
42174217
properties:
42184218
args:

config/manifests/bases/splunk-otel-collector-operator.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ spec:
155155
deployment(s).
156156
displayName: Volumes
157157
path: clusterReceiver.volumes
158-
- description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
159-
used to export data to Splunk APM.
158+
- description: Gateway is a Splunk OpenTelemetry Collector deployment used to
159+
export data to Splunk APM.
160160
displayName: Gateway
161161
path: gateway
162162
- description: Args is the set of arguments to pass to the OpenTelemetry Collector

0 commit comments

Comments
 (0)