Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
[metricbeat] split configmap for daemonset and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Apr 10, 2020
1 parent b3bb665 commit cea4e9a
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 182 deletions.
70 changes: 38 additions & 32 deletions metricbeat/README.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions metricbeat/examples/6.x/test/goss-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ port:
- '127.0.0.1'

mount:
/usr/share/metricbeat/kube-state-metrics-metricbeat.yml:
/usr/share/metricbeat/metricbeat.yml:
exists: true
opts:
- ro
Expand All @@ -32,7 +32,6 @@ file:
/usr/share/metricbeat/metricbeat.yml:
exists: true
contains:
- 'add_kubernetes_metadata'
- 'output.elasticsearch'

command:
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/examples/default/test/goss-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ port:
- '127.0.0.1'

mount:
/usr/share/metricbeat/kube-state-metrics-metricbeat.yml:
/usr/share/metricbeat/metricbeat.yml:
exists: true
opts:
- ro
Expand Down Expand Up @@ -33,7 +33,6 @@ file:
/usr/share/metricbeat/metricbeat.yml:
exists: true
contains:
- 'add_kubernetes_metadata'
- 'output.elasticsearch'
- 'elasticsearch-master:9200'

Expand Down
3 changes: 1 addition & 2 deletions metricbeat/examples/oss/test/goss-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ port:
- '127.0.0.1'

mount:
/usr/share/metricbeat/kube-state-metrics-metricbeat.yml:
/usr/share/metricbeat/metricbeat.yml:
exists: true
opts:
- ro
Expand All @@ -32,7 +32,6 @@ file:
/usr/share/metricbeat/metricbeat.yml:
exists: true
contains:
- 'add_kubernetes_metadata'
- 'output.elasticsearch'

command:
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/examples/security/test/goss-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ port:
- '127.0.0.1'

mount:
/usr/share/metricbeat/kube-state-metrics-metricbeat.yml:
/usr/share/metricbeat/metricbeat.yml:
exists: true
opts:
- ro
Expand Down Expand Up @@ -38,7 +38,6 @@ file:
/usr/share/metricbeat/metricbeat.yml:
exists: true
contains:
- 'add_kubernetes_metadata'
- 'output.elasticsearch'

