-
Notifications
You must be signed in to change notification settings - Fork 310
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
Secrets Manager and secrets specification for tasks #406
Conversation
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #406 +/- ##
==========================================
+ Coverage 83.98% 84.07% +0.09%
==========================================
Files 337 340 +3
Lines 24955 25166 +211
Branches 2028 2048 +20
==========================================
+ Hits 20959 21159 +200
- Misses 3441 3449 +8
- Partials 555 558 +3
Continue to review full report at Codecov.
|
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the user interface for secrets will evolve as people start using it (and maybe possibly as we add an authz layer). Not sure how exactly though.
|
||
|
||
def test_secrets(): | ||
@task(secret_requests=["my_secret"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Secret("my_secret")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aah yes it should be, and thus in this case maybe i should do a check on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Ketan Umare <[email protected]>
@@ -304,16 +311,21 @@ def __init__( | |||
name: str, | |||
task_config: T, | |||
interface: Optional[Interface] = None, | |||
environment=None, | |||
task_type_version=0, | |||
environment: Optional[Dict[str, str]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we removing task_type_version
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not removing, i am keeping it so that, if something is declared in the base, it does not need to repeated at every class layer - **kwargs should take care of it?
return v | ||
if os.path.exists(fpath): | ||
with open(fpath, "r") as f: | ||
return f.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a strip()
here in case of newlines??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
class MountType(Enum): | ||
ENV_VAR = _sec.Secret.MountType.ENV_VAR | ||
""" | ||
Use this if the secret can be injected as an environment variable. Usually works for symmetric keys, passwords etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question: is this way of using multi-line strings as in-line comments a convention, or important for sphinx docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats what I understand, that sphinx will convert this to a doc-string on the constant
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
The resolution order is | ||
- Try env var first. The env var should have the configuration.SECRETS_ENV_PREFIX. The env var will be all upper | ||
cased | ||
- If not then try the file where the name matches the key as lower case in configuration.SECRETS_DEFAULT_DIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated right? it will be <DEFAULT_DIR>/Group/<PREFIX>Key
flytekit/configuration/secrets.py
Outdated
FLYTE_SECRETS_ENV_PREFIX variable | ||
""" | ||
|
||
SECRETS_DEFAULT_DIR = _common_config.FlyteStringConfigurationEntry("secrets", "default_dir", default="/etc/secrets") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.join?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for /etc/secrets you mean?
flytekit/models/security.py
Outdated
group: str | ||
key: str | ||
group_version: Optional[str] = None | ||
mount_requirement: MountType = MountType.ENV_VAR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ANY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ANY what? - for MountType?
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
flytekit/configuration/secrets.py
Outdated
""" | ||
|
||
SECRETS_DEFAULT_DIR = _common_config.FlyteStringConfigurationEntry( | ||
"secrets", "default_dir", default=os.path.join("etc", "secrets") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"secrets", "default_dir", default=os.path.join("etc", "secrets") | |
"secrets", "default_dir", default=os.path.join(os.path.sep, "etc", "secrets") |
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
* Secrets Manager and secrets specification for tasks Signed-off-by: Ketan Umare <[email protected]> * Updated setup.py Signed-off-by: Ketan Umare <[email protected]> * requirements updated Signed-off-by: Ketan Umare <[email protected]> * Unit tests and models for security context Signed-off-by: Ketan Umare <[email protected]> * Updated test Signed-off-by: Ketan Umare <[email protected]> * Tests and exposed methods Signed-off-by: Ketan Umare <[email protected]> * SecretManager available in testing Signed-off-by: Ketan Umare <[email protected]> * requirements updated Signed-off-by: Ketan Umare <[email protected]> * ran make requirements Signed-off-by: wild-endeavor <[email protected]> * Fixed test Signed-off-by: Ketan Umare <[email protected]> * Fixed test and check that secrets are not bare strings Signed-off-by: Ketan Umare <[email protected]> * Updated to use new FlyteIDL Signed-off-by: Ketan Umare <[email protected]> * Updated group secrets Signed-off-by: Ketan Umare <[email protected]> * Updated secrets with group concat logic Signed-off-by: Ketan Umare <[email protected]> * wip Signed-off-by: Ketan Umare <[email protected]> * Updated to flyteidl 0.18.24. Secrets with version Signed-off-by: Ketan Umare <[email protected]> * Updated secrets, to always require group Signed-off-by: Ketan Umare <[email protected]> * addressed comments Signed-off-by: Ketan Umare <[email protected]> * updated to address comments Signed-off-by: Ketan Umare <[email protected]> * updated linter fix Signed-off-by: Ketan Umare <[email protected]> * Updated to address more comments Signed-off-by: Ketan Umare <[email protected]> * remove faulty test Signed-off-by: Ketan Umare <[email protected]> * update os.sep Signed-off-by: Ketan Umare <[email protected]> Co-authored-by: wild-endeavor <[email protected]>
Signed-off-by: Ketan Umare [email protected]
TL;DR
[wip]Pending adding secrets to flyteidl tasktemplate
This enables every python task or a python plugin to request for secrets and the secrets are retrieved in a standardized way during the execution using the flytekit context's new SecretsManager.
SecretsManager will resolve the secrets by first looking at Env Var and then at the configured secrets directory.
Rules:
default_dir is set to /etc/secrets (can be overriden using an env var)
prefix is set to ""
Type
Are all requirements met?
Tracking Issue
flyteorg/flyte#796
flyteorg/flyte#800