Skip to content

Conversation

@Mangaal
Copy link
Contributor

@Mangaal Mangaal commented Sep 17, 2025

Description

This PR introduces a more secure method for providing Redis credentials to Argo CD components by allowing them to be loaded from a specified file path. Currently, Redis credentials (password, username, sentinel credentials) are configured via environment variables (e.g., REDIS_PASSWORD). Storing secrets in environment variables is a common practice but can be less secure than using file-based secrets.

This change is backward-compatible. Existing setups using environment variables will continue to work without any modification

Proposed Change
This PR introduces a new mechanism to load Redis credentials from files:

  1. New Environment Variable: A new environment variable, REDIS_CREDS_FILE_PATH, is introduced. This variable should point to a directory where credential files are mounted.
  2. File-Based Credential Loading: When REDIS_CREDS_FILE_PATH is set, Argo CD will attempt to read credentials from the following files within that directory:
    • auth: The password for the main Redis connection.
    • auth_username: The username for the main Redis connection.
    • sentinel_auth: The password for Redis Sentinel connections.
    • sentinel_username: The username for Redis Sentinel connections.
  3. Fallback Logic: The implementation prioritises credentials loaded from the file path. If REDIS_CREDS_FILE_PATH is not set, or if a specific credential file does not exist, the system gracefully falls back to using the corresponding environment variables (REDIS_PASSWORD, REDIS_USERNAME, etc.). This ensures full backward compatibility.

Implementation Details

  1. A new struct redisCreds was added to hold the set of credentials.
  2. A new function loadRedisCredsFromFile(mountPath string) was created to handle the logic of reading the individual credential files from the specified mountPath. It is designed to be resilient to missing files, returning empty strings for any credential that cannot be read.
  3. The AddCacheFlagsToCmd function has been updated to incorporate this new logic. It first checks for the REDIS_CREDS_FILE_PATH environment variable. If present, it calls loadRedisCredsFromFile and then checks if any credentials still need to be populated from the environment variables.

How to Test This Change
Mount the Secret into your Argo CD pods (e.g., argocd-repo-server, argocd-application-controller) and set the new environment variable.

spec:
  template:
    spec:
      containers:
      - name: your-argocd-container
        env:
        - name: REDIS_CREDS_FILE_PATH
          value: "/etc/redis-creds"
        # IMPORTANT: Ensure the old env vars like REDIS_PASSWORD are NOT set
        # to verify the new mechanism is working.
        volumeMounts:
        - name: redis-creds-volume
          mountPath: "/etc/redis-creds"
          readOnly: true
      volumes:
      - name: redis-creds-volume
        secret:
          secretName: argocd-redis-creds

Related Issue

Fixes #20619

@bunnyshell
Copy link

bunnyshell bot commented Sep 17, 2025

❌ Preview Environment undeployed from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@Mangaal Mangaal marked this pull request as ready for review September 17, 2025 10:44
@Mangaal Mangaal requested review from a team as code owners September 17, 2025 10:44
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 19f73c4)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 56fdbba)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 6faea33)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit f078ccc)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 0730071)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit d8cb701)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 60055d0)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 11da147)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 9ae4d23)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 01bdb19)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 8aa326f)
…le mount

Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 3f2e7e8)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit a7962a2)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit 5510ccb)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit f2338ee)
Signed-off-by: Mangaal <[email protected]>
(cherry picked from commit c11e2f0)
- Remove duplicate volumeMounts section

Signed-off-by: Mangaal <[email protected]>
@Mangaal Mangaal force-pushed the secrets-via-volume-mount-clean branch from 115d9b6 to 2026e39 Compare September 17, 2025 12:17
@Mangaal
Copy link
Contributor Author

Mangaal commented Oct 16, 2025

Hi @dudinea , I have updated this PR to include only the required code changes for this feature. I will create a separate PR for the documentation and manifest updates.

@Mangaal Mangaal requested a review from dudinea October 17, 2025 17:03
Copy link
Member

@dudinea dudinea left a comment

Choose a reason for hiding this comment

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

Hi @Mangaal! Thank you for the changes you made to the PR!

This PR has been discussed on the last Contributors Experience Meeting: it has been decided to include this functionality for now without the changes in the provided Manifests, just argocd code + docs to allow interested people to use this functionality provided they know to add custom configuration to ArgoCD and Redis.

Could you re-add the relevant part of the FAQ that you wrote?

Please also see my new comment on the code.

After this is addressed I hope it would be possible to commit this feature.

@Mangaal
Copy link
Contributor Author

Mangaal commented Oct 22, 2025

Hi @dudinea, I have added documentation explaining how to configure Argo CD components with file-based Redis authentication and have also addressed your previous review comments.
Please take another look when you get a chance.
Thanks again for your time and for reviewing this PR, It would be great if we could get it merged soon.

@Mangaal Mangaal requested a review from dudinea October 22, 2025 16:54
Copy link
Member

@dudinea dudinea left a comment

Choose a reason for hiding this comment

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

Hi! Please see the comments on the files. Otherwise LGTM.
Thanks!

Copy link
Member

@nitishfy nitishfy left a comment

Choose a reason for hiding this comment

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

Thank you! I've left some comments, PTAL.

The Redis password is stored in Kubernetes secret `argocd-redis` with key `auth` in the namespace where Argo CD is installed.
You can config your secret provider to generate Kubernetes secret accordingly.

### Using file-based Redis credentials via `REDIS_CREDS_FILE_PATH`
Copy link
Member

Choose a reason for hiding this comment

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

Also, i think we should find a better place to document somewhere, probably in operator-manual?

@Mangaal
Copy link
Contributor Author

Mangaal commented Oct 27, 2025

Hi @dudinea, could you please take a look at my PR when you have a chance?

@Mangaal Mangaal requested a review from dudinea October 27, 2025 06:31
@nitishfy
Copy link
Member

Feel free to resolve the comments that you've addressed.

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.

Read Secrets from Disk as well as from Env

3 participants