Reputation: 5951
I am trying to build a release-from-main pipeline using Google's "serverless" offerings, where when something gets merged into main on GitHub, it triggers a Cloud Build (which builds, containerizes, unit tests, and pushes the image), then deploys it to a "test" environment in Cloud Deploy, which sets up a Cloud Run instance with the new build and lets me try it before promoting it to staging and prod.
I've found documentation on the Cloud Deploy->Cloud Run part, and I've found Cloud Build->Cloud Run, and I've found examples of going to GKE or raw Kubernetes, but I haven't found any examples of putting the whole chain of "serverless" offerings together.
I asked ChatGPT, which suggested I use a "kind: Rollout" deploy_config.yaml, but Google Build says "kind Rollout not supported".
Here is my cloudbuild.yaml (with the project/app names generified, and just using "latest" for now to get things going):
steps:
# Build and tag the Docker image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/my-project/my-server:latest', '.']
# Push the Docker image to Google Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/my-project/my-server:latest']
# Deploy using Cloud Deploy
- name: 'gcr.io/cloud-builders/gcloud'
args: ['deploy', 'apply', '--file=deploy_config.yaml', '--region=europe-west3']
Then my deploy_config.yaml:
apiVersion: deploy.cloud.google.com/v1
kind: Rollout
metadata:
name: api-server-rollout
namespace: default
spec:
deliveryPipeline: my-delivery-pipeline
stage: deploy-to-test
target: my-delivery-target
revision:
from:
type: PreviousRollout
artifacts:
- image: gcr.io/my-project/my-app:latest
But "Rollout" seems to be the wrong thing to do here. Can anyone point me in the right direction? Or am I misguided in this structure entirely?
Upvotes: 2
Views: 1573
Reputation: 40
Kind 'Rollout' (nor 'Release') is not supported and is not a declarative resource type of Cloud Deploy. You will instead want to create a Cloud Build trigger to create a Cloud Deploy release after creating your container(s), using gcloud deploy releases create
.
The steps would be to:
Here is some documentation, which I hope may be useful: https://cloud.google.com/deploy/docs/integrating-ci#examples_passing_a_build_artifacts_file
The "Basic Walkthrough - Cloud Run" example here also should provide a general overview of the process of connecting CI to Cloud Deploy. https://cloud.google.com/deploy/docs/tutorials
Upvotes: 2