command:
Expand Down
152 changes: 79 additions & 73 deletions metricbeat/examples/security/values.yaml
Original file line number Diff line number Diff line change
@@ -1,77 +1,83 @@
metricbeatConfig:
metricbeat.yml: |
metricbeat.modules:
- module: kubernetes
metricsets:
- container
- node
- pod
- system
- volume
period: 10s
host: "${NODE_NAME}"
hosts: ["https://${NODE_NAME}:10250"]
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
ssl.verification_mode: "none"
# If using Red Hat OpenShift remove ssl.verification_mode entry and
# uncomment these settings:
#ssl.certificate_authorities:
#- /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
processors:
- add_kubernetes_metadata: ~
- module: kubernetes
enabled: true
metricsets:
- event
- module: system
period: 10s
metricsets:
- cpu
- load
- memory
- network
- process
- process_summary
processes: ['.*']
process.include_top_n:
by_cpu: 5
by_memory: 5
- module: system
period: 1m
metricsets:
- filesystem
- fsstat
processors:
- drop_event.when.regexp:
system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'
daemonset:
# Allows you to add any config files in /usr/share/metricbeat
# such as metricbeat.yml for daemonset
metricbeatConfig:
metricbeat.yml: |
metricbeat.modules:
- module: kubernetes
metricsets:
- container
- node
- pod
- system
- volume
period: 10s
host: "${NODE_NAME}"
hosts: ["https://${NODE_NAME}:10250"]
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
ssl.verification_mode: "none"
# If using Red Hat OpenShift remove ssl.verification_mode entry and
# uncomment these settings:
#ssl.certificate_authorities:
#- /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
processors:
- add_kubernetes_metadata: ~
- module: kubernetes
enabled: true
metricsets:
- event
- module: system
period: 10s
metricsets:
- cpu
- load
- memory
- network
- process
- process_summary
processes: ['.*']
process.include_top_n:
by_cpu: 5
by_memory: 5
- module: system
period: 1m
metricsets:
- filesystem
- fsstat
processors:
- drop_event.when.regexp:
system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'
output.elasticsearch:
username: '${ELASTICSEARCH_USERNAME}'
password: '${ELASTICSEARCH_PASSWORD}'
protocol: https
hosts: ["security-master:9200"]
ssl.certificate_authorities:
- /usr/share/metricbeat/config/certs/elastic-certificate.pem
output.elasticsearch:
username: '${ELASTICSEARCH_USERNAME}'
password: '${ELASTICSEARCH_PASSWORD}'
protocol: https
hosts: ["security-master:9200"]
ssl.certificate_authorities:
- /usr/share/metricbeat/config/certs/elastic-certificate.pem
kube-state-metrics-metricbeat.yml: |
metricbeat.modules:
- module: kubernetes
enabled: true
metricsets:
- state_node
- state_deployment
- state_replicaset
- state_pod
- state_container
period: 10s
hosts: ["${KUBE_STATE_METRICS_HOSTS}"]
output.elasticsearch:
username: '${ELASTICSEARCH_USERNAME}'
password: '${ELASTICSEARCH_PASSWORD}'
protocol: https
hosts: ["security-master:9200"]
ssl.certificate_authorities:
- /usr/share/metricbeat/config/certs/elastic-certificate.pem
deployment:
# Allows you to add any config files in /usr/share/metricbeat
# such as metricbeat.yml for deployment
metricbeatConfig:
metricbeat.yml: |
metricbeat.modules:
- module: kubernetes
enabled: true
metricsets:
- state_node
- state_deployment
- state_replicaset
- state_pod
- state_container
period: 10s
hosts: ["${KUBE_STATE_METRICS_HOSTS}"]
output.elasticsearch:
username: '${ELASTICSEARCH_USERNAME}'
password: '${ELASTICSEARCH_PASSWORD}'
protocol: https
hosts: ["security-master:9200"]
ssl.certificate_authorities:
- /usr/share/metricbeat/config/certs/elastic-certificate.pem
secretMounts:
- name: elastic-certificate-pem
Expand Down
36 changes: 36 additions & 0 deletions metricbeat/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,39 @@ data:
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if .Values.daemonset.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "metricbeat.fullname" . }}-daemonset-config
labels:
app: "{{ template "metricbeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.daemonset.metricbeatConfig }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if .Values.deployment.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "metricbeat.fullname" . }}-deployment-config
labels:
app: "{{ template "metricbeat.fullname" . }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.deployment.metricbeatConfig }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}
12 changes: 12 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ spec:
configMap:
defaultMode: 0600
name: {{ template "metricbeat.fullname" . }}-config
{{- else if .Values.daemonset.metricbeatConfig }}
- name: metricbeat-config
configMap:
defaultMode: 0600
name: {{ template "metricbeat.fullname" . }}-daemonset-config
{{- end }}
- name: data
hostPath:
Expand Down Expand Up @@ -136,6 +141,13 @@ spec:
mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{ else }}
{{- range $path, $config := .Values.daemonset.metricbeatConfig }}
- name: metricbeat-config
mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{- end }}
{{- end }}
- name: data
mountPath: /usr/share/metricbeat/data
Expand Down
14 changes: 12 additions & 2 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ spec:
configMap:
defaultMode: 0600
name: {{ template "metricbeat.fullname" . }}-config
{{- else if .Values.deployment.metricbeatConfig }}
- name: metricbeat-config
configMap:
defaultMode: 0600
name: {{ template "metricbeat.fullname" . }}-deployment-config
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
Expand All @@ -69,8 +74,6 @@ spec:
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
args:
- "-c"
- "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml"
- "-e"
- "-E"
- "http.enabled=true"
Expand Down Expand Up @@ -111,6 +114,13 @@ spec:
mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{ else }}
{{- range $path, $config := .Values.deployment.metricbeatConfig }}
- name: metricbeat-config
mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{- end }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
Expand Down
Loading

0 comments on commit cea4e9a

Please sign in to comment.