Skip to content

Commit 9b9dcf8

Browse files
authored
feat: Add cloud provider info to the gateways (#1778)
1 parent 2550687 commit 9b9dcf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+812
-172
lines changed

.k3d-kyma.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ registries:
1212
name: kyma
1313
hostPort: '5001'
1414

15+
options:
16+
k3s:
17+
nodeLabels:
18+
- label: topology.kubernetes.io/region=kyma-local
19+
nodeFilters:
20+
- server:*
21+
- label: topology.kubernetes.io/zone=kyma-local
22+
nodeFilters:
23+
- server:*
24+
- label: node.kubernetes.io/instance-type=local
25+
nodeFilters:
26+
- server:*

config/rbac/role.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rules:
1111
- ""
1212
resources:
1313
- secrets
14+
- configmaps
1415
verbs:
1516
- get
1617
- list

docs/contributor/assets/multi_pipeline_gateway_with_connectors.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ data:
3131
- filter/drop-if-input-source-runtime
3232
- filter/drop-if-input-source-prometheus
3333
- filter/drop-if-input-source-istio
34-
- resource/insert-cluster-name
34+
- resource/insert-cluster-attributes
3535
- batch
3636
exporters:
3737
- otlp/load-test-1
@@ -58,7 +58,7 @@ data:
5858
- filter/drop-if-input-source-runtime
5959
- filter/drop-if-input-source-prometheus
6060
- filter/drop-if-input-source-istio
61-
- resource/insert-cluster-name
61+
- resource/insert-cluster-attributes
6262
- batch
6363
exporters:
6464
- otlp/load-test-2
@@ -85,7 +85,7 @@ data:
8585
- filter/drop-if-input-source-runtime
8686
- filter/drop-if-input-source-prometheus
8787
- filter/drop-if-input-source-istio
88-
- resource/insert-cluster-name
88+
- resource/insert-cluster-attributes
8989
- batch
9090
exporters:
9191
- otlp/load-test-3
@@ -165,7 +165,7 @@ data:
165165
name: k8s.pod.uid
166166
- sources:
167167
- from: connection
168-
resource/insert-cluster-name:
168+
resource/insert-cluster-attributes:
169169
attributes:
170170
- action: insert
171171
key: k8s.cluster.name

docs/contributor/assets/single_pipeline_gateway_with_connectors.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ data:
3131
- filter/drop-if-input-source-runtime
3232
- filter/drop-if-input-source-prometheus
3333
- filter/drop-if-input-source-istio
34-
- resource/insert-cluster-name
34+
- resource/insert-cluster-attributes
3535
- batch
3636
exporters:
3737
- otlp/load-test-1
@@ -97,7 +97,7 @@ data:
9797
name: k8s.pod.uid
9898
- sources:
9999
- from: connection
100-
resource/insert-cluster-name:
100+
resource/insert-cluster-attributes:
101101
attributes:
102102
- action: insert
103103
key: k8s.cluster.name

internal/otelcollector/config/gatewayprocs/k8s_attribute_proc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,25 @@ func extractLabels() []config.ExtractLabel {
5151
Key: "app",
5252
TagName: "kyma.app_name",
5353
},
54+
{
55+
From: "node",
56+
Key: "topology.kubernetes.io/region",
57+
TagName: "cloud.region",
58+
},
59+
{
60+
From: "node",
61+
Key: "topology.kubernetes.io/zone",
62+
TagName: "cloud.availability_zone",
63+
},
64+
{
65+
From: "node",
66+
Key: "node.kubernetes.io/instance-type",
67+
TagName: "host.type",
68+
},
69+
{
70+
From: "node",
71+
Key: "kubernetes.io/arch",
72+
TagName: "host.arch",
73+
},
5474
}
5575
}

internal/otelcollector/config/gatewayprocs/k8s_attribute_proc_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ func TestK8sAttributesProcessorConfig(t *testing.T) {
4343
Key: "app",
4444
TagName: "kyma.app_name",
4545
},
46+
{
47+
From: "node",
48+
Key: "topology.kubernetes.io/region",
49+
TagName: "cloud.region",
50+
},
51+
{
52+
From: "node",
53+
Key: "topology.kubernetes.io/zone",
54+
TagName: "cloud.availability_zone",
55+
},
56+
{
57+
From: "node",
58+
Key: "node.kubernetes.io/instance-type",
59+
TagName: "host.type",
60+
},
61+
{
62+
From: "node",
63+
Key: "kubernetes.io/arch",
64+
TagName: "host.arch",
65+
},
4666
}
4767

