craftcms / craftcms/cms

What about Kubernetes Secrets vs. environment variables support in Craft

Open
#5,945 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Hi guys,

I want to startup a discussion about Kubernetes Secrets. Not that this is a part of the Craft CMS support, but it has something to do with environment variables, which Craft supports.

Maybe you know, maybe you don't... But Secrets in Kubernetes are used to store credentials in. Those secrets are basically put back into containers as files, mounted typically on something like /run/secrets/ or whatever.
For now I have to do put them in a configuration file, since I have to read the contents of these files like file_get_contents(getenv('MY_ENV_VAR_AS_SECRET')).
This way I can't use the environment variables directly in the CP env-vars-support fields like email settings or site settings etc.

For example; In Symfony you can use these kind of secrets like parameters defined as %env(file:MY_ENV_VAR_AS_SECRET)%. The "file" keyword is being parsed as a file_get_contents() would do. Maybe this is something Craft can support too. This makes working with Secrets in new environment infrastructures (like Kubernetes) and Craft even more powerful.

I hope you see the value of this and I would like to talk about this kinda feature.

Additional info
  • Craft version: 3.4.15
  • PHP version: 7.4.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing Craft's existing environment-variable support and the Kubernetes Secrets workflow described in the issue. Determine how mounted secret files should be referenced in CP environment-variable fields, then define and test the proposed file-based expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, php
Domain
infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.