Cordium documentation · Latest
CI/CD Pipelines
Cordium Workspaces make capable CI/CD execution environments: each job runs in a fresh, ephemeral sandbox on your own infrastructure, with as much CPU and memory as it needs, shared caches, and secretless access to the private resources that integration tests and deployments need, such as databases, internal APIs and Kubernetes clusters. Since deployments run with the identity of the job's Workspace, there is no kubeconfig, cloud credential or database password to store in your CI system.
This example builds a test-and-deploy pipeline for a Go service that can be driven by any CI system, such as GitHub Actions, GitLab CI, Jenkins or Buildkite.
The Test Template
The ci Template checks out the commit to test when the Workspace is created, and reuses the Go caches across runs via a shared Volume (read more about variables here and about caches here):
REF can be a branch, a tag or a commit SHA, since the checkout task fetches it explicitly.
Running Jobs from Any CI System
The following Python script is all that a CI job needs to run. It starts an ephemeral Workspace for the commit, runs the pipeline's steps in it via exec while streaming their output to the CI job's log, stops at the first failing step with its exit code, and always deletes the Workspace (read more about authenticating CI jobs here and here):
Since each step is a separate exec session, you get the exact exit code and output of every step, while the Workspace's CPU, memory, caches and network access are shared by all of them. The ::group:: lines fold the output of each step in GitHub Actions and are harmless in other CI systems.
Secretless Deployments
Deployment jobs need access to production-like infrastructure, which is exactly where long-lived CI credentials are the most dangerous. Instead, a Cluster administrator exposes the staging Kubernetes cluster as an Octelium KUBERNETES Service named k8s-staging (read more here), and only allows the Workspaces of the deploy Template to use it, and only within the payments Kubernetes namespace:
The deploy Template, which uses Cordium's default Ubuntu-based image, then rolls out a new image with kubectl, which is authenticated by Octelium on a per-request basis. Since it is an auto-stopping POST_START task with ON_FAILURE_ABORT, the run fails if the rollout fails:
Every kubectl request made by the job, including the image that was rolled out, appears in Octelium's access logs along with the identity of the Workspace and of the User who triggered it (read more here).