Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add cloud provider info to the gateways #1778

Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
92bb30e
add cloud provider attributes to the gateways, initial commit
hisarbalik Jan 21, 2025
32651c0
add get gardener shoot-info getter
hisarbalik Jan 22, 2025
1f4476d
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 22, 2025
50d6ae3
update unit tests with cluster info attributes
hisarbalik Jan 22, 2025
25f8e83
update RBAC rules
hisarbalik Jan 22, 2025
9c274dd
fix wrong pipeline service configuation
hisarbalik Jan 22, 2025
7983e62
fix wrong pipeline service configuation tests
hisarbalik Jan 22, 2025
849d134
add configmap shhot-info from namespace kube-system to the cache
hisarbalik Jan 22, 2025
62da594
re-generate sec-scan-config.yaml
hisarbalik Jan 22, 2025
66f9394
adjust cluster roles for OTel based gateways
hisarbalik Jan 22, 2025
2863e47
fix otel gateway unit tests
hisarbalik Jan 22, 2025
469115e
revert doc changes
hisarbalik Jan 22, 2025
84d7847
update cache config
hisarbalik Jan 22, 2025
4148ecb
update cache settings
hisarbalik Jan 22, 2025
f7f1ed7
update rbac rules
hisarbalik Jan 22, 2025
6bb0968
add unit test for cluster info getter
hisarbalik Jan 23, 2025
edeb602
refactor the cluster info getter
hisarbalik Jan 23, 2025
3792f30
fix linter issues
hisarbalik Jan 23, 2025
30b5e40
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 23, 2025
8e7ae43
add host.arch and host.type attrbiutes to the k8sattribute processor
hisarbalik Jan 24, 2025
6b28648
Merge branch 'add-metricpipeline-cloud-provider-attributes' of github…
hisarbalik Jan 24, 2025
e8fcc03
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 24, 2025
388ba5e
fix failing e2e tests
hisarbalik Jan 27, 2025
455ee73
add cloud provider attribute tests
hisarbalik Jan 27, 2025
d743a30
move node lables config tot he k2d config file
hisarbalik Jan 27, 2025
86b8aaa
add gardener shoot-info e2e test
hisarbalik Jan 27, 2025
c90e932
update k3d config
hisarbalik Jan 27, 2025
f1bbc9c
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 27, 2025
cdeb3e2
add more e2e test
hisarbalik Jan 27, 2025
1a44b54
Merge branch 'add-metricpipeline-cloud-provider-attributes' of github…
hisarbalik Jan 27, 2025
7cbb3fe
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 28, 2025
8db82f6
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 28, 2025
8d356cd
add gardener and k3d integration test
hisarbalik Jan 28, 2025
55bf232
Merge branch 'add-metricpipeline-cloud-provider-attributes' of github…
hisarbalik Jan 28, 2025
28478dc
remove unused code
hisarbalik Jan 28, 2025
11a2db1
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 28, 2025
5f47dd8
rename coud provider attribute test file
hisarbalik Jan 28, 2025
5f5be1b
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 30, 2025
51b0857
add SAP Converged Cloud as cloud provider
hisarbalik Jan 30, 2025
d2be1a3
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Jan 30, 2025
1fc8353
move cache config for configmaps to a dedicated function
hisarbalik Jan 31, 2025
aa71eb5
Merge branch 'main' into add-metricpipeline-cloud-provider-attributes
hisarbalik Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .k3d-kyma.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ registries:
name: kyma
hostPort: '5001'

