generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce labels in agent and gateways for usage in NetworkPoli…
…cy (#1557) Co-authored-by: Stanislav Khalash <[email protected]> Co-authored-by: Nina Hingerl <[email protected]>
- Loading branch information
1 parent
33a8adc
commit 418610b
Showing
14 changed files
with
231 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package labels | ||
|
||
const ( | ||
selectorLabelKey = "app.kubernetes.io/name" | ||
traceGatewayIngestSelector = "telemetry.kyma-project.io/trace-ingest" | ||
traceGatewayExportSelector = "telemetry.kyma-project.io/trace-export" | ||
metricAgentScrapeSelector = "telemetry.kyma-project.io/metric-scrape" | ||
metricGatewayIngestSelector = "telemetry.kyma-project.io/metric-ingest" | ||
metricGatewayExportSelector = "telemetry.kyma-project.io/metric-export" | ||
istioSidecarInjectLabel = "sidecar.istio.io/inject" | ||
) | ||
|
||
func MakeDefaultLabel(baseName string) map[string]string { | ||
return map[string]string{ | ||
selectorLabelKey: baseName, | ||
} | ||
} | ||
|
||
func MakeMetricAgentSelectorLabel(baseName string) map[string]string { | ||
return map[string]string{ | ||
selectorLabelKey: baseName, | ||
metricAgentScrapeSelector: "true", | ||
istioSidecarInjectLabel: "true", | ||
} | ||
} | ||
|
||
func MakeMetricGatewaySelectorLabel(baseName string) map[string]string { | ||
return map[string]string{ | ||
selectorLabelKey: baseName, | ||
metricGatewayIngestSelector: "true", | ||
metricGatewayExportSelector: "true", | ||
istioSidecarInjectLabel: "true", | ||
} | ||
} | ||
|
||
func MakeTraceGatewaySelectorLabel(baseName string) map[string]string { | ||
return map[string]string{ | ||
selectorLabelKey: baseName, | ||
traceGatewayIngestSelector: "true", | ||
traceGatewayExportSelector: "true", | ||
istioSidecarInjectLabel: "true", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package labels | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMakeDefaultLabel(t *testing.T) { | ||
podLabel := MakeDefaultLabel("my-pod") | ||
require.Equal(t, map[string]string{ | ||
"app.kubernetes.io/name": "my-pod", | ||
}, podLabel) | ||
} | ||
|
||
func TestMakeMetricAgentSelectorLabel(t *testing.T) { | ||
metricAgentSelectorLabel := MakeMetricAgentSelectorLabel("metric-agent") | ||
require.Equal(t, map[string]string{ | ||
"app.kubernetes.io/name": "metric-agent", | ||
"telemetry.kyma-project.io/metric-scrape": "true", | ||
"sidecar.istio.io/inject": "true", | ||
}, metricAgentSelectorLabel) | ||
} | ||
|
||
func TestMakeMetricGatewaySelectorLabel(t *testing.T) { | ||
metricGatewaySelectorLabel := MakeMetricGatewaySelectorLabel("metric-gateway") | ||
require.Equal(t, map[string]string{ | ||
"app.kubernetes.io/name": "metric-gateway", | ||
"telemetry.kyma-project.io/metric-ingest": "true", | ||
"telemetry.kyma-project.io/metric-export": "true", | ||
"sidecar.istio.io/inject": "true", | ||
}, metricGatewaySelectorLabel) | ||
} | ||
func TestMakeTraceGatewaySelectorLabel(t *testing.T) { | ||
traceGatewaySelectorLabel := MakeTraceGatewaySelectorLabel("trace-gateway") | ||
require.Equal(t, map[string]string{ | ||
"app.kubernetes.io/name": "trace-gateway", | ||
"telemetry.kyma-project.io/trace-ingest": "true", | ||
"telemetry.kyma-project.io/trace-export": "true", | ||
"sidecar.istio.io/inject": "true", | ||
}, traceGatewaySelectorLabel) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.