4868
config := K8sAttributesProcessorConfig()

internal/otelcollector/config/gatewayprocs/resource_procs.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,30 @@ import (
44
"github.com/kyma-project/telemetry-manager/internal/otelcollector/config"
55
)
66

7-
func InsertClusterNameProcessorConfig() *config.ResourceProcessor {
7+
func InsertClusterAttributesProcessorConfig(clusterName, cloudProvider string) *config.ResourceProcessor {
8+
if cloudProvider != "" {
9+
return &config.ResourceProcessor{
10+
Attributes: []config.AttributeAction{
11+
{
12+
Action: "insert",
13+
Key: "k8s.cluster.name",
14+
Value: clusterName,
15+
},
16+
{
17+
Action: "insert",
18+
Key: "cloud.provider",
19+
Value: cloudProvider,
20+
},
21+
},
22+
}
23+
}
24+
825
return &config.ResourceProcessor{
926
Attributes: []config.AttributeAction{
1027
{
1128
Action: "insert",
1229
Key: "k8s.cluster.name",
13-
Value: "${KUBERNETES_SERVICE_HOST}",
30+
Value: clusterName,
1431
},
1532
},
1633
}

internal/otelcollector/config/gatewayprocs/resource_procs_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ func TestInsertClusterNameProcessorConfig(t *testing.T) {
1515
{
1616
Action: "insert",
1717
Key: "k8s.cluster.name",
18-
Value: "${KUBERNETES_SERVICE_HOST}",
18+
Value: "test-cluster",
19+
},
20+
{
21+
Action: "insert",
22+
Key: "cloud.provider",
23+
Value: "test-cloud-provider",
1924
},
2025
}
2126

22-
config := InsertClusterNameProcessorConfig()
27+
config := InsertClusterAttributesProcessorConfig("test-cluster", "test-cloud-provider")
2328

2429
require.ElementsMatch(expectedAttributeActions, config.Attributes, "Attributes should match")
2530
}

internal/otelcollector/config/log/gateway/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ type Receivers struct {
1919
type Processors struct {
2020
config.BaseProcessors `yaml:",inline"`
2121

22-
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
23-
InsertClusterName *config.ResourceProcessor `yaml:"resource/insert-cluster-name,omitempty"`
24-
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
22+
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
23+
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
24+
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
2525
}
2626

2727
type Exporters map[string]Exporter

internal/otelcollector/config/log/gateway/config_builder.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ type Builder struct {
2222
Reader client.Reader
2323
}
2424

25-
func (b *Builder) Build(ctx context.Context, pipelines []telemetryv1alpha1.LogPipeline) (*Config, otlpexporter.EnvVars, error) {
25+
type BuildOptions struct {
26+
ClusterName string
27+
CloudProvider string
28+
}
29+
30+
func (b *Builder) Build(ctx context.Context, pipelines []telemetryv1alpha1.LogPipeline, opts BuildOptions) (*Config, otlpexporter.EnvVars, error) {
2631
cfg := &Config{
2732
Base: config.Base{
2833
Service: config.DefaultService(make(config.Pipelines)),
2934
Extensions: config.DefaultExtensions(),
3035
},
3136
Receivers: makeReceiversConfig(),
32-
Processors: makeProcessorsConfig(),
37+
Processors: makeProcessorsConfig(opts),
3338
Exporters: make(Exporters),
3439
}
3540

@@ -99,7 +104,7 @@ func makePipelineConfig(exporterIDs ...string) config.Pipeline {
99104
Processors: []string{
100105
"memory_limiter",
101106
"k8sattributes",
102-
"resource/insert-cluster-name",
107+
"resource/insert-cluster-attributes",
103108
"batch",
104109
},
105110
Exporters: exporterIDs,

0 commit comments

Comments
 (0)