Configs/Secrets Rotation #23
Labels
No labels
availability
bug
deployment-usability
duplicate
enhancement
help-wanted
question
security
stack-auth
stack-chat
stack-cleanup
stack-git
stack-mesh
stack-site-support
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#24 Configs/Secrets Bootstrapping & Management
python-support/python-support-infra
Reference: python-support/python-support-infra#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Both secrets and configs will be referred to as configs. The usage is identical.
Docker stacks are, when redeployed, capable of picking up on service changes (which includes changes to configs and secrets) and choosing when to restart what. When one relies on this, niceties like rolling updates become easy (see
update_config).Unfortunately,
configscannot be changed while being used. To rotate aconfig, one must:config, with a unique name, in the Swarm.docker-compose.yml, replace the (also unique) name for the oldconfig, with the unique name for the newconfig.docker-compose.ymlfile.This is where complexities arise.
Implementation
In practice, here's the way to do it (separate
configandsecret):docker-compose.yml, specifyconfignames using Jinja2-templating: `"{{ config_latest['<stack_name>__'] }}"docker-compose.yml, specifysecretnames using Jinja2-templating: `"{{ secret_latest['<stack_name>__'] }}"docker-compose.ymlusingtemplateinstead offile.templateinstead offile.rolling_versionsincommunity.docker.docker_config. Setversions_to_keepto 2.config_result.config_result.results, add to (and/or create) dictconfig_latestwith key of config name(removing the_vXpostfix), and value ofitem.config_name.role.In total, the procedure will be modified to be:
_vX. If there was already a config, the new config will be created with incremented version postfix_vX. If no change is needed, no new config will be created. Only the last config will be kept (to allow rollback).config_latest: '<stack_name>__<id>' => '<stack_name>__<id>_vX'.rollback_configin the stack will enable reverting to the previous version without human input.update_configin the stack will enable re-creating one replica at a time, ensuring no downtime even in the case of failure (in which case, rolling back to the last working version can be configured).References / Resources
A bit of inspiration to how this solution came to be.
Why Version, Not Hash?
Keeping a unique, incrementing int ID is the right choice here: