Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[elasticsearch-exporter] Support ssl-skip-verify option (and make securitycontext configurable) #14748

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jun 12, 2019

What this PR does / why we need it:

  • support ssl-skip-verify option (for version >= 1.0.4rc1)
  • make securityContext configurable (so we can remove runAsUser:1000 that prevent the chart from running on OpenShift)

(Redo of #12627 that I accidentally closed)

@helm-bot helm-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 12, 2019
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 12, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @bquartier. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>
@ghost ghost force-pushed the master branch from ce8ac4c to 22c9d91 Compare June 12, 2019 09:41
@helm-bot helm-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Jun 12, 2019
@ghost
Copy link
Author

ghost commented Jun 12, 2019

@svenmueller , @desaintmartin ,
This is an updated version of #1262 that I accidentally closed.
Sorry for the delay between the initial version and the corrected one.

@desaintmartin
Copy link
Collaborator

/assign
/ok-to-test
Thanks!

@k8s-ci-robot k8s-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 12, 2019
Copy link
Collaborator

@desaintmartin desaintmartin left a comment

Choose a reason for hiding this comment

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

More generally, could you add a test file in the ci directory (see https://github.com/helm/charts/tree/master/stable/elasticsearch/ci for inspiration)?

@@ -1,7 +1,7 @@
apiVersion: v1
description: Elasticsearch stats exporter for Prometheus
name: elasticsearch-exporter
version: 1.3.1
version: 1.4.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
version: 1.4.1
version: 1.4.0

Copy link
Author

Choose a reason for hiding this comment

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

I updated the version.

Regarding the test, I will need to have a look at the documentation.
What do you think should be tested in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

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

if you want to write tests, you might want to look at some examples, e.g. https://github.com/helm/charts/blob/master/stable/grafana/templates/tests/test-podsecuritypolicy.yaml

Copy link
Author

Choose a reason for hiding this comment

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

I don't really want to add test for such a small PR, but I was respondint to @desaintmartin coment regarding https://github.com/helm/charts/tree/master/stable/elasticsearch/ci

Copy link
Collaborator

@desaintmartin desaintmartin Jun 13, 2019

Choose a reason for hiding this comment

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

Oh, it is very simple, just adding a file or two in ci that acts as values.yaml testing the different configurations you are introducing (along with an empty file to also test default values).
In my experience those things tend to break after some "unrelated" PRs if it is not tested.

@@ -11,6 +11,10 @@ image:
tag: 1.0.2
pullPolicy: IfNotPresent

securityContext:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe state that you should comment in order to disable.

Usually this is done by a enabled flag but it does not work this way here unless we explicitely get runAsNonRoot runAsUser in deployment.yaml. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

What is needed in the securityContext depends on the version of the image you use and the flavor of Kubernetes. I think it is good to have it completely configurable.
I added a comment in the value file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i double-checked how other charts are doing it. It seems to be standard to use a flag for enabling/disabling configuration snippets (as @desaintmartin mentioned already), e.g.

{{- if .Values.securityContext.enabled }}
    securityContext:
        runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
        runAsUser: {{ .Values.securityContext.runAsUser }}
       ...
{{- end }}

would this be an option?

Copy link
Author

Choose a reason for hiding this comment

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

@svenmueller this is an option.
However, with your example it would not be possible to set runAsNonRoot without setting runAsUser.
I could do:

{{- if .Values.securityContext.enabled }}
    securityContext:
        {{- if .Values.securityContext.runAsNonRoot }}
        runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
        {{- end}}
        {{- if .Values.securityContext.runAsUser }}
        runAsUser: {{ .Values.securityContext.runAsUser }}
         {{- end }}
       ...
{{- end }}

but it seems quite heavy, not sure it is really worth it.

@svenmueller , @desaintmartin what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

in that case, i would prefer you current solution.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, thanks @svenmueller .

The lgtm label is still needed to merge this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Who can put the lgtm label (my understanding of the process is that it comes before the approve label)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've just realized something.
Actually, if you comment the whole section in your own custom values.yaml, it will take values from the default values.yaml (this file!) and it will be still used. Same if you comment runAsNonRoot for example.
This is why the enabled flags are preferred.
But maybe we can workaround this by setting securityContext: {} or something like this.

Copy link
Author

Choose a reason for hiding this comment

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

@desaintmartin You're right, it is not good. :(.

Initially, I wanted to let the securityContext configuration 100% configurable. However, it is not what other stable charts in this repository do.
I searched this repository for securityContext.enabled and I propose to use the same pattern as they use in the mongodb chart. It is not as configurable as I initially wanted it to be but it covers the two cases I am aware of, Kubernetes and OpenShift.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, I don't like this pattern (any new parameter requires a PR) but this might be the simplest way for now.

@ghost ghost force-pushed the master branch 3 times, most recently from 980fb20 to 4bce2ae Compare June 12, 2019 11:30
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 12, 2019
@svenmueller
Copy link
Collaborator

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2019
@ghost ghost force-pushed the master branch from 4bce2ae to 51c254d Compare June 13, 2019 09:54
@helm-bot helm-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 13, 2019
@ghost ghost force-pushed the master branch from 51c254d to d8ae3c8 Compare June 13, 2019 10:01
# Set default security context for kubernetes

securityContext:
runAsNonRoot: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

1/ It also requires an empty file as well to test with the default values : https://github.com/helm/charts/blob/30b5c13ae1cad13655c0e3f43c7f4cf525e76944/stable/redis/ci/default-values.yaml, so that the default values are tested

2/ In this file, you can change securityContext to be disabled.

And then let's merge this!

Copy link
Author

Choose a reason for hiding this comment

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

@desaintmartin like this?

By the way, I am not familiar at all with those files for the CI. Do you have a link to the documentation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>
@ghost ghost force-pushed the master branch from d8ae3c8 to d9d5ce8 Compare June 13, 2019 10:31
@ghost
Copy link
Author

ghost commented Jun 14, 2019

Do you think we can merge this PR now?

@desaintmartin
Copy link
Collaborator

Thanks for this work!
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bquartier, desaintmartin, svenmueller

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2019
@k8s-ci-robot k8s-ci-robot merged commit 72ac0bb into helm:master Jun 14, 2019
fooka03 pushed a commit to fooka03/charts that referenced this pull request Jun 17, 2019
…uritycontext configurable) (helm#14748)

* [elasticsearch-exporter] Add es.ssl-skip-verify option

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>

* [stable/elasticsearch-exporter] Make securityContext configurable

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>
Signed-off-by: Nigel Foucha <nigel.foucha@gmail.com>
anasinnyk pushed a commit to MacPaw/charts that referenced this pull request Jun 29, 2019
…uritycontext configurable) (helm#14748)

* [elasticsearch-exporter] Add es.ssl-skip-verify option

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>

* [stable/elasticsearch-exporter] Make securityContext configurable

Signed-off-by: Benoit Quartier <benoit.quartier@camptocamp.com>
Signed-off-by: Andrii Nasinnyk <anasinnyk@macpaw.com>
ollytheninja added a commit to ollytheninja/charts that referenced this pull request Jan 26, 2020
Just a simple update to add a parameter to the README that was added in helm#14748
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged. ok-to-test size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants