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

[metricbeat] split values for daemonset and deployment #572

Merged
merged 15 commits into from
Apr 17, 2020

Conversation

jmlrt
Copy link
Member

@jmlrt jmlrt commented Apr 10, 2020

Split values for DaemonSet and Deployment:

  • affinity
  • envFrom
  • extraEnvs
  • extraVolumeMounts
  • extraVolumes
  • metricbeatConfig
  • nodeSelector
  • securityContext
  • resources
  • secretMounts
  • tolerations

Fixes #446
Replace #448

  • Chart version not bumped (the versions are all bumped and released at the same time)
  • README.md updated with any new values or changes
  • Updated template tests in ${CHART}/tests/*.py
  • Updated integration tests in ${CHART}/examples/*/test/goss.yaml

@jmlrt jmlrt requested review from Crazybus and a team April 15, 2020 20:47
@jmlrt jmlrt marked this pull request as ready for review April 15, 2020 20:48
mgreau
mgreau previously approved these changes Apr 17, 2020
Copy link
Member

@mgreau mgreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

[serviceAccount]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
[tolerations]: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
[updateStrategy]: https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy
[values.yaml]: https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line missing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in b489901

{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line missing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in b489901

Crazybus
Crazybus previously approved these changes Apr 17, 2020
Copy link
Contributor

@Crazybus Crazybus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This is fantastic work! As the person that originally created this mess...thank you so much for fixing this up and making everything else better in the process :)

I thought I found an issue, but after testing it looks like it works as expected. I just hadn't seen that syntax before. I left the comments in anyway because it confused me until I looked up how it worked.

@@ -136,6 +130,13 @@ spec:
mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{ else }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 I think this else should be an {{ end }} and the other end below needs to be removed. The range loop above is going over .Values.metricbeatConfig and doesn't seem to end properly.

Suggested change
{{ else }}
{{ end }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this looked like an issue to me but I couldn't make it cause any unexpected issues when testing. After looking at the docs it looks like you can do a {{ range }} {{ else }}. I think the syntax just through me off:

{{range pipeline}} T1 {{else}} T0 {{end}}
The value of the pipeline must be an array, slice, map, or channel.
If the value of the pipeline has length zero, dot is unaffected and
T0 is executed; otherwise, dot is set to the successive elements
of the array, slice, or map and T1 is executed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah {{ range }} {{ else }} isn't documented in Helm doc, but is fine in Go template. That said, if you think this syntax can be confusing or lead to mistake, I'm fine with replacing it by 2 entirely different {{ range }} loops instead.

@@ -32,17 +32,16 @@ spec:
heritage: '{{ .Release.Service }}'
release: '{{ .Release.Name }}'
spec:
{{- with .Values.tolerations }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ I really like all of these little cleanups here to add some consistency. I like the much cleaner and shorter versions using nindent below :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah Helm templates are a little more readable with nindents 😃.

{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 10 }}
{{- if .Values.envFrom | default .Values.deployment.envFrom }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 I think this if statement can just be dropped. Since the default is an empty list already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 890428d



def test_adding_deprecated_envs():
config = """
extraEnvs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ Great to see this test being added to test the backwards compatibility logic!

mountPath: /usr/share/metricbeat/{{ $path }}
readOnly: true
subPath: {{ $path }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- end }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was part of #572 (comment) and can be ignored.

Copy link
Contributor

@Crazybus Crazybus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jmlrt jmlrt merged commit 2c82a65 into elastic:master Apr 17, 2020
@jmlrt jmlrt deleted the split-metricbeat-values branch April 17, 2020 15:31
@jmlrt jmlrt added the v7.7.0 label Apr 17, 2020
mgreau pushed a commit that referenced this pull request Apr 17, 2020
[metricbeat] split values for daemonset and deployment
@jmlrt
Copy link
Member Author

jmlrt commented Apr 20, 2020

backported to 7.7 branch in f74d721

jmlrt added a commit that referenced this pull request May 28, 2020
…624)

This commit fix a bug introduced in #572 where Metricbeat deployment doesn't start after an upgrade from a previous version when using a custom metricbeatConfig.
jmlrt added a commit that referenced this pull request May 28, 2020
…624)

This commit fix a bug introduced in #572 where Metricbeat deployment doesn't start after an upgrade from a previous version when using a custom metricbeatConfig.
jmlrt added a commit that referenced this pull request May 28, 2020
…624)

This commit fix a bug introduced in #572 where Metricbeat deployment doesn't start after an upgrade from a previous version when using a custom metricbeatConfig.
jmlrt added a commit that referenced this pull request May 28, 2020
…624)

This commit fix a bug introduced in #572 where Metricbeat deployment doesn't start after an upgrade from a previous version when using a custom metricbeatConfig.
@jmlrt jmlrt mentioned this pull request Oct 28, 2020
This was referenced Nov 17, 2020
@jmlrt jmlrt mentioned this pull request Feb 8, 2021
This was referenced Mar 15, 2021
@jmlrt jmlrt mentioned this pull request May 25, 2021
@jmlrt jmlrt mentioned this pull request Mar 8, 2022
@jmlrt jmlrt mentioned this pull request Apr 21, 2022
This was referenced Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[metricbeat] Different tolerations, nodeSelector and affinity for deployment and daemonset
3 participants