Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add envFollowKubernetesPattern to handle k8s-like format env in helm templates #2955

Merged
merged 10 commits into from
Mar 17, 2022

Conversation

g1eny0ung
Copy link
Member

@g1eny0ung g1eny0ung commented Mar 1, 2022

Signed-off-by: Yue Yang g1enyy0ung@gmail.com

What problem does this PR solve?

Close #2924

What's changed and how it works?

{{/*
Handle env variables.

TODO: in the future, we would like to use the k8s-like format for defining environment variables.
So the `envFollowKubernetesPattern` will become to `env`.
And the original way of writing env will be removed.
Ref: https://github.com/chaos-mesh/chaos-mesh/pull/2955.
*/}}
{{- define "chaos-mesh.helpers.list-env-vars" -}}
{{- with .envFollowKubernetesPattern }}
{{ toYaml . }}
{{- end }}
{{- range $key, $val := .env }}
- name: {{ $key | upper }}
  value: {{ $val | quote }}
{{- end }}
{{- end }}

Related changes

  • Need to update chaos-mesh/website
  • Need to update Dashboard UI
  • Need to cheery-pick to release branches
    • release-2.1
    • release-2.0

Checklist

Tests

  • Unit test
  • E2E test
  • No code
  • Manual test (add steps below)

Side effects

  • Breaking backward compatibility

Release note

Please add a release note.

You can safely ignore this section if you don't think this PR needs a release note.

DCO

If you find the DCO check fails, please run commands like below (Depends on the actual situations. For example, if the failed commit isn't the most recent) to fix it:

git commit --amend --signoff
git push --force

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 1, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • STRRL
  • iguoyr

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@g1eny0ung g1eny0ung added component/helm type/bug-fix A bug needs to be fixed. labels Mar 1, 2022
@g1eny0ung g1eny0ung added type/enhancement New feature or request and removed type/bug-fix A bug needs to be fixed. labels Mar 1, 2022
@g1eny0ung g1eny0ung requested review from cwen0 and a team March 1, 2022 10:59
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@ti-chi-bot ti-chi-bot added size/L and removed size/M labels Mar 2, 2022
@STRRL
Copy link
Member

STRRL commented Mar 2, 2022

So in the PR, we could set valueFrom like

dashboard:
  env:
    SOME_SECRET:
      valueFrom:
        secretKeyRef:
          name: some-secret
          key: token

It does not follow the K: V, neither follows the kubneretes like name: <name> then value: <value>.  😰

Maybe we could create another new field near the origin env field, and follows the kubernetes-like format.

@g1eny0ung
Copy link
Member Author

So in the PR, we could set valueFrom like

dashboard:
  env:
    SOME_SECRET:
      valueFrom:
        secretKeyRef:
          name: some-secret
          key: token

It does not follow the K: V, neither follows the kubneretes like name: <name> then value: <value>.  😰

Maybe we could create another new field near the origin env field, and follows the kubernetes-like format.

But our current env also doesn't conform to the k8s-like format. I have no problem with using another field, but maybe we should make env a k8s-like format in a future release? (means that the key: value format can no longer be used in env)

@STRRL
Copy link
Member

STRRL commented Mar 2, 2022

maybe we should make env a k8s-like format in a future release? (means that the key: value format can no longer be used in env)

I agree with you. Maybe we could change the current env as the k8s-like format, and we should notice that in the upgrade manual doc.

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@g1eny0ung g1eny0ung requested a review from STRRL March 7, 2022 08:28
@g1eny0ung
Copy link
Member Author

Updated. @STRRL PTAL.

@g1eny0ung g1eny0ung changed the title fix: handle env map in helm templates fix: add envFollowKubernetesPattern to handle k8s-like format env in helm templates Mar 7, 2022
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Copy link
Member

@iguoyr iguoyr left a comment

Choose a reason for hiding this comment

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

Rest LGTM

helm/chaos-mesh/templates/_helpers.tpl Outdated Show resolved Hide resolved
helm/chaos-mesh/templates/chaos-daemon-daemonset.yaml Outdated Show resolved Hide resolved
helm/chaos-mesh/templates/chaos-dashboard-deployment.yaml Outdated Show resolved Hide resolved
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Copy link
Member

@iguoyr iguoyr left a comment

Choose a reason for hiding this comment

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

LGTM

@g1eny0ung
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 3250a21

@ti-chi-bot ti-chi-bot merged commit d0b0236 into chaos-mesh:master Mar 17, 2022
@ti-srebot
Copy link
Contributor

cherry pick to release-2.1 failed

@g1eny0ung g1eny0ung deleted the fix/2924 branch March 18, 2022 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helm: range env should support valueFrom
5 participants