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

Commit

Permalink
Add base support to deploy gateway collectors
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoravong committed Sep 29, 2022
1 parent 2d18e22 commit c05a49c
Show file tree
Hide file tree
Showing 20 changed files with 870 additions and 37 deletions.
176 changes: 175 additions & 1 deletion apis/otel/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,181 @@ service:

defaultGatewayCPU = "4"
defaultGatewayMemory = "8Gi"

defaultGatewayConfig = `
exporters:
sapm:
access_token: ${SPLUNK_ACCESS_TOKEN}
endpoint: https://ingest.${SPLUNK_REALM}.signalfx.com/v2/trace
signalfx:
access_token: ${SPLUNK_ACCESS_TOKEN}
api_url: https://api.${SPLUNK_REALM}.signalfx.com
ingest_url: https://ingest.${SPLUNK_REALM}.signalfx.com
extensions:
health_check: null
http_forwarder:
egress:
endpoint: https://api.${SPLUNK_REALM}.signalfx.com
memory_ballast:
size_mib: ${SPLUNK_BALLAST_SIZE_MIB}
zpages: null
processors:
batch: null
filter/logs:
logs:
exclude:
match_type: strict
resource_attributes:
- key: splunk.com/exclude
value: "true"
k8sattributes:
extract:
annotations:
- from: pod
key: splunk.com/sourcetype
- from: namespace
key: splunk.com/exclude
tag_name: splunk.com/exclude
- from: pod
key: splunk.com/exclude
tag_name: splunk.com/exclude
- from: namespace
key: splunk.com/index
tag_name: com.splunk.index
- from: pod
key: splunk.com/index
tag_name: com.splunk.index
labels:
- key: app
metadata:
- k8s.namespace.name
- k8s.node.name
- k8s.pod.name
- k8s.pod.uid
pod_association:
- from: resource_attribute
name: k8s.pod.uid
- from: resource_attribute
name: k8s.pod.ip
- from: resource_attribute
name: ip
- from: connection
- from: resource_attribute
name: host.name
memory_limiter:
check_interval: 2s
limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB}
resource/add_cluster_name:
attributes:
- action: upsert
key: k8s.cluster.name
value: ${MY_CLUSTER_NAME}
resource/add_collector_k8s:
attributes:
- action: insert
key: k8s.node.name
value: ${K8S_NODE_NAME}
- action: insert
key: k8s.pod.name
value: ${K8S_POD_NAME}
- action: insert
key: k8s.pod.uid
value: ${K8S_POD_UID}
- action: insert
key: k8s.namespace.name
value: ${K8S_NAMESPACE}
resource/logs:
attributes:
- action: upsert
from_attribute: k8s.pod.annotations.splunk.com/sourcetype
key: com.splunk.sourcetype
- action: delete
key: k8s.pod.annotations.splunk.com/sourcetype
- action: delete
key: splunk.com/exclude
resourcedetection:
detectors:
- env
- system
override: true
timeout: 10s
receivers:
jaeger:
protocols:
grpc:
endpoint: 0.0.0.0:14250
thrift_http:
endpoint: 0.0.0.0:14268
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
prometheus/collector:
config:
scrape_configs:
- job_name: otel-collector
scrape_interval: 10s
static_configs:
- targets:
- ${K8S_POD_IP}:8889
signalfx:
access_token_passthrough: true
endpoint: 0.0.0.0:9943
zipkin:
endpoint: 0.0.0.0:9411
service:
extensions:
- health_check
- memory_ballast
- zpages
- http_forwarder
pipelines:
logs/signalfx-events:
exporters:
- signalfx
processors:
- memory_limiter
- batch
receivers:
- signalfx
metrics:
exporters:
- signalfx
processors:
- memory_limiter
- batch
- resource/add_cluster_name
receivers:
- otlp
- signalfx
metrics/collector:
exporters:
- signalfx
processors:
- memory_limiter
- batch
- resource/add_collector_k8s
- resourcedetection
- resource/add_cluster_name
receivers:
- prometheus/collector
traces:
exporters:
- sapm
processors:
- memory_limiter
- batch
- k8sattributes
- resource/add_cluster_name
receivers:
- otlp
- jaeger
- zipkin
telemetry:
metrics:
address: 0.0.0.0:8889
`
// the javaagent version is managed by the update-javaagent-version.sh script.
defaultJavaAgentVersion = "v1.14.1"
defaultJavaAgentImage = "quay.io/signalfx/splunk-otel-instrumentation-java:" + defaultJavaAgentVersion
Expand Down
4 changes: 2 additions & 2 deletions apis/otel/v1alpha1/splunkotelagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type AgentSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
ClusterReceiver CollectorSpec `json:"clusterReceiver,omitempty"`

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

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// AgentList contains a list of SplunkOtelAgent.
type AgentList struct {
Expand Down
119 changes: 110 additions & 9 deletions apis/otel/v1alpha1/splunkotelagent_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (r *Agent) validateCRDAgentSpec() error {
spec := r.Spec.Agent

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

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

if spec.Replicas != nil {
return fmt.Errorf("`replicas` is not supported by clusterReceiver")
return fmt.Errorf("`replicas` is not supported by the clusterReceiver")
}

if spec.HostNetwork {
return fmt.Errorf("`hostNetwork` cannot be true for clusterReceiver")
return fmt.Errorf("`hostNetwork` cannot be true for the clusterReceiver")
}

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

if r.Spec.Gateway.Enabled != nil && *r.Spec.Gateway.Enabled {
return fmt.Errorf("gateway is not supported at the moment")
}

if spec.HostNetwork {
return fmt.Errorf("`hostNetwork` cannot be true for clusterReceiver")
}
Expand Down Expand Up @@ -249,8 +245,6 @@ func (r *Agent) defaultClusterReceiver() {

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

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

if spec.Replicas == nil {
s := int32(3)
spec.Replicas = &s
}

if spec.Ports == nil {
spec.Ports = []v1.ServicePort{
{
Name: "otlp",
Protocol: "TCP",
Port: 4317,
},
{
Name: "otlp-http",
Protocol: "TCP",
Port: 4318,
},
{
Protocol: "TCP",
Port: 55681,
},
{
Name: "jaeger-thrift",
Protocol: "TCP",
Port: 14268,
},
{
Name: "jaeger-grpc",
Protocol: "TCP",
Port: 14250,
},
{
Name: "zipkin",
Protocol: "TCP",
Port: 9411,
},
{
Name: "signalfx",
Protocol: "TCP",
Port: 9943,
},
{
Name: "http-forwarder",
Protocol: "TCP",
Port: 6060,
},
}
}

if spec.Enabled == nil {
s := false
spec.Enabled = &s
}

if spec.Replicas == nil {
s := int32(3)
spec.Replicas = &s
}

if spec.Ports == nil {
spec.Ports = []v1.ServicePort{
{
Name: "otlp",
Protocol: "TCP",
Port: 4317,
},
{
Name: "otlp-http",
Protocol: "TCP",
Port: 4318,
},
{
Protocol: "TCP",
Port: 55681,
},
{
Name: "jaeger-thrift",
Protocol: "TCP",
Port: 14268,
},
{
Name: "jaeger-grpc",
Protocol: "TCP",
Port: 14250,
},
{
Name: "zipkin",
Protocol: "TCP",
Port: 9411,
},
{
Name: "signalfx",
Protocol: "TCP",
Port: 9943,
},
{
Name: "http-forwarder",
Protocol: "TCP",
Port: 6060,
},
}
}

setDefaultResources(spec, defaultGatewayCPU, defaultGatewayMemory)
setDefaultEnvVars(spec, r.Spec.Realm, r.Spec.ClusterName)

if spec.Config == "" {
spec.Config = defaultGatewayConfig
}
}

func setDefaultResources(spec *CollectorSpec, defaultCPU string,
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/otel.splunk.com_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4222,7 +4222,7 @@ spec:
x-kubernetes-list-type: atomic
type: object
gateway:
description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
description: Gateway is a Splunk OpenTelemetry Collector deployment
used to export data to Splunk APM.
properties:
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ spec:
deployment(s).
displayName: Volumes
path: clusterReceiver.volumes
- description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
used to export data to Splunk APM.
- description: Gateway is a Splunk OpenTelemetry Collector deployment used to
export data to Splunk APM.
displayName: Gateway
path: gateway
- description: Args is the set of arguments to pass to the OpenTelemetry Collector
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/otel.splunk.com_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4212,7 +4212,7 @@ spec:
x-kubernetes-list-type: atomic
type: object
gateway:
description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
description: Gateway is a Splunk OpenTelemetry Collector deployment
used to export data to Splunk APM.
properties:
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ spec:
deployment(s).
displayName: Volumes
path: clusterReceiver.volumes
- description: ClusterReceiver is a Splunk OpenTelemetry Collector deployment
used to export data to Splunk APM.
- description: Gateway is a Splunk OpenTelemetry Collector deployment used to
export data to Splunk APM.
displayName: Gateway
path: gateway
- description: Args is the set of arguments to pass to the OpenTelemetry Collector
Expand Down
Loading

0 comments on commit c05a49c

Please sign in to comment.