On the Hosted plan your deploys still run in your own cluster, by the Stagecoach server you install there. The difference is the connection: your Drupal admin reaches that server through api.stagecoach.sh, and the server only ever dials out, so nothing in your cluster is exposed.
Tokens
Create them in the client portal under API tokens. Each does one job, so a site's pods never hold a credential that could register clusters or reach the rest of your organization.
- Cluster token
- For the server in your cluster: registers and reports the cluster, and takes the module's requests. Cannot operate a cluster.
- Site token
- For the stage_coach module: operates the one cluster it names. Cannot register clusters or reach other ones.
- Release token
- For CI: records releases on the one cluster it names, and nothing else.
Organization-wide tokens created before these types still work; replace and revoke them.
-
Install the server
helm repo add stagecoach https://charts.stagecoach.sh helm upgrade --install stagecoach stagecoach/stagecoach \ -n stagecoach --create-namespace -f values.yamlmode: hosted stagecoach: token: stg_live_... # a Cluster token clusterName: prod # unique in your organization environments: - {name: prod, namespace: mysite, host: example.com, rank: 30, production: true} - {name: dev, namespace: mysite-dev, host: dev.example.com, rank: 10} workload: drupal container: drupal snapshots: store: pvc://stage-coach-snapshotsThe chart pins a tested server build by digest, denies all ingress to it (there is no Service), and creates a Role in each environment's namespace that never reads Secrets. The cluster appears in the portal within a minute.
-
Connect the module
composer require 'drupal/stage_coach:^1.0@alpha' drush en stage_coach -yPut a Site token in
settings.php, then at Configuration → Development → Stagecoach choose Hosted and pick your cluster from the list.$settings['stage_coach_api_token'] = getenv('STAGECOACH_SITE_TOKEN'); -
Record releases from CI
With a Release token, from anywhere:
- uses: jtarleton/stagecoach-k8s-manifests/actions/record-release@main with: cluster: cl_... token: ${{ secrets.STAGECOACH_RELEASE_TOKEN }} image: ghcr.io/you/site@${{ steps.build.outputs.digest }}curl -fsS -X POST https://api.stagecoach.sh/v1/clusters/cl_.../api/releases \ -H "Authorization: Bearer $STAGECOACH_RELEASE_TOKEN" \ --data-urlencode "image=ghcr.io/you/site@sha256:..." \ --data-urlencode "ref=$GITHUB_REF" --data-urlencode "sha=$GITHUB_SHA"
Moving from Community
Your releases, snapshots, deploy log and audit history live in the old server's database. Move them with the server API's export and import, through a port-forward:
Install the hosted chart
As above, in its own namespace, with the same environments.
-
Export, then stop the old server
With the old server's API token (in its
stagecoach-apiSecret):kubectl -n stagecoach-old port-forward deploy/stagecoach 18080:8080 & curl -fsS -H "Authorization: Bearer $OLD_API_TOKEN" http://localhost:18080/api/export > stage-coach.db kill %1 kubectl -n stagecoach-old scale deploy/stagecoach --replicas=0A server from before chart 0.2.0 has no
/api/export: there, runkubectl -n stagecoach-old exec deploy/stagecoach -- /stage-coach export -db=/data/stage-coach.db > stage-coach.db. -
Import into the new server
kubectl -n stagecoach port-forward deploy/stagecoach 18080:8080 & curl -fsS -X POST --data-binary @stage-coach.db http://localhost:18080/api/import kill %1The import replaces everything in one transaction, then the server restarts on its own with the imported history. It refuses a database that already has releases, snapshots or deploys unless you add
?force=trueto the URL. Switch the module and CI
Choose Hosted in the module with a Site token, and give CI a Release token. Once
drush stagecoach:gridworks, uninstall the old server and revoke its tokens.
Every deploy ends with the site out of maintenance mode: if it is still on after a successful update, the server turns it off in the running site, and fails the deploy if it stays on.