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

[charts/redis-ha] Allows changes on command/args/env redis container #238

Merged
merged 7 commits into from
Apr 7, 2024

Conversation

Benoitsob
Copy link
Contributor

@Benoitsob Benoitsob commented Oct 26, 2022

What this PR does / why we need it:

When containers are restarted, initContainers are not re-executed as the pod is not restarted. To ensure that a script is executed before starting redis, the script should be included in the redis container.
This PR allows this by allowing:

  • Overriding of Redis container command and args.
  • Adding extra environment variables from ConfigMap and Secrets.
redis:
  command:
  - bash
  - "/scripts/init.sh" 
  args:
  - redis-server
  - /data/conf/redis.conf
  extraVolumeMounts:
  - mountPath: /scripts
    name: init-script
  envFrom:
  - secretRef:
      name: add-env-secret
....
extraVolumes:
- name: init-script
  configMap:
    name: redis-init-script
init.sh
#!/bin/bash
echo "Do stuff before redis startup with custom EnvVar"
exec "$@"

Which issue this PR fixes

Doesn't concern an issue.

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • DCO signed
  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [stable/mychartname])

@DandyDeveloper
Copy link
Owner

@Benoitsob I would love a second opinion on this one, there's two ways to go about this:

  • We keep the default and condition with an if/else to map the customCommand. I say this, because for some, it would be VERY easy to break what they already have in a not so obvious way,

  • The way you've done things.

I like both, one of the frustrations of being an independent maintainer is figuring which one I like better.

If you had to choose between these both. Which would you prefer?

Copy link
Owner

@DandyDeveloper DandyDeveloper left a comment

Choose a reason for hiding this comment

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

Missing some defaults that you've added to the core values.

charts/redis-ha/values.yaml Show resolved Hide resolved
@Benoitsob
Copy link
Contributor Author

Benoitsob commented Mar 2, 2023

Hello @DandyDeveloper ,

The second one is less code and more straightforward. But it's fair to make clear that the command is/may be overridden by the user. I would go then with the proposed if/else clause.

It would look like this (also applied for args):

#values.yaml
  customCommand: []
  # - bash
  customArgs: []
  # - "custom-startup.sh"

#redis-ha-statefulset.yaml
        command:
        {{- if .Values.redis.customCommand }}
{{ toYaml .Values.redis.customCommand | indent 10 }}
        {{- else }}
          - redis-server
        {{- end }}
        args:
        {{- if .Values.redis.customArgs }}
{{ toYaml .Values.redis.customArgs | indent 10 }}
        {{- else }}
          - /data/conf/redis.conf
        {{- end }}

If ok, I'll make the change & correction.

@DandyDeveloper
Copy link
Owner

@Benoitsob I think this is the happy middleground to suit all user cases (I had nothing wrong with the original, but I think this is more thorough and won't hurt existing users).

Throw me an @ when you finish and I'll get this merged asap.

Signed-off-by: Benoit Sobrie <[email protected]>
Signed-off-by: Benoit Sobrie <[email protected]>
@Benoitsob
Copy link
Contributor Author

Hello @DandyDeveloper ,

I made changes according the discussion. Thanks for the review.

@maxisam
Copy link

maxisam commented Jul 12, 2023

@DandyDeveloper I think this is the missing piece for using redis stack, could you let us know what is your plan on this?

Thanks!

DandyDeveloper
DandyDeveloper previously approved these changes Apr 7, 2024
DandyDeveloper
DandyDeveloper previously approved these changes Apr 7, 2024
Signed-off-by: Aaron Layfield <[email protected]>
@DandyDeveloper DandyDeveloper merged commit 6bf9e46 into DandyDeveloper:master Apr 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants