Deploys
Deploy modes
Section titled “Deploy modes”Each stack has a deploy mode, from its kelpie.yaml or the repository’s
default. It decides what happens when a new revision arrives:
auto: deploy it right away.approve: wait until someone with permission approves it.manual: record it and do nothing else. Someone deploys it from the stack page.
Deploying from the stack page, or approving a deployment, shows what changes first: a diff of
the stack’s files between the running revision and the one being deployed. secrets.env is listed when it changed, without
its values.
Stages
Section titled “Stages”Every deployment runs through the same stages. Each stage’s result is stored and shown live on the deployment page.
- Resolve. Check out the revision and decrypt
secrets.env. - Validate. Run
docker stack configordocker compose configto merge and normalize the compose file. Syntax and schema errors stop here. - Pre-flight. Check the normalized file against the endpoint (see below). Errors stop the deploy; warnings are shown and don’t block.
- Apply. Create the hash-named secrets and configs, then run
docker stack deploy --with-registry-auth --pruneordocker compose up -d --remove-orphans. - Converge. Watch the tasks or containers until they are running and healthy, or until
KELPIE_DEPLOY_TIMEOUT(5 minutes) runs out. A Swarm deploy only succeeds once its services have run forKELPIE_DEPLOY_STABLE_FOR(15 seconds) without a task failing. Task errors are collected per service.
Only one deployment per stack runs at a time. A revision that arrives during a deploy waits for it.
Pre-flight checks
Section titled “Pre-flight checks”Before anything changes on the endpoint, Kelpie checks that:
- the compose file is valid,
- every image exists in its registry, using the credentials under Registries,
- external networks exist, and for Swarm stacks external secrets and configs,
- bind mount sources exist on every node a service can run on, given its placement constraints (this needs the agents),
- published ports aren’t taken by another stack’s Swarm services or, for Compose stacks, by another Compose project on the host.
Labels
Section titled “Labels”Kelpie labels every service it deploys, so running services can be traced back to git:
kelpie.stack: the stack namekelpie.revision: the revision IDkelpie.commit: the commit SHA
When a deploy fails
Section titled “When a deploy fails”A failed deployment is marked failed, with every error it collected. That’s all:
- Git is never changed or reverted.
- The stack’s desired state stays the failed revision.
- Nothing is rolled back on its own.
A successful deployment makes its revision the stack’s last good revision. To go back, deploy an older revision from the stack page. To change what git says, revert the commit in git.
Approvals
Section titled “Approvals”On a stack in approve mode, a revision waits until a user with the operator role or higher on
that stack approves it. Kelpie announces each waiting deployment once, through the
notifications that subscribe to approval requests.
With KELPIE_SEPARATE_APPROVER=true, the author of a change can’t approve it, or deploy it by
hand on that stack. Authors are matched on the commit’s email address. Edits made in Kelpie carry
the user’s email, or <username>@kelpie.local when they have none.
After each successful Swarm deploy, Kelpie stores how each service looked. Every
KELPIE_DRIFT_INTERVAL (5 minutes) it compares the running services with that and flags the
stack as drifted when they differ, for example after someone ran docker service update by hand.
The stack page lists the differences: changed replicas, image, environment, removed services,
and services with the stack’s label that the stack doesn’t define. Environment changes name the
variable but never show its value.
docker service update --force only restarts tasks and doesn’t count as drift, and the order of
plain lists such as environment variables is ignored.
Kelpie doesn’t correct drift on its own. Deploying the stack again puts it back. Compose projects aren’t checked for drift yet.