-
Notifications
You must be signed in to change notification settings - Fork 6
Introduce a cloud-deploy-pipelines skill #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa2b52d
Introduce a cloud-deploy-pipeline-designer skill that guides users th…
mattsanta d6f9724
Address typos and lint issues
mattsanta e93ea18
One more missing new line
mattsanta 327ebe4
Update skill to be Cloud Deploy generic and add release management se…
mattsanta 3d200a5
Update SKILL.md based on PR feedback
mattsanta b849cc5
Add use-case to each subsection in Release Management
mattsanta d7475a4
Merge branch 'gemini-cli-extensions:main' into main
mattsanta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| --- | ||
| name: cloud-deploy-pipelines | ||
| description: > | ||
| Design Cloud Deploy delivery pipelines and manage releases when deploying applications to Cloud Run and Google Kubernetes Engine (GKE). Use when users want to deploy their applications to multiple environments (e.g. dev and prod), leverage deployment strategies (i.e. canary), or rollback (manually or automatically) when there are issues deploying their application. | ||
| --- | ||
|
|
||
| # Cloud Deploy Pipelines | ||
|
|
||
| ## Overview | ||
|
|
||
| This skill encompasses the entire lifecycle of Cloud Deploy for a user, from designing and creating delivery pipelines to managing releases and debugging release failures. | ||
|
|
||
| ## Workflow: Designing a Pipeline | ||
|
|
||
| This workflow provides steps for designing a Cloud Deploy `DeliveryPipeline`. | ||
|
|
||
| ### Constraints & Rules | ||
|
|
||
| 1. **NO PLACEHOLDERS**: Never generate YAML with placeholders like `<PROJECT_ID>`. Ask the user for values first. | ||
| 2. **Context First**: Always check existing files and conversation context before asking. | ||
| 3. **Step-by-Step**: Perform the steps one at a time. The goal is to guide the user through designing a delivery pipeline. | ||
|
|
||
| ### Step 0: Prerequisites | ||
|
|
||
| **Required Context**: Before generating ANY configuration for this workflow, you **MUST** have the following values. Ask the user strictly for any missing information: | ||
| - **Project ID**: The Google Cloud project ID for the Cloud Deploy resources. | ||
| - **Region**: The region for the Cloud Deploy resources (e.g., `us-central1`). | ||
| - **Application Name**: The name of the application that will be deployed. Use the application name to generate the names of the Cloud Deploy resources, such as `DeliveryPipeline` and `Target` resources. | ||
| - **Runtime**: Either Cloud Run or Google Kubernetes Engine (GKE). | ||
| - **If Cloud Run**: The Cloud Run project and location. | ||
| - **If GKE**: The GKE cluster name. | ||
|
|
||
| ### Step 1: Define the target environments | ||
|
|
||
| 1. Identify the number of deployment environments (e.g., dev, staging, production). | ||
| 2. Identify if promotions should require user approval. | ||
| 3. Define each of the deployment environments as Cloud Deploy `Target` resources in a `clouddeploy.yaml` file. | ||
| - Use `references/configure-targets.md` as a reference when generating the resource YAML. | ||
| - Use the application name provided by the user when naming the Cloud Deploy `Target` resources. For example, if the user wants to deploy an application named "hello-world" to a test and production environment then use "hello-world-test" and "hello-world-prod" as the `Target` IDs. | ||
|
|
||
| ### Step 2: Define the delivery pipeline | ||
|
|
||
| 1. Identify whether the user wants to use a canary deployment strategy for any of the target environments. | ||
| 2. Define the Cloud Deploy `DeliveryPipeline` in the `clouddeploy.yaml` file. | ||
| - Use `references/configure-pipelines.md` as a reference when generating the resource YAML. | ||
| - Use application name as the `DeliveryPipeline` ID. | ||
|
|
||
| ### Step 3: Define automations | ||
|
|
||
| 1. Identify whether the user wants to automatically rollback if any failures occur during the rollout. | ||
| 2. **If the user specified multiple deployment environments in the previous step** | ||
| - Identify if they want automatic promotions between deployment environments. | ||
| 3. **If the user specified a canary deployment strategy in the previous step** | ||
| - Identify if they want to automatically advance the rollout through the phases after a wait period. | ||
| 4. Define the Cloud Deploy `Automation` resources in the `clouddeploy.yaml` file. | ||
| - Use `references/configure-automations.md` as a reference when generating the resource YAML. | ||
|
|
||
| ### Step 4: Validate the clouddeploy.yaml file | ||
|
|
||
| Ensure that the `clouddeploy.yaml` file is valid. See https://docs.cloud.google.com/deploy/docs/config-files for the schema. | ||
|
|
||
| ### Step 5: Create the delivery pipeline | ||
|
|
||
| Run the following command to create the Cloud Deploy `DeliveryPipeline` and associated resources, using the values collected in Step 0: | ||
|
|
||
| ```bash | ||
| gcloud deploy apply --file=clouddeploy.yaml --region=<REGION> --project=<PROJECT_ID> | ||
| ``` | ||
|
|
||
| ### Step 6: Create a skaffold.yaml file and runtime manifests | ||
|
|
||
| **Required Context**: Before generating a `skaffold.yaml` file, you **MUST** know if the user has manifests for the runtime they are deploying to. | ||
|
|
||
| 1. **If the user does not have runtime manifests**: Generate some basic ones based on the runtime. | ||
| - **If Cloud Run**: Generate a Cloud Run manifest. Use `references/basic-cloudrun-manifests.md` as a reference. | ||
| - **If GKE**: Generate a Kubernetes `Deployment` and `Service`manifest. Use `references/basic-k8s-manifests.md` as a reference. | ||
| 2. Create a `skaffold.yaml` file required to create a Cloud Deploy `Release` for the `DeliveryPipeline`. | ||
| - Use `references/configure-skaffold.md` as a reference when generating the `skaffold.yaml` file. | ||
|
|
||
| ## Release Management | ||
mattsanta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| This section covers the various aspects of managing Cloud Deploy `Release` resources. | ||
haroonc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Constraints & Rules | ||
|
|
||
| In order to manage releases, a `DeliveryPipeline` MUST already be defined and configured in Cloud Deploy. Determine whether a delivery pipeline is defined by checking for a `clouddeploy.yaml` file and checking if the resources exist in Cloud Deploy or ask the user directly. | ||
|
|
||
| **Required Context**: | ||
| - **Project ID**: The Google Cloud project ID of the `DeliveryPipeline`. | ||
| - **Region**: The region of the `DeliveryPipeline` (e.g., `us-central1`). | ||
| - **Delivery Pipeline ID**: The `DeliveryPipeline` ID. | ||
|
|
||
| ### Create a release | ||
|
|
||
| **Use case**: The user wants to deploy a new version of their application. | ||
|
|
||
| **Required Context**: Before creating a `Release`, you **MUST** know whether the users runtime manifests are using a placeholder for the container image and the value of the placeholder. This is **CRITICAL** for build artifact substitution in Cloud Deploy. Check the users runtime manifests or ask the user directly. See examples in `references/basic-cloudrun-manifests.md` and `references/basic-k8s-manifests.md`. | ||
|
|
||
| Run the following command to create a `Release` for the `DeliveryPipeline`: | ||
|
|
||
| ```bash | ||
| gcloud deploy releases create release-$DATE-$TIME --delivery-pipeline=<DELIVERY_PIPELINE_ID> --region=<REGION> --project=<PROJECT_ID> | ||
| ``` | ||
|
|
||
| If the user is leveraging build artifact substitution with a placeholder in the image field of the runtime manifests then use the `--images` flag: | ||
|
|
||
| ```bash | ||
| gcloud deploy releases create release-$DATE-$TIME --delivery-pipeline=<DELIVERY_PIPELINE_ID> --region=<REGION> --project=<PROJECT_ID> --images <IMAGE_PLACEHOLDER>=<IMAGE_URI> | ||
| ``` | ||
|
|
||
| **CRITICAL**: If the `skaffold.yaml` is not in the current directory, use the `--source` flag to specify the directory where the `skaffold.yaml` file is located. | ||
|
|
||
| Reference documenation for `gcloud deploy releases create`: https://docs.cloud.google.com/sdk/gcloud/reference/deploy/releases/create. | ||
|
|
||
| ### Promote a release | ||
|
|
||
| **Use case**: The user wants to promote the application to the next target environment in the `DeliveryPipeline` progression sequence. | ||
|
|
||
| Run the following command to promote a `Release` to the next target in the `DeliveryPipeline` progression sequence: | ||
|
|
||
| ```bash | ||
| gcloud deploy promote --release=<RELEASE_ID> --delivery-pipeline=<DELIVERY_PIPELINE_ID> --region=<REGION> --project=<PROJECT_ID> | ||
| ``` | ||
|
|
||
| Reference documentation for `gcloud deploy releases promote`: https://docs.cloud.google.com/sdk/gcloud/reference/deploy/releases/promote. | ||
|
|
||
| ### Monitor a release | ||
|
|
||
| **Use case**: Monitor the status of a release across a `DeliveryPipeline`. | ||
|
|
||
| Monitoring a release across a `DeliveryPipeline` consists of checking the status of both the `Release` resource and its child `Rollout` resource(s). Always ensure that the `Release` has completed successfully before checking the status of the `Rollout`. | ||
|
|
||
| ### Troubleshoot | ||
|
|
||
| #### Release failed | ||
|
|
||
| Get the release to determine which of the target renders failed and inspect the failure message and failure cause. Additionally the target renders contain a Cloud Build reference where the target render was executed. Retrieve the build logs to determine the root cause of the failure. | ||
|
|
||
| #### Rollout failed | ||
|
|
||
| Get the rollout to determine which of the jobs failed and inspect the failure message and failure cause. Additionally the `Rollout` contains a Cloud Build reference where the failed job was executed. Retrieve the build logs to determine the root cause of the failure. | ||
35 changes: 35 additions & 0 deletions
35
skills/cloud-deploy-pipelines/references/basic-cloudrun-manifests.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Basic Cloud Run manifests | ||
|
|
||
| This document provides examples for generating Cloud Run resource manifests that are used with Cloud Deploy to deploy to Cloud Run. | ||
|
|
||
| The examples in this file use placeholders between `<` and `>`, e.g. `<SERVICE_NAME>`. Replace these placeholders with the actual values when generating the YAML. | ||
|
|
||
| Cloud Deploy performs build artifact substitutions on the image field so a placeholder like `app-image` is used. When a Cloud Deploy `Release` is created the user supplies the actual image and associates it with the `app-image` key. | ||
|
|
||
| ## Cloud Run Service | ||
|
|
||
| ```yaml | ||
| apiVersion: serving.knative.dev/v1 | ||
| kind: Service | ||
| metadata: | ||
| name: <SERVICE_NAME> | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - image: app-image | ||
| ``` | ||
|
|
||
| ## Cloud Run Worker Pool | ||
|
|
||
| ```yaml | ||
| apiVersion: run.googleapis.com/v1 | ||
| kind: WorkerPool | ||
| metadata: | ||
| name: <WORKER_POOL_NAME> | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - image: app-image | ||
| ``` |
49 changes: 49 additions & 0 deletions
49
skills/cloud-deploy-pipelines/references/basic-k8s-manifests.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Basic Kubernetes manifests | ||
|
|
||
| This document provides examples for generating Kubernetes `Deployment` and `Service` resource manifests that are used with Cloud Deploy to deploy to GKE. | ||
|
|
||
| The examples in this file use placeholders between `<` and `>`, e.g. `<DEPLOYMENT_NAME>`. Replace these placeholders with the actual values when generating the YAML. | ||
|
|
||
| Cloud Deploy performs build artifact substitutions on the image field so a placeholder like `app-image` is used. When a Cloud Deploy `Release` is created the user supplies the actual image and associates it with the `app-image` key. | ||
|
|
||
| ## Kubernetes Deployment | ||
|
|
||
| ```yaml | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: <DEPLOYMENT_NAME> | ||
| labels: | ||
| app: <APPLICATION_NAME> | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: <APPLICATION_NAME> | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: <APPLICATION_NAME> | ||
| spec: | ||
| containers: | ||
| - name: <APPLICATION_NAME> | ||
| image: app-image | ||
| ``` | ||
|
|
||
| ## Kubernetes Service | ||
|
|
||
| ```yaml | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: <SERVICE_NAME> | ||
| labels: | ||
| app: <APPLICATION_NAME> | ||
| spec: | ||
| selector: | ||
| app: <APPLICATION_NAME> | ||
| ports: | ||
| - protocol: TCP | ||
| port: 80 | ||
| type: LoadBalancer | ||
| ``` |
118 changes: 118 additions & 0 deletions
118
skills/cloud-deploy-pipelines/references/configure-automations.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| # Configure Automations | ||
|
|
||
| This document provides examples for configuring Cloud Deploy `Automation` resources. The examples are in YAML format and are intended to be used with the `gcloud deploy apply` command to create or update the resource. Use these examples if it fits the users requirements. | ||
|
|
||
| The examples in this file use placeholders between `<` and `>`, e.g. `<AUTOMATION_ID>`. Replace these placeholders with the actual values when generating the YAML. | ||
|
|
||
| **CRITICAL**: | ||
| - The `metadata.name` field for an `Automation` resource is made up of the `DeliveryPipeline` ID and the `Automation` ID, separated by a forward slash. For example, if the `DeliveryPipeline` ID is "hello-world" and the `Automation` ID is "promote" then the `metadata.name` field should be "hello-world/promote". | ||
| - Automations **require** a service account to run as. Use the Compute Engine default service account if the user doesn't provide one. The format is: | ||
|
|
||
| ``` | ||
| <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| ``` | ||
|
|
||
| ## Automatic Rollbacks | ||
|
|
||
| This `Automation` will rollback for any `Target` in the `DeliveryPipeline` progression sequence if the `Rollout` fails. | ||
|
|
||
| The `*` in the `selector.targets.id` field means that this `Automation` will apply to all `Target` resources in the `DeliveryPipeline`. | ||
|
|
||
| ```yaml | ||
| apiVersion: deploy.cloud.google.com/v1 | ||
| kind: Automation | ||
| metadata: | ||
| name: <PIPELINE_ID>/<AUTOMATION_ID> | ||
| serviceAccount: <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| selector: | ||
| targets: | ||
| - id: "*" | ||
| rules: | ||
| - repairRolloutRule: | ||
| id: "repair-rule" | ||
| repairPhases: | ||
| - rollback: {} | ||
| ``` | ||
|
|
||
| ## Automatic Rollbacks with Retry | ||
|
|
||
| This `Automation` will attempt to retry the failed `Rollout` job up to 3 times with a 1 minute wait between attempts. If the `Rollout` still fails after the retries then it will be rolled back. | ||
|
|
||
| ```yaml | ||
| apiVersion: deploy.cloud.google.com/v1 | ||
| kind: Automation | ||
| metadata: | ||
| name: <PIPELINE_ID>/<AUTOMATION_ID> | ||
| serviceAccount: <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| selector: | ||
| targets: | ||
| - id: "*" | ||
| rules: | ||
| - repairRolloutRule: | ||
| id: "repair-rule" | ||
| repairPhases: | ||
| - retry: | ||
| attempts: 3 | ||
| wait: 1m | ||
| - rollback: {} | ||
| ``` | ||
|
|
||
| ## Automatic Promotions on a Schedule | ||
|
|
||
| This `Automation` will automatically promote a release to the next `Target` in the `DeliveryPipeline` progression sequence every Monday at 12:00 PM New York time. | ||
|
|
||
| ```yaml | ||
| apiVersion: deploy.cloud.google.com/v1 | ||
| kind: Automation | ||
| metadata: | ||
| name: <PIPELINE_ID>/<AUTOMATION_ID> | ||
| serviceAccount: <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| selector: | ||
| targets: | ||
| - id: <FROM_TARGET_ID> | ||
| rules: | ||
| - timedPromoteReleaseRule: | ||
| id: "timed-promote-rule" | ||
| schedule: "0 12 * * 1" # Cron format. | ||
| timeZone: "America/New_York" # IANA format. | ||
| destinationTargetId: "@next" # promote to the next `Target` in the `DeliveryPipeline` progression sequence. | ||
| ``` | ||
|
|
||
| ## Automatic Promotion after a Delay | ||
|
|
||
| This `Automation` will automatically promote a release to the next `Target` in the `DeliveryPipeline` after 3 hours has passed since the release was rolled out to the previous `Target`. | ||
|
|
||
| ```yaml | ||
| apiVersion: deploy.cloud.google.com/v1 | ||
| kind: Automation | ||
| metadata: | ||
| name: <PIPELINE_ID>/<AUTOMATION_ID> | ||
| serviceAccount: <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| selector: | ||
| targets: | ||
| - id: <FROM_TARGET_ID> | ||
| rules: | ||
| - promoteReleaseRule: | ||
| id: "promote-rule" | ||
| wait: 3h | ||
| destinationTargetId: "@next" # promote to the next `Target` in the `DeliveryPipeline` progression sequence. | ||
| ``` | ||
|
|
||
| ## Automatic Canary Advance | ||
|
|
||
| This `Automation` will automatically advance through each phase of a canary `Rollout` for a specific `Target` after 1 hour has passed since the previous phase completed. | ||
|
|
||
| ```yaml | ||
| apiVersion: deploy.cloud.google.com/v1 | ||
| kind: Automation | ||
| metadata: | ||
| name: <PIPELINE_ID>/<AUTOMATION_ID> | ||
| serviceAccount: <PROJECT_NUMBER>-compute@developer.gserviceaccount.com | ||
| selector: | ||
| targets: | ||
| - id: <TARGET_ID> | ||
| rules: | ||
| - advanceRolloutRule: | ||
| id: "advance-rule" | ||
| wait: 1h | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.