If you have run a Drupal site on Acquia or Pantheon, you already know the rhythm: code goes up from dev to production, the database comes down the other way, and you hope nothing breaks in between. Stagecoach gives you that same rhythm on a Kubernetes cluster you control, from a dashboard inside your own Drupal admin. The Community plan is free, and this post walks you through it from an empty browser tab to your first deploy.
We'll go slowly and explain the Kubernetes words as they come up. Copy the commands as they are, change the names that are yours, and you will be fine. Set aside about half an hour.
What "free" means here. On the Community plan you run the Stagecoach server yourself, inside your own cluster. There is no credit card, no trial clock, and no limit on deploys, snapshots or copy-downs. The paid Hosted plans (in private beta) add a server we run for you; you can move to one later without losing your history.
Before you start
Community is the self-hosted plan, so it needs a Drupal site that already runs on Kubernetes. Check that you have:
- A Drupal 10.3 or 11 site running in a Kubernetes cluster, as a Deployment (by default named
drupal), with one namespace per environment: for examplemysitefor production andmysite-devfor dev. kubectlon your computer, able to reach the cluster. Ifkubectl get namespaceslists your site's namespaces, you're ready.- Helm 3, the installer we'll use for the Stagecoach server.
- Composer access to your site's codebase, the same way you add any contributed module.
If your site still lives on Acquia or Pantheon, the FAQ explains what moving to your own cluster involves.
Five words you'll see
- Cluster
- The group of servers Kubernetes runs your sites on. Think of it as your own private hosting platform.
- Namespace
- A walled-off area inside the cluster. Each environment (dev, prod) gets its own, so they can't step on each other.
- Deployment
- Kubernetes' description of "run this many copies of this Drupal image". Deploying a new release means changing the image it points at.
- Image
- A packaged, read-only copy of your codebase (Drupal core, modules, theme). Each build of your site produces one. Stagecoach calls a recorded image a release.
- Helm
- A package manager for Kubernetes. One command installs everything the Stagecoach server needs.
How the pieces fit
1. Create your free account
Strictly speaking, Community works without an account: nothing in this walkthrough goes through stagecoach.sh. We still recommend one. It's how we tell you about security releases, it gives you a portal where you can list your clusters, and it keeps the door open to the Hosted plans.
On stagecoach.sh, click Get Started Free.
Enter your work email, pick where your cluster runs (it's only to help us support you), and press Create account & get API token. There is no password to invent.
The link opens the portal and asks you to name your organization. Working alone? Use your own name. You can invite teammates later.
That's all the website part. Everything from here happens in your terminal and your own Drupal admin.
2. Describe your environments
The Stagecoach server needs to know which environments exist, where they live and in what order code moves through them. You tell it in a small text file. Create a file named values.yaml:
mode: community
environments:
- {name: prod, namespace: mysite, host: www.example.com, rank: 30, production: true}
- {name: dev, namespace: mysite-dev, host: dev.example.com, rank: 10}
workload: drupal # the name of your Drupal Deployment
container: drupal # and of the container inside it
snapshots:
store: pvc://stage-coach-snapshots
Line by line:
mode: communitymeans your Drupal admin talks straight to this server; nothing goes through stagecoach.sh.environmentslists each environment with its namespace and public hostname.ranksets the order: code is promoted from lower ranks to higher ones, and databases are copied down the other way. Mark exactly one asproduction: true. Got a stage environment too? Add it with a rank in between, such as 20.workloadandcontainermust match your site. If you're not sure,kubectl -n mysite get deploymentsshows the Deployment's name.snapshots.storeis where database backups go before every deploy.pvc://keeps them on a disk in each environment's namespace, which is the simplest option. If you later want to copy uploaded files between environments as well, switch to an S3 bucket (s3://bucket/prefix).
3. Install the Stagecoach server
Two commands. The first tells Helm where our charts live, the second installs the server into its own stagecoach namespace:
helm repo add stagecoach https://charts.stagecoach.sh
helm upgrade --install stagecoach stagecoach/stagecoach \
-n stagecoach --create-namespace -f values.yaml
Helm creates a small server (it asks for 48 MB of memory), a disk for its history, a backup disk in each environment's namespace, and permissions to update your Drupal Deployments and run jobs there. It never reads your Secrets. It also generates two passwords, called tokens: one for your Drupal admin and one for your build pipeline. They're kept across upgrades.
When it finishes, Helm prints install notes. Keep them open: they contain the server's address and the command that reveals the token. Check that the server is running:
kubectl -n stagecoach get pods
After a few seconds you should see one stagecoach-… pod with status Running. If it stays Pending, your cluster probably has no default storage class: see Troubleshooting.
4. Add the stage_coach module to your site
This part is ordinary Drupal. In your site's codebase:
composer require 'drupal/stage_coach:^1.0@alpha'
drush en stage_coach -y
Commit, build and deploy that change the way you do today. It's the last deploy you'll do the old way. Afterwards, Extend lists the module:
5. Connect your Drupal admin to the server
Go to Configuration → Development → Stagecoach (/admin/config/development/stage_coach). Choose Self-hosted and enter the server URL from the install notes. With the names used above it is:
http://stagecoach.stagecoach.svc:8080
Now the token. It goes in settings.php rather than in this form, on purpose: configuration gets copied between environments, and a password shouldn't travel with it. Add this line to your settings.php and commit it:
$settings['stage_coach_api_token'] = getenv('STAGE_COACH_API_TOKEN');
It reads the token from an environment variable, so the secret itself never enters your code. Give that variable to your Drupal pods by copying the token from the server's Secret into each environment:
TOKEN=$(kubectl -n stagecoach get secret stagecoach-api -o jsonpath='{.data.api-token}' | base64 -d)
for ns in mysite mysite-dev; do
kubectl -n "$ns" create secret generic stagecoach-module \
--from-literal=STAGE_COACH_API_TOKEN="$TOKEN"
kubectl -n "$ns" set env deployment/drupal --from=secret/stagecoach-module
done
The last command restarts your Drupal pods so they pick the variable up; give them a minute. If you manage your Deployments with files in Git, add the same envFrom there instead, or your next manifest change will undo it.
Back on the settings page, press Save configuration. The Status line at the bottom should now read Connected to Stagecoach, followed by the server's version. If it still says Not connected, the most common cause is a network rule that stops your site's namespace from reaching the stagecoach namespace on port 8080 (see Troubleshooting).
6. Record your first release
Stagecoach deploys releases: images it has been told about. Usually your build pipeline records each one automatically (more on that below). For the first, record what production already runs, so you have something to promote and a known-good version to come back to.
Find the exact build your production site is running. This prints its image pinned by digest (@sha256:…):
kubectl -n mysite get pods \
-o jsonpath='{.items[0].status.containerStatuses[0].imageID}{"\n"}'
Then record it from your site with Drush, giving it a name you'll recognise, such as v1.0.0, and the Git commit it was built from:
kubectl -n mysite exec deploy/drupal -- drush stagecoach:release \
--image='registry.example.com/mysite@sha256:…' \
--ref=v1.0.0 --sha='the git commit'
Drush prints the release as Stagecoach recorded it, and drush stagecoach:releases lists it from now on. The command goes through the same connection and token as the dashboard, so if step 5 says Connected, this works too.
Tip: always use the digest. A digest names one exact build, while a tag such as :latest can quietly change. Give Drush an image with only a tag and it warns you, and Stagecoach refuses to record it. If the image you found starts with docker-pullable://, leave that part off.
7. Deploy to dev, then promote to production
Open Reports → Stagecoach (/admin/stage_coach). The dashboard shows each environment and what it runs. Choose to deploy to dev, pick v1.0.0 under What to deploy, and confirm. If you prefer the command line, the module adds Drush commands that do the same:
drush stagecoach:releases
drush stagecoach:deploy dev --release=v1.0.0
Here's what happens behind that button, in order:
- A snapshot of dev's database is taken, so you can go back.
- The Deployment is pointed at the new image, and Kubernetes swaps the pods over.
- With the site briefly in maintenance mode, the familiar Drupal steps run: database updates and configuration import.
- Maintenance mode is switched off and the site is checked.
Click around dev. When you're happy, deploy the same release to prod the same way. That's a promotion: the exact build you tested is what goes live.
8. Your safety net
Every deploy starts with a snapshot, so a bad release is a short fix rather than a long night:
drush stagecoach:rollback prod # back to the previous release
drush stagecoach:rollback prod --with-data # and restore the pre-deploy database too
You can also take a snapshot any time (drush stagecoach:snapshot prod) and copy production's database down to dev, with personal data scrubbed on arrival. For that copy-down, the install notes list one extra Secret to create. The FAQ covers what to do when production is down, including when Drush itself won't start.
Next: let your pipeline record releases
Typing release commands gets old fast. The chart created a second token just for your build pipeline. After each build, your CI job (running somewhere that can reach the server's address) records the image:
curl -fsS -X POST http://stagecoach.stagecoach.svc:8080/api/releases \
-H "Authorization: Bearer $STAGE_COACH_RELEASE_TOKEN" \
--data-urlencode "image=registry.example.com/mysite@sha256:…" \
--data-urlencode "ref=$GITHUB_REF" --data-urlencode "sha=$GITHUB_SHA"
That token is in the same Secret: kubectl -n stagecoach get secret stagecoach-api -o jsonpath='{.data.release-token}' | base64 -d. Only your environments' namespaces can reach the server by default; to let a CI runner in, add its namespace under api.extraIngressFrom in values.yaml and run the Helm command again.
Troubleshooting
- The stagecoach pod stays Pending
- Its disk can't be created. Run
kubectl get storageclass; if none is marked (default), setstorage.storageClassNameandsnapshots.claim.storageClassNameinvalues.yamlto one that exists, then rerun the Helm command. - The settings page still says Not connected
- Check the URL, then that the variable reached the pods:
kubectl -n mysite exec deploy/drupal -- sh -c 'test -n "$STAGE_COACH_API_TOKEN" && echo set'should printset. If your namespaces block outgoing traffic by default, allow traffic to thestagecoachnamespace on port 8080. - A deploy waits for ever
- The new pods aren't becoming ready, often because the image can't be pulled.
kubectl -n mysite-dev get podsandkubectl -n mysite-dev describe pod …say why. Roll back from the dashboard or withdrush stagecoach:rollback dev. - Copy-down says a Secret is missing
- Copying a database down needs read-only credentials for the source database in the target namespace. The Helm install notes name the Secret and its keys.
Wrapping up
You now have a deployment pipeline that lives in your own Drupal admin, runs on your own cluster and costs nothing: snapshots before every deploy, one-click promotion from dev to production, and a rollback when you need one. The Community setup reference has every option on one page.
Stuck, or something here didn't match what you saw? Tell us. We read every message, and posts like this one get better because of them.