Skip to content

Commit 8ec0229

Browse files
authored
Set fullnameOverride and validate Otel kube-stack deployment datastreams are being written (metrics, traces) (#7754)
1 parent 5883bb0 commit 8ec0229

File tree

6 files changed

+166
-146
lines changed

6 files changed

+166
-146
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: feature
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: set collectors fullnameOverride for edot kube-stack values
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
22+
component: elastic-agent
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: https://github.com/elastic/elastic-agent/pull/7754
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
issue: https://github.com/elastic/elastic-agent/issues/7381

deploy/helm/edot-collector/kube-stack/managed_otlp/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ collectors:
3333
# Cluster is a K8s deployment EDOT collector focused on gathering telemetry
3434
# at the cluster level (Kubernetes Events and cluster metrics).
3535
cluster:
36+
fullnameOverride: "opentelemetry-kube-stack-cluster-stats"
3637
env:
3738
- name: ELASTIC_AGENT_OTEL
3839
value: '"true"'
@@ -184,6 +185,7 @@ collectors:
184185
# node level and exposing an OTLP endpoint for data ingestion.
185186
# Auto-instrumentation SDKs will use this endpoint.
186187
daemon:
188+
fullnameOverride: "opentelemetry-kube-stack-daemon"
187189
env:
188190
# Work around for open /mounts error: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35990
189191
- name: HOST_PROC_MOUNTINFO
@@ -526,6 +528,7 @@ collectors:
526528
# Gateway is a K8s deployment EDOT collector focused on processing and
527529
# forwarding telemetry to an Elasticsearch endpoint.
528530
gateway:
531+
fullnameOverride: "opentelemetry-kube-stack-gateway"
529532
suffix: gateway
530533
replicas: 2
531534
autoscaler:

deploy/helm/edot-collector/kube-stack/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ collectors:
3333
# Cluster is a K8s deployment EDOT collector focused on gathering telemetry
3434
# at the cluster level (Kubernetes Events and cluster metrics).
3535
cluster:
36+
fullnameOverride: "opentelemetry-kube-stack-cluster-stats"
3637
env:
3738
- name: ELASTIC_AGENT_OTEL
3839
value: '"true"'
@@ -184,6 +185,7 @@ collectors:
184185
# node level and exposing an OTLP endpoint for data ingestion.
185186
# Auto-instrumentation SDKs will use this endpoint.
186187
daemon:
188+
fullnameOverride: "opentelemetry-kube-stack-daemon"
187189
env:
188190
# Work around for open /mounts error: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35990
189191
- name: HOST_PROC_MOUNTINFO
@@ -526,6 +528,7 @@ collectors:
526528
# Gateway is a K8s deployment EDOT collector focused on processing and
527529
# forwarding telemetry to an Elasticsearch endpoint.
528530
gateway:
531+
fullnameOverride: "opentelemetry-kube-stack-gateway"
529532
resources:
530533
limits:
531534
cpu: 1500m

testing/integration/kubernetes_agent_standalone_test.go

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/stretchr/testify/require"
3030

3131
"github.com/elastic/elastic-agent-libs/kibana"
32+
"github.com/elastic/elastic-agent-libs/testing/estools"
3233
"github.com/elastic/go-elasticsearch/v8"
3334

3435
appsv1 "k8s.io/api/apps/v1"
@@ -864,7 +865,8 @@ func k8sCheckAgentStatus(ctx context.Context, client klient.Client, stdout *byte
864865

865866
// k8sGetAgentID returns the agent ID for the given agent pod
866867
func k8sGetAgentID(ctx context.Context, client klient.Client, stdout *bytes.Buffer, stderr *bytes.Buffer,
867-
namespace string, agentPodName string, containerName string) (string, error) {
868+
namespace string, agentPodName string, containerName string,
869+
) (string, error) {
868870
command := []string{"elastic-agent", "status", "--output=json"}
869871

870872
status := atesting.AgentStatusOutput{} // clear status output
@@ -997,7 +999,7 @@ func k8sDumpPods(t *testing.T, ctx context.Context, client klient.Client, testNa
997999
header := &tar.Header{
9981000
Name: logFileName,
9991001
Size: int64(len(b)),
1000-
Mode: 0600,
1002+
Mode: 0o600,
10011003
ModTime: time.Now(),
10021004
AccessTime: time.Now(),
10031005
ChangeTime: time.Now(),
@@ -1024,7 +1026,7 @@ func k8sDumpPods(t *testing.T, ctx context.Context, client klient.Client, testNa
10241026
header := &tar.Header{
10251027
Name: statesDumpFile,
10261028
Size: int64(len(b)),
1027-
Mode: 0600,
1029+
Mode: 0o600,
10281030
ModTime: time.Now(),
10291031
AccessTime: time.Now(),
10301032
ChangeTime: time.Now(),
@@ -1102,35 +1104,8 @@ func k8sRenderKustomize(kustomizePath string) ([]byte, error) {
11021104
}
11031105

11041106
// generateESAPIKey generates an API key for the given Elasticsearch.
1105-
func generateESAPIKey(esClient *elasticsearch.Client, keyName string) (string, error) {
1106-
apiKeyReqBody := fmt.Sprintf(`{
1107-
"name": "%s",
1108-
"expiration": "1d"
1109-
}`, keyName)
1110-
1111-
resp, err := esClient.Security.CreateAPIKey(strings.NewReader(apiKeyReqBody))
1112-
if err != nil {
1113-
return "", err
1114-
}
1115-
defer resp.Body.Close()
1116-
1117-
response := make(map[string]interface{})
1118-
err = json.NewDecoder(resp.Body).Decode(&response)
1119-
if err != nil {
1120-
return "", err
1121-
}
1122-
1123-
keyToken := response["api_key"].(string)
1124-
if keyToken == "" {
1125-
return "", fmt.Errorf("key token is empty")
1126-
}
1127-
1128-
keyID := response["id"].(string)
1129-
if keyID == "" {
1130-
return "", fmt.Errorf("key ID is empty")
1131-
}
1132-
1133-
return fmt.Sprintf("%s:%s", keyID, keyToken), nil
1107+
func generateESAPIKey(esClient *elasticsearch.Client, keyName string) (estools.APIKeyResponse, error) {
1108+
return estools.CreateAPIKey(context.Background(), esClient, estools.APIKeyRequest{Name: keyName, Expiration: "1d"})
11341109
}
11351110

11361111
// k8sDeleteOpts contains options for deleting k8s objects
@@ -1330,6 +1305,8 @@ type k8sContext struct {
13301305
esHost string
13311306
// esAPIKey is the API key of the elasticsearch to use in the test
13321307
esAPIKey string
1308+
// esEncodedAPIKey is the encoded API key of the elasticsearch to use in the test
1309+
esEncodedAPIKey string
13331310
// enrollParams contains the information needed to enroll an agent with Fleet in the test
13341311
enrollParams *fleettools.EnrollParams
13351312
// createdAt is the time when the k8sContext was created
@@ -1415,16 +1392,17 @@ func k8sGetContext(t *testing.T, info *define.Info) k8sContext {
14151392
require.NoError(t, err, "failed to create fleet enroll params")
14161393

14171394
return k8sContext{
1418-
client: client,
1419-
clientSet: clientSet,
1420-
agentImage: agentImage,
1421-
agentImageRepo: agentImageRepo,
1422-
agentImageTag: agentImageTag,
1423-
logsBasePath: testLogsBasePath,
1424-
esHost: esHost,
1425-
esAPIKey: esAPIKey,
1426-
enrollParams: enrollParams,
1427-
createdAt: time.Now(),
1395+
client: client,
1396+
clientSet: clientSet,
1397+
agentImage: agentImage,
1398+
agentImageRepo: agentImageRepo,
1399+
agentImageTag: agentImageTag,
1400+
logsBasePath: testLogsBasePath,
1401+
esHost: esHost,
1402+
esAPIKey: esAPIKey.APIKey,
1403+
esEncodedAPIKey: esAPIKey.Encoded,
1404+
enrollParams: enrollParams,
1405+
createdAt: time.Now(),
14281406
}
14291407
}
14301408

0 commit comments

Comments
 (0)