How Custom Runtimes Work
Custom Runtimes are defined by three interfaces: Fetch, Apply, GetInfo. These interfaces tell Prodvana how to interact with your infrastructure and execute as run-to-completion jobs on another Runtime, such as Kubernetes (support for AWS Lambda and GCP Cloud Functions coming soon).
Interface | Required? | Description |
---|---|---|
Fetch | Optional | Detect whether there is any work to get a Service to its desired state. Exit 0 if there is no work to be done, 2 if there is work to be done. If there is work, Apply will execute. Fetch can also define the exact work to be done that will be passed to Apply (e.g. a Terraform plan). If defined, Prodvana will automatically detect drift for your Service by running Fetch periodically. When Fetch returns that there is work to be done, Apply will run (subject to approvals as configured). If not defined, Apply will always execute once. |
Apply | Required | Make changes to the underlying infrastructure to get a Service to its desired state. |
GetInfo | Optional | Freeform, auxiliary output that should be displayed on the Prodvana UI to explain the current state of the Service. GetInfo has no impact on the convergence status of the Service nor on how the other interfaces (Fetch, Apply) are executed. |
Examples
Let's walk through a couple of examples of how Custom Runtimes may be used to manage arbitrary, non-Kubernetes services on Prodvana.
Terraform
Goal: Manage executions of a Terraform module on Prodvana. Detect drift.
Interface | Implementation |
---|---|
Fetch | terraform plan -detailed-exitcode This command checks if there is any drift between the Terraform module and the physical infrastructure. Note that the builtin Terraform Runner Runtime does quite a bit more to handle lock and retries, as well as save the Terraform plan to be used on Apply. |
Apply | terraform apply This command makes any changes necessary to bring the physical infrastructure to what the Terraform module defines. |
GetInfo | Not implemented. |
Static Asset Deployment to a GCS Bucket
Goal: Copy static assets to a GCS bucket.
Interface | Implementation |
---|---|
Fetch | Not implemented. |
Apply | gsutil cp ... This command copies files locally to a GCS bucket. |
GetInfo | Return the GCP console link to the file being deployed so the developer can quickly inspect it. |
Google Cloud Build
Goal: Run a Google Cloud Build that will handle the deployment logic.
For a full end-to-end example, see here.
Interface | Implementation |
---|---|
Fetch | Not implemented. |
Apply | gcloud build triggers run ... This command starts a new Google Cloud Build. The Apply command can additionally be made to wait for the build to complete and stream logs (see full example above). |
GetInfo | Not implemented |
Updated 10 months ago