Getting Started with Google Cloud Run on Prodvana
To deploy Google Cloud Run with Prodvana, you will need the following:
- A Docker image built and published to a registry your Cloud Run service account can pull from
- Artifact Registry (AR)is the simplest option.
- A Kubernetes Runtime, used entirely for management of Google Cloud Run workload. No user-facing workload will run here.
- A GCP service account for Prodvana to use (make sure you have its service account key JSON handy)
- The service account must at least have
roles/run.serviceAgent
androles/run.admin
roles.
- The service account must at least have
1. Prepare a Kubernetes Runtime
Create a Kubernetes Runtime using your cloud provider of choice.
Link your Kubernetes Runtime to Prodvana. See Configuring a Runtime.
2. Configure a Google Cloud Run Runtime
Make sure you have your GCP service account key JSON handy.
Store the key on Prodvana via pvnctl.
pvnctl secrets set gcp-service-account-key-json "$(cat service-account-key.json)"
Create a new config file for your Google Cloud Run Runtime.
runtime:
name: my-cloud-run-runtime # this can be whatever you want
googleCloudRun:
proxyRuntime:
runtime: YOUR_KUBERNETES_RUNTIME
serviceAccountJson:
secret:
key: gcp-service-account-key-json # this is the name of the secret passed to `pvnctl` earlier
version: gcp-service-account-key-json-0 # this should be the version string returned from `pvnctl` earlier
project: GCP_PROJECT
region: REGION
Alternative Authentication Methods Available
You can customize how you pass credentials to the Google Cloud Run Runtime, including by manually creating a Kubernetes Secret so that the credentials never leave your environment. See docs.
Apply the config file to create the Google Cloud Run Runtime.
pvnctl configs apply my-cloud-run-runtime.pvn.yaml
You should repeat this step once for each Cloud Run project and region you want to deploy to, giving each of them a unique Runtime name.
3. Create an Application
Create a new Application that uses your Google Cloud Run Runtime, by creating a new config file.
application:
name: my-application # can be whatever you want
releaseChannels:
- name: staging
runtimes:
- runtime: my-cloud-run-runtime # need to match the Runtime name you picked earlier
Apply the config file to create the Application.
pvnctl configs apply my-application.pvn.yaml
If you have more than one Google Cloud Run Runtime, you can deploy your Application across multiple Release Channels and order them. For example:
application:
name: my-application
releaseChannels:
- name: us-east
runtimes:
- runtime: cloud-run-us-east
- name: us-west
runtimes:
- runtime: cloud-run-us-west
preconditions:
- releaseChannelStable:
releaseChannel: us-west
- manualApproval: {}
You can also use the same runtime across Release Channels, as long as you take care to avoid name collision on the Service definition. This tutorial will show you how to do that in the next step.
application:
name: my-application
releaseChannels:
- name: staging
runtimes:
- runtime: my-cloud-run-runtime
- name: produdction
runtimes:
- runtime: cloud-run-us-west
preconditions:
- releaseChannelStable:
releaseChannel: staging
- manualApproval: {}
4. Create a Cloud Run Service Spec
Create a Cloud Run Service specification.
If you have an existing Cloud Run Service, you can use gcloud run services describe SERVICE --format yaml > service.yaml
.
Here is an example of a simple spec:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: "NAME"
spec:
template:
spec:
containers:
- image: "IMAGE"
If you are using the same Service spec for multiple Release Channels on the same Runtime, you will need to make sure there are no name collision. One way to accomplish that is to rely on template variables.
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: "NAME-{{.Builtins.ReleaseChannel.Name}}"
spec:
template:
spec:
containers:
- image: "IMAGE"
For the full list of variables available, see Configuring Services.
5. Create a Prodvana Service
Create a Prodvana Service by creating a new config file:
service:
name: my-service
application: my-application # needs to match the Application name you picked earlier
googleCloudRun:
local:
path: service.yaml # relative path to the Service specification YAML you made earlier
Apply the config file to create the Service.
pvnctl configs apply my-service.pvn.yaml
6. Deploy Your Service
Go to my-demo-organization.runprodvana.com -> your Application name -> your Service name, and click "Manage Release" -> "Create a New Release". Prodvana will deploy your Cloud Run Service, creating it if needed. If there are issues with your configuration or credentials, Prodvana will display an error.
Congratulations! You have deployed your first Cloud Run Service with Prodvana.
7. Parametrize the Docker Image
Optional
This step shows how you can parametrize the Docker image, allowing the image to be changed without having to edit the Cloud Run Service specification YAML. If you'd like a full gitops workflow where everything is checked in to code, you can skip this step.
You can use a Docker image parameter to refer to your image.
First, link your repository integration to Prodvana. For example, to link a Google Artifact Registry repository, see Artifact Registry (AR).
Next, modify your Prodvana Service config file:
service:
name: my-service
application: my-application
googleCloudRun: ... # unchanged from before
parameters:
- name: image
required: true
dockerImage:
imageRegistryInfo:
containerRegistry: YOUR_REGISTRY_INTEGRATION_NAME
imageRepository: REPOSITORY # this is the part of the Docker image url after the domain. For example, for `us-central1-docker.pkg.dev/my-project/foo/bar:`, it is `my-project/foo/bar`
You can now use the image
parameter in your Cloud Run Service YAML
apiVersion: serving.knative.dev/v1
kind: Service
metadata: ... # unchanged
spec:
template:
spec:
containers:
- image: "{{.Params.image}}"
There are a number of other variables available, including builtin ones. See Configuring Services.
Apply the config file to pick up the change.
pvnctl configs apply my-service.pvn.yaml
Now go to the Prodvana UI, at my-demo-organization.runprodvana.com -> your Application -> your Service, click on "Manage Release" -> "Create a New Release". Click "Edit" to pick up the new config file and you will see the option to specify the image parameter value.
Updated 12 months ago