options:
k3s:
nodeLabels:
- label: topology.kubernetes.io/region=kyma-local
nodeFilters:
- server:*
- label: topology.kubernetes.io/zone=kyma-local
hisarbalik marked this conversation as resolved.
Show resolved Hide resolved
nodeFilters:
- server:*
- label: node.kubernetes.io/instance-type=local
nodeFilters:
- server:*
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rules:
- ""
resources:
- secrets
- configmaps
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data:
- filter/drop-if-input-source-runtime
- filter/drop-if-input-source-prometheus
- filter/drop-if-input-source-istio
- resource/insert-cluster-name
- resource/insert-cluster-attributes
- batch
exporters:
- otlp/load-test-1
Expand All @@ -58,7 +58,7 @@ data:
- filter/drop-if-input-source-runtime
- filter/drop-if-input-source-prometheus
- filter/drop-if-input-source-istio
- resource/insert-cluster-name
- resource/insert-cluster-attributes
- batch
exporters:
- otlp/load-test-2
Expand All @@ -85,7 +85,7 @@ data:
- filter/drop-if-input-source-runtime
- filter/drop-if-input-source-prometheus
- filter/drop-if-input-source-istio
- resource/insert-cluster-name
- resource/insert-cluster-attributes
- batch
exporters:
- otlp/load-test-3
Expand Down Expand Up @@ -165,7 +165,7 @@ data:
name: k8s.pod.uid
- sources:
- from: connection
resource/insert-cluster-name:
resource/insert-cluster-attributes:
attributes:
- action: insert
key: k8s.cluster.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data:
- filter/drop-if-input-source-runtime
- filter/drop-if-input-source-prometheus
- filter/drop-if-input-source-istio
- resource/insert-cluster-name
- resource/insert-cluster-attributes
- batch
exporters:
- otlp/load-test-1
Expand Down Expand Up @@ -97,7 +97,7 @@ data:
name: k8s.pod.uid
- sources:
- from: connection
resource/insert-cluster-name:
resource/insert-cluster-attributes:
attributes:
- action: insert
key: k8s.cluster.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,25 @@ func extractLabels() []config.ExtractLabel {
Key: "app",
TagName: "kyma.app_name",
},
{
From: "node",
hisarbalik marked this conversation as resolved.
Show resolved Hide resolved
Key: "topology.kubernetes.io/region",
TagName: "cloud.region",
},
{
From: "node",
Key: "topology.kubernetes.io/zone",
TagName: "cloud.availability_zone",
},
{
From: "node",
Key: "node.kubernetes.io/instance-type",
TagName: "host.type",
},
{
From: "node",
Key: "kubernetes.io/arch",
TagName: "host.arch",
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ func TestK8sAttributesProcessorConfig(t *testing.T) {
Key: "app",
TagName: "kyma.app_name",
},
{
From: "node",
Key: "topology.kubernetes.io/region",
TagName: "cloud.region",
},
{
From: "node",
Key: "topology.kubernetes.io/zone",
TagName: "cloud.availability_zone",
},
{
From: "node",
Key: "node.kubernetes.io/instance-type",
TagName: "host.type",
},
{
From: "node",
Key: "kubernetes.io/arch",
TagName: "host.arch",
},
}

config := K8sAttributesProcessorConfig()
Expand Down
21 changes: 19 additions & 2 deletions internal/otelcollector/config/gatewayprocs/resource_procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@ import (
"github.com/kyma-project/telemetry-manager/internal/otelcollector/config"
)

func InsertClusterNameProcessorConfig() *config.ResourceProcessor {
func InsertClusterAttributesProcessorConfig(clusterName, cloudProvider string) *config.ResourceProcessor {
if cloudProvider != "" {
return &config.ResourceProcessor{
Attributes: []config.AttributeAction{
{
Action: "insert",
Key: "k8s.cluster.name",
Value: clusterName,
},
{
Action: "insert",
Key: "cloud.provider",
Value: cloudProvider,
},
},
}
}

return &config.ResourceProcessor{
Attributes: []config.AttributeAction{
{
Action: "insert",
Key: "k8s.cluster.name",
Value: "${KUBERNETES_SERVICE_HOST}",
Value: clusterName,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ func TestInsertClusterNameProcessorConfig(t *testing.T) {
{
Action: "insert",
Key: "k8s.cluster.name",
Value: "${KUBERNETES_SERVICE_HOST}",
Value: "test-cluster",
},
{
Action: "insert",
Key: "cloud.provider",
Value: "test-cloud-provider",
},
}

config := InsertClusterNameProcessorConfig()
config := InsertClusterAttributesProcessorConfig("test-cluster", "test-cloud-provider")

require.ElementsMatch(expectedAttributeActions, config.Attributes, "Attributes should match")
}
Expand Down
6 changes: 3 additions & 3 deletions internal/otelcollector/config/log/gateway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type Receivers struct {
type Processors struct {
config.BaseProcessors `yaml:",inline"`

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

type Exporters map[string]Exporter
Expand Down
11 changes: 8 additions & 3 deletions internal/otelcollector/config/log/gateway/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ type Builder struct {
Reader client.Reader
}

func (b *Builder) Build(ctx context.Context, pipelines []telemetryv1alpha1.LogPipeline) (*Config, otlpexporter.EnvVars, error) {
type BuildOptions struct {
ClusterName string
CloudProvider string
}

func (b *Builder) Build(ctx context.Context, pipelines []telemetryv1alpha1.LogPipeline, opts BuildOptions) (*Config, otlpexporter.EnvVars, error) {
cfg := &Config{
Base: config.Base{
Service: config.DefaultService(make(config.Pipelines)),
Extensions: config.DefaultExtensions(),
},
Receivers: makeReceiversConfig(),
Processors: makeProcessorsConfig(),
Processors: makeProcessorsConfig(opts),
Exporters: make(Exporters),
}

Expand Down Expand Up @@ -99,7 +104,7 @@ func makePipelineConfig(exporterIDs ...string) config.Pipeline {
Processors: []string{
"memory_limiter",
"k8sattributes",
"resource/insert-cluster-name",
"resource/insert-cluster-attributes",
"batch",
},
Exporters: exporterIDs,
Expand Down
Loading
Loading