Configs/Secrets Rotation #23
Labels
No Label
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 Milestone
No project
No Assignees
1 Participants
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…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. 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,
configs
cannot 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.yml
file.This is where complexities arise.
Implementation
In practice, here's the way to do it (separate
config
andsecret
):docker-compose.yml
, specifyconfig
names using Jinja2-templating: `"{{ config_latest['<stack_name>__'] }}"docker-compose.yml
, specifysecret
names using Jinja2-templating: `"{{ secret_latest['<stack_name>__'] }}"docker-compose.yml
usingtemplate
instead offile
.template
instead offile
.rolling_versions
incommunity.docker.docker_config
. Setversions_to_keep
to 2.config_result
.config_result.results
, add to (and/or create) dictconfig_latest
with key of config name(removing the_vX
postfix), 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_config
in the stack will enable reverting to the previous version without human input.update_config
in 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: