From 9d2c3c92069894db0bbea34a7c5ca66f4b632377 Mon Sep 17 00:00:00 2001 From: Panos Koutsovasilis Date: Mon, 4 Nov 2024 22:30:46 +0200 Subject: [PATCH] [helm]: forward agent providers configuration for fleet mode (#5912) * feat: forward agent providers configuration for fleet mode * feat: add fleet example --- .../examples/fleet-managed/README.md | 68 +++++ .../examples/fleet-managed/fleet-values.yaml | 39 +++ .../fleet-managed/rendered/manifest.yaml | 233 ++++++++++++++++++ .../kubernetes-default/rendered/manifest.yaml | 40 +-- .../rendered/manifest.yaml | 44 ++-- .../rendered/manifest.yaml | 14 +- .../rendered/manifest.yaml | 44 ++-- .../rendered/manifest.yaml | 8 +- .../rendered/manifest.yaml | 14 +- .../templates/agent/k8s/_pod_template.yaml | 6 - .../templates/agent/k8s/_secret.tpl | 15 +- .../templates/agent/k8s/secret.yaml | 2 - 12 files changed, 432 insertions(+), 95 deletions(-) create mode 100644 deploy/helm/elastic-agent/examples/fleet-managed/README.md create mode 100644 deploy/helm/elastic-agent/examples/fleet-managed/fleet-values.yaml create mode 100644 deploy/helm/elastic-agent/examples/fleet-managed/rendered/manifest.yaml diff --git a/deploy/helm/elastic-agent/examples/fleet-managed/README.md b/deploy/helm/elastic-agent/examples/fleet-managed/README.md new file mode 100644 index 00000000000..abcc0f12f86 --- /dev/null +++ b/deploy/helm/elastic-agent/examples/fleet-managed/README.md @@ -0,0 +1,68 @@ +# Example: Managed by Fleet Elastic Agent + +In this example we deploy an Elastic Agent that is managed by [Fleet](https://www.elastic.co/guide/en/fleet/current/manage-agents-in-fleet.html). + +## Prerequisites: +1. Follow [this guide](https://www.elastic.co/guide/en/fleet/current/install-fleet-managed-elastic-agent.html#elastic-agent-installation-steps) to set up an agent policy and enroll an agent to it. Do not download any binary, from the proposed enrollment command just extract the Fleet URL (`--url=$FLEET_URL`) and Enrollment token (`--enrollment-token=$FLEET_TOKEN`). + +## Run: + +```console +helm install elastic-agent ../../ \ + --set agent.fleet.enabled=true \ + --set agent.fleet.url=$FLEET_URL \ + --set agent.fleet.token=$FLEET_TOKEN \ + --set agent.fleet.preset=perNode + -n kube-system +``` + +## Validate: + +1. [Optional] Install kube-state metrics if you want to see the KSM related metrics `kubectl apply -k https://github.com/kubernetes/kube-state-metrics`. +2. Install Kubernetes integration to the agent policy that you created in Fleet. If you didn't install kube-state metrics from above, make sure to disable them in the integration. +3. The Kibana `kubernetes`-related dashboards should start showing the respective info. + +## Note: + +In this example we deploy an Elastic Agent that is managed by Fleet using the built-in `perNode` preset (`DaemonSet`) targeting kubernetes monitoring. However, a user-defined agent `preset`, for different use cases, can be used as well, e.g. by using the following configuration: +```yaml +agent: + fleet: + enabled: true + url: $FLEET_URL # replace with Fleet URL + token: $FLEET_TOKEN # replace with Fleet Enrollment token + preset: nginx + presets: + nginx: + mode: deployment + securityContext: + runAsUser: 0 + rules: + # minimum cluster role ruleset required by agent + - apiGroups: [ "" ] + resources: + - nodes + - namespaces + - pods + verbs: + - get + - watch + - list + - apiGroups: [ "apps" ] + resources: + - replicasets + verbs: + - get + - list + - watch + - apiGroups: [ "batch" ] + resources: + - jobs + verbs: + - get + - list + - watch + providers: + kubernetes_leaderelection: + enabled: false +``` diff --git a/deploy/helm/elastic-agent/examples/fleet-managed/fleet-values.yaml b/deploy/helm/elastic-agent/examples/fleet-managed/fleet-values.yaml new file mode 100644 index 00000000000..704efe84cb8 --- /dev/null +++ b/deploy/helm/elastic-agent/examples/fleet-managed/fleet-values.yaml @@ -0,0 +1,39 @@ +agent: + fleet: + enabled: true + url: http://localhost:8220 + token: fleetToken + preset: nginx + presets: + nginx: + mode: deployment + securityContext: + runAsUser: 0 + rules: + # minimum cluster role ruleset required by agent + - apiGroups: [ "" ] + resources: + - nodes + - namespaces + - pods + verbs: + - get + - watch + - list + - apiGroups: [ "apps" ] + resources: + - replicasets + verbs: + - get + - list + - watch + - apiGroups: [ "batch" ] + resources: + - jobs + verbs: + - get + - list + - watch + providers: + kubernetes_leaderelection: + enabled: false diff --git a/deploy/helm/elastic-agent/examples/fleet-managed/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/fleet-managed/rendered/manifest.yaml new file mode 100644 index 00000000000..688dd97906b --- /dev/null +++ b/deploy/helm/elastic-agent/examples/fleet-managed/rendered/manifest.yaml @@ -0,0 +1,233 @@ +--- +# Source: elastic-agent/templates/agent/service-account.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: agent-nginx-example + namespace: "default" + labels: + helm.sh/chart: elastic-agent-0.0.1 + app.kubernetes.io/name: elastic-agent + app.kubernetes.io/instance: example + app.kubernetes.io/version: 9.0.0 + app.kubernetes.io/managed-by: Helm +--- +# Source: elastic-agent/templates/agent/k8s/secret.yaml +apiVersion: v1 +kind: Secret +metadata: + name: agent-nginx-example + namespace: "default" + labels: + helm.sh/chart: elastic-agent-0.0.1 + app.kubernetes.io/name: elastic-agent + app.kubernetes.io/instance: example + app.kubernetes.io/version: 9.0.0 + app.kubernetes.io/managed-by: Helm +stringData: + + agent.yml: |- + fleet: + enabled: true + providers: + kubernetes_leaderelection: + enabled: false +--- +# Source: elastic-agent/templates/agent/cluster-role.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: agent-nginx-example-default + labels: + helm.sh/chart: elastic-agent-0.0.1 + app.kubernetes.io/name: elastic-agent + app.kubernetes.io/instance: example + app.kubernetes.io/version: 9.0.0 + app.kubernetes.io/managed-by: Helm +rules: + - apiGroups: [ "" ] # "" indicates the core API group + resources: + - nodes + - namespaces + - events + - pods + - services + - configmaps + - persistentvolumes + - persistentvolumeclaims + - persistentvolumeclaims/status + - nodes/metrics + - nodes/proxy + - nodes/stats + verbs: + - get + - watch + - list + - apiGroups: + - storage.k8s.io + resources: + - storageclasses + verbs: + - get + - watch + - list + - nonResourceURLs: + - /metrics + verbs: + - get + - watch + - list + - apiGroups: [ "coordination.k8s.io" ] + resources: + - leases + verbs: + - get + - create + - update + - nonResourceURLs: + - /healthz + - /healthz/* + - /livez + - /livez/* + - /metrics + - /metrics/slis + - /readyz + - /readyz/* + verbs: + - get + - apiGroups: [ "apps" ] + resources: + - replicasets + - deployments + - daemonsets + - statefulsets + verbs: + - get + - list + - watch + - apiGroups: [ "batch" ] + resources: + - jobs + - cronjobs + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - nodes + - namespaces + - pods + verbs: + - get + - watch + - list + - apiGroups: + - apps + resources: + - replicasets + verbs: + - get + - list + - watch + - apiGroups: + - batch + resources: + - jobs + verbs: + - get + - list + - watch +--- +# Source: elastic-agent/templates/agent/cluster-role-binding.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: agent-nginx-example-default + labels: + helm.sh/chart: elastic-agent-0.0.1 + app.kubernetes.io/name: elastic-agent + app.kubernetes.io/instance: example + app.kubernetes.io/version: 9.0.0 + app.kubernetes.io/managed-by: Helm +subjects: + - kind: ServiceAccount + name: agent-nginx-example + namespace: "default" +roleRef: + kind: ClusterRole + name: agent-nginx-example-default + apiGroup: rbac.authorization.k8s.io +--- +# Source: elastic-agent/templates/agent/k8s/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: agent-nginx-example + namespace: "default" + labels: + helm.sh/chart: elastic-agent-0.0.1 + app.kubernetes.io/name: elastic-agent + app.kubernetes.io/instance: example + app.kubernetes.io/version: 9.0.0 + app.kubernetes.io/managed-by: Helm +spec: + selector: + matchLabels: + name: agent-nginx-example + template: + metadata: + labels: + name: agent-nginx-example + annotations: + checksum/config: ce25762427c9b6e207de5327b69be314f9d077db8138b7b241fd40f7b8a80aca + spec: + automountServiceAccountToken: true + containers: + - args: + - -c + - /etc/elastic-agent/agent.yml + - -e + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: STATE_PATH + value: /usr/share/elastic-agent/state + - name: FLEET_URL + value: http://localhost:8220 + - name: FLEET_ENROLLMENT_TOKEN + value: fleetToken + - name: FLEET_INSECURE + value: "false" + - name: FLEET_ENROLL + value: "1" + image: docker.elastic.co/beats/elastic-agent:9.0.0-SNAPSHOT + imagePullPolicy: IfNotPresent + name: agent + securityContext: + runAsUser: 0 + volumeMounts: + - mountPath: /usr/share/elastic-agent/state + name: agent-data + - mountPath: /etc/elastic-agent/agent.yml + name: config + readOnly: true + subPath: agent.yml + dnsPolicy: ClusterFirstWithHostNet + serviceAccountName: agent-nginx-example + volumes: + - hostPath: + path: /etc/elastic-agent/default/agent-nginx-example-managed/state + type: DirectoryOrCreate + name: agent-data + - name: config + secret: + defaultMode: 292 + secretName: agent-nginx-example diff --git a/deploy/helm/elastic-agent/examples/kubernetes-default/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/kubernetes-default/rendered/manifest.yaml index a6614406723..1406c3512ba 100644 --- a/deploy/helm/elastic-agent/examples/kubernetes-default/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/kubernetes-default/rendered/manifest.yaml @@ -69,12 +69,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: cluster - kubernetes_leaderelection: - enabled: true inputs: - data_stream: namespace: default @@ -94,6 +88,12 @@ stringData: - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt type: kubernetes/metrics use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: cluster + kubernetes_leaderelection: + enabled: true --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -126,11 +126,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - enabled: false - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -388,6 +383,11 @@ stringData: period: 10s type: kubernetes/metrics use_output: default + providers: + kubernetes: + enabled: false + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -420,12 +420,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: node - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -571,6 +565,12 @@ stringData: ssl.verification_mode: none type: kubernetes/metrics use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: node + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -1089,7 +1089,7 @@ spec: labels: name: agent-pernode-example annotations: - checksum/config: 53aa4ccc3e8557125fecf738e70722e2aaa1199ee79a823f684a9d4a296af7b0 + checksum/config: d361521be4fd034ea920a15f80ef519e05c00d801973175e3f165ea714931b52 spec: automountServiceAccountToken: true containers: @@ -1209,7 +1209,7 @@ spec: labels: name: agent-clusterwide-example annotations: - checksum/config: 73527b0aad319ef33239ef3c862820c5ee5cafb42e2ce164049646791b69ec68 + checksum/config: 14177955837470abb34597058889ea1f1d34ded25b5271b0dbbfb0bc8f3161c9 spec: automountServiceAccountToken: true containers: @@ -1291,7 +1291,7 @@ spec: labels: name: agent-ksmsharded-example annotations: - checksum/config: 4ec2b2ef4d3c5c103e79e47a45d4b3b4f9f774e85293f9a5b2d56556025f1d2d + checksum/config: 58c52f37c9e2582e270e0c3b5c0150252db79a8a1be4e9b287da943a7c9e3bdf spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml index 372ae13feb5..bdebe554edf 100644 --- a/deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml @@ -69,12 +69,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: cluster - kubernetes_leaderelection: - enabled: true inputs: - data_stream: namespace: default @@ -94,6 +88,12 @@ stringData: - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt type: kubernetes/metrics use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: cluster + kubernetes_leaderelection: + enabled: true --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -126,11 +126,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - enabled: false - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -388,6 +383,11 @@ stringData: period: 10s type: kubernetes/metrics use_output: default + providers: + kubernetes: + enabled: false + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -420,14 +420,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - hints: - enabled: true - node: ${NODE_NAME} - scope: node - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -573,6 +565,14 @@ stringData: ssl.verification_mode: none type: kubernetes/metrics use_output: default + providers: + kubernetes: + hints: + enabled: true + node: ${NODE_NAME} + scope: node + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -1091,7 +1091,7 @@ spec: labels: name: agent-pernode-example annotations: - checksum/config: 21fb7e317577410096de8d8e0fb03b32ad2e406b549f75085ae6907d38678e46 + checksum/config: c9823ca6e0ab0a28164ee0111de74d3225480f5c5e81057159d3276ad3208f46 spec: automountServiceAccountToken: true containers: @@ -1236,7 +1236,7 @@ spec: labels: name: agent-clusterwide-example annotations: - checksum/config: 73527b0aad319ef33239ef3c862820c5ee5cafb42e2ce164049646791b69ec68 + checksum/config: 14177955837470abb34597058889ea1f1d34ded25b5271b0dbbfb0bc8f3161c9 spec: automountServiceAccountToken: true containers: @@ -1318,7 +1318,7 @@ spec: labels: name: agent-ksmsharded-example annotations: - checksum/config: 4ec2b2ef4d3c5c103e79e47a45d4b3b4f9f774e85293f9a5b2d56556025f1d2d + checksum/config: 58c52f37c9e2582e270e0c3b5c0150252db79a8a1be4e9b287da943a7c9e3bdf spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/examples/kubernetes-only-logs/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/kubernetes-only-logs/rendered/manifest.yaml index e1059a75e73..4edbe32ea59 100644 --- a/deploy/helm/elastic-agent/examples/kubernetes-only-logs/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/kubernetes-only-logs/rendered/manifest.yaml @@ -43,12 +43,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: node - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -104,6 +98,12 @@ stringData: prospector.scanner.symlinks: true type: filestream use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: node + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -227,7 +227,7 @@ spec: labels: name: agent-pernode-example annotations: - checksum/config: 4de2216224a483ae1355aeec668894f764edc48bd3481d8fbc65f67eedc1b336 + checksum/config: 10cb3f4c3996f9ccaee8461e274a694fbbb03df6437e46d293cc515296b00cc0 spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml index 3daea68d21a..1358245dc7e 100644 --- a/deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml @@ -69,12 +69,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: cluster - kubernetes_leaderelection: - enabled: true inputs: - data_stream: namespace: default @@ -120,6 +114,12 @@ stringData: - nginx-stubstatus type: nginx/metrics use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: cluster + kubernetes_leaderelection: + enabled: true --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -152,11 +152,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - enabled: false - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -414,6 +409,11 @@ stringData: period: 10s type: kubernetes/metrics use_output: default + providers: + kubernetes: + enabled: false + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/k8s/secret.yaml apiVersion: v1 @@ -446,14 +446,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - hints: - enabled: true - node: ${NODE_NAME} - scope: node - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -599,6 +591,14 @@ stringData: ssl.verification_mode: none type: kubernetes/metrics use_output: default + providers: + kubernetes: + hints: + enabled: true + node: ${NODE_NAME} + scope: node + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -1117,7 +1117,7 @@ spec: labels: name: agent-pernode-example annotations: - checksum/config: 21fb7e317577410096de8d8e0fb03b32ad2e406b549f75085ae6907d38678e46 + checksum/config: c9823ca6e0ab0a28164ee0111de74d3225480f5c5e81057159d3276ad3208f46 spec: automountServiceAccountToken: true containers: @@ -1252,7 +1252,7 @@ spec: labels: name: agent-clusterwide-example annotations: - checksum/config: b04d7965af8739293cd90e352c59d1240473f56febd9aded16ba766d77f90b5f + checksum/config: 7cd88cef1c964a3660d069d4525c2efc0eed06607e0011c2af83a37648fcaacc spec: automountServiceAccountToken: true containers: @@ -1324,7 +1324,7 @@ spec: labels: name: agent-ksmsharded-example annotations: - checksum/config: 4ec2b2ef4d3c5c103e79e47a45d4b3b4f9f774e85293f9a5b2d56556025f1d2d + checksum/config: 58c52f37c9e2582e270e0c3b5c0150252db79a8a1be4e9b287da943a7c9e3bdf spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/examples/nginx-custom-integration/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/nginx-custom-integration/rendered/manifest.yaml index 3754e60eccc..693189323e1 100644 --- a/deploy/helm/elastic-agent/examples/nginx-custom-integration/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/nginx-custom-integration/rendered/manifest.yaml @@ -36,9 +36,6 @@ stringData: type: elasticsearch username: elastic secret_references: [] - providers: - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -66,6 +63,9 @@ stringData: - nginx-stubstatus type: nginx/metrics use_output: default + providers: + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -215,7 +215,7 @@ spec: labels: name: agent-nginx-example annotations: - checksum/config: 4b3a03273d11151ee0f8bbdc8e235f8b6d2b344e09dedc632ae6f7f9e8e0ef34 + checksum/config: 627f26ad8791a17274403b380c484441f4b4667f49d72057b17921707be49b0c spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/examples/system-custom-auth-paths/rendered/manifest.yaml b/deploy/helm/elastic-agent/examples/system-custom-auth-paths/rendered/manifest.yaml index 0660d3638c6..48caa3a1153 100644 --- a/deploy/helm/elastic-agent/examples/system-custom-auth-paths/rendered/manifest.yaml +++ b/deploy/helm/elastic-agent/examples/system-custom-auth-paths/rendered/manifest.yaml @@ -43,12 +43,6 @@ stringData: metrics: true namespace: default use_output: default - providers: - kubernetes: - node: ${NODE_NAME} - scope: node - kubernetes_leaderelection: - enabled: false inputs: - data_stream: namespace: default @@ -176,6 +170,12 @@ stringData: period: 10s type: system/metrics use_output: default + providers: + kubernetes: + node: ${NODE_NAME} + scope: node + kubernetes_leaderelection: + enabled: false --- # Source: elastic-agent/templates/agent/cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -299,7 +299,7 @@ spec: labels: name: agent-pernode-example annotations: - checksum/config: 39e00ed2a77861d6ce0f1436c373284c3651db4325dbe5d25300677203cfdca7 + checksum/config: 2c282d47af61943389605343bda01a73669627e940b9c563e4a678dfcbaa0c73 spec: automountServiceAccountToken: true containers: diff --git a/deploy/helm/elastic-agent/templates/agent/k8s/_pod_template.yaml b/deploy/helm/elastic-agent/templates/agent/k8s/_pod_template.yaml index 3b471f9e37e..ade4aacf672 100644 --- a/deploy/helm/elastic-agent/templates/agent/k8s/_pod_template.yaml +++ b/deploy/helm/elastic-agent/templates/agent/k8s/_pod_template.yaml @@ -55,13 +55,11 @@ template: {{- end }} type: DirectoryOrCreate {{- end }} - {{- if eq $.Values.agent.fleet.enabled false }} {{/* standalone mode so config is static */}} - name: config secret: defaultMode: 0444 secretName: {{ $agentName }} - {{- end }} {{- with $.Values.agent.imagePullSecrets }} imagePullSecrets: {{- . | toYaml | nindent 8 }} @@ -83,9 +81,7 @@ template: {{- else }} image: "{{ $.Values.agent.image.repository }}:{{ $.Values.agent.version }}" {{- end }} - {{- if eq $.Values.agent.fleet.enabled false }} args: ["-c", "/etc/elastic-agent/agent.yml", "-e"] - {{- end }} {{- with ($presetVal).securityContext }} securityContext: {{- . | toYaml | nindent 10 }} @@ -110,12 +106,10 @@ template: - name: agent-data mountPath: /usr/share/elastic-agent/state {{- end }} - {{- if eq $.Values.agent.fleet.enabled false }} - name: config mountPath: /etc/elastic-agent/agent.yml readOnly: true subPath: agent.yml - {{- end }} env: - name: NODE_NAME valueFrom: diff --git a/deploy/helm/elastic-agent/templates/agent/k8s/_secret.tpl b/deploy/helm/elastic-agent/templates/agent/k8s/_secret.tpl index 88e880ee5fb..854bd5eea6a 100644 --- a/deploy/helm/elastic-agent/templates/agent/k8s/_secret.tpl +++ b/deploy/helm/elastic-agent/templates/agent/k8s/_secret.tpl @@ -3,6 +3,7 @@ {{- $presetVal := index . 1 -}} {{- $agentName := index . 2 }} agent.yml: |- + {{- if eq $.Values.agent.fleet.enabled false }} id: {{ $agentName }} {{- with ($presetVal).outputs }} outputs: @@ -15,12 +16,16 @@ agent: {{- . | toYaml | nindent 6}} {{- end }} - {{- with ($presetVal).providers }} - providers: - {{- . | toYaml | nindent 6 }} - {{- end }} inputs: {{- with ($presetVal)._inputs -}} {{- . | toYaml | nindent 6 }} {{- end }} -{{- end }} \ No newline at end of file + {{- else }} + fleet: + enabled: true + {{- end }} + {{- with ($presetVal).providers }} + providers: + {{- . | toYaml | nindent 6 }} + {{- end }} +{{- end }} diff --git a/deploy/helm/elastic-agent/templates/agent/k8s/secret.yaml b/deploy/helm/elastic-agent/templates/agent/k8s/secret.yaml index d4f045278d8..d207a5099d1 100644 --- a/deploy/helm/elastic-agent/templates/agent/k8s/secret.yaml +++ b/deploy/helm/elastic-agent/templates/agent/k8s/secret.yaml @@ -1,5 +1,4 @@ {{- include "elasticagent.init" $ -}} -{{- if eq $.Values.agent.fleet.enabled false }} {{- range $presetName, $presetVal := $.Values.agent.presets }} {{- if (eq $.Values.agent.engine "k8s") -}} {{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) -}} @@ -20,6 +19,5 @@ metadata: stringData: {{ include "elasticagent.engine.k8s.secretData" (list $ $presetVal $agentName) }} --- -{{- end -}} {{- end }} {{- end }}