N Implementation Guide
N Implementation Guide
1
Table of Contents
Introduction 3
Configuration Details 3
Implementation Details 3
Service Name & Revision Name 5
Traffic Split 5
Deleting Active Server Group 5
Testing 6
Service Creation 7
Second Revision Creation 11
Spitting Traffic between the Revisions 13
Deleting a Revision 14
Deleting a Service 17
Service Creation thru Artifact 18
Sample Cloudrun Deployment Pipeline 22
2
Introduction
This document is intended to provide details of the implementation changes that are added
to the Spinnaker code base, in order to support Google Cloud Run as a cloud provider.
Configuration Details
The following configuration details need to be added in the clouddriver-local.yml file before
proceeding with the implementation.
cloudrun:
enabled: true
accounts:
- name: my-cloudrun-account
requiredGroupMembership: []
permissions: {}
project: my-orbit-project-71824
jsonPath: /home/ubuntu/.gcp/my-orbit-project-71824-ce91bf940a59.json
Implementation Details
The following Spinnaker microservices have been modified to support Cloud Run.
● Cloud driver
● Orca
● Halyard
● Deck
Cloud Run deployment includes Service and Revision components.The following table
represents the mapping between CloudRun and Spinnaker resources:
3
Instance Cloud Run Container Instance
In Spinnaker, a user can create a Server Group from the CLUSTERS pane by clicking the
Create Server Group button. Similarly, a Load Balancer can be created from the LOAD
BALANCERS pane. But, as in Google App engine, the load balancer (Cloud Run Service)
cannot be created without a Cloud Run Revision. So, Create Server Group action leads to
the creation of Cloud Run Service and Revision.
A service yaml needs to be added in the Service Yaml text box that appears when the
Create Server Group button is clicked. When the Create button is clicked, a series of
actions take place resulting in the creation of Cloud Run Service and Revision resources in
the Google Cloud and display of the information related to these resources in the Spinnaker
UI.
After creating the server group, the load balancer gets displayed with service details and
options such as
4
Service Name & Revision Name
The Service name & Revision names are managed by Spinnaker irrespective of their values
in the Service Yaml. This helps Spinnaker to manage the segregation of server groups and
clusters. So any other names given to the service and revision in the Service yaml will be
overridden by Spinnaker using the Account name, Stack and Detail field values.
Traffic Split
There is a section in the Service yaml for representing traffic split but as part of this
implementation we are ignoring the section because the user needs to know the existing
traffic routing in order to change it. And if a user doesn’t add the traffic section in the Service
yaml, a gcloud command will route 100% traffic to the newly created revision which is not
needed. Hence the better way is to preserve the existing traffic split until the user performs
an explicit split using Edit Load Balancer action to route some or total percentage of traffic
to the newly created Revision.
5
Testing
Apart from the unit test cases, the following manual tests have been done in the
development environment.
● Service Creation
● Second Revision Creation
● Spitting Traffic between the Revisions
● Deleting a Revision
● Deleting a Service
● Service Creation thru Artifact
The Service Account requires permissions to deploy the CloudRun Services. A Service
Account credentials key(a json file) is added in Spinnaker in the form of cloudrun account as
given below:
cloudrun:
enabled: true
accounts:
- name: my-cloudrun-account
requiredGroupMembership: []
permissions: {}
project: my-orbit-project-71824
jsonPath:
/home/ubuntu/.gcp/my-orbit-project-71824-ce91bf940a59.json
6
Service Creation
● Create an application in Spinnaker - cloudrunsvc.
● Enter the values in the Stack and Detail fields.
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: cloudrunsvc
namespace: '135005621049'
labels:
cloud.googleapis.com/location: us-central1
annotations:
run.googleapis.com/client-name: cloud-console
serving.knative.dev/creator:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
serving.knative.dev/lastModifier:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
client.knative.dev/user-image:
us-docker.pkg.dev/cloudrun/container/hello
run.googleapis.com/ingress: all
run.googleapis.com/ingress-status: all
spec:
7
template:
metadata:
name: cloudrunsvc-hkb-v001
annotations:
run.googleapis.com/client-name: cloud-console
autoscaling.knative.dev/minScale: '1'
autoscaling.knative.dev/maxScale: '3'
spec:
containerConcurrency: 80
timeoutSeconds: 200
serviceAccountName:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
containers:
- image: us-docker.pkg.dev/cloudrun/container/hello
ports:
- name: http1
containerPort: 8080
resources:
limits:
cpu: 1000m
memory: 256Mi
● Verify that the Service and Revision are created in the cloud.
8
9
● Verify if the load balancer and server group are created.
10
Second Revision Creation
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: cloudrunsvc
namespace: '135005621049'
labels:
cloud.googleapis.com/location: us-central1
annotations:
run.googleapis.com/client-name: cloud-console
serving.knative.dev/creator:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
serving.knative.dev/lastModifier:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
client.knative.dev/user-image:
us-docker.pkg.dev/cloudrun/container/hello
run.googleapis.com/ingress: all
run.googleapis.com/ingress-status: all
spec:
template:
metadata:
name: cloudrunsvc-hkb-v002
annotations:
run.googleapis.com/client-name: cloud-console
autoscaling.knative.dev/minScale: '1'
autoscaling.knative.dev/maxScale: '3'
spec:
containerConcurrency: 80
timeoutSeconds: 200
serviceAccountName:
spinnaker-cloudrun-account@my-orbit-project-71824.iam.gserviceaccount.com
containers:
- image: us-docker.pkg.dev/cloudrun/container/hello
ports:
- name: http1
containerPort: 8080
resources:
limits:
cpu: 1000m
memory: 256Mi
11
2. Verify if the second revision is created.
12
Spitting Traffic between the Revisions
2. Allocate traffic between the two revisions equally and click Update.
13
4. Verify if the Load Balancers details are updated with the latest traffic split.
Deleting a Revision
1. Select a Server Group having zero traffic and click Destroy. Before this step, another
version was created and traffic was split between the latest two revisions(v002 &
v001).
14
2. Verify that the deletion is successful.
15
3. Also, verify that the Revision is deleted from the Cloud.
16
Deleting a Service
1. Select the service that you need to delete and click Delete Load Balancer.
3. Once confirming the deletion, verify that the delete operation is successful in
Spinnaker.
17
4. Also, verify if the Service is deleted from the cloud.
18
19
4. Add the Deploy(Cloudrun) stage to the existing pipeline and enter the values in the
Stack and Detail fields as shown in the screenshot below.
20
7. Verify that the service(googletestcase001-s1-d1) is created successfully.
21
To know more about artifacts, refer to the below spinnaker documentation.
1. https://spinnaker.io/docs/reference/ref-artifacts/types/
2. https://spinnaker.io/docs/setup/other_config/artifacts/
22
● Wait - before destroying the old server group 2 minutes of wait time is
followed, to be sure everything is OK. In a real deployment pipeline, it’s likely
that this wait time would be longer (an hour or more).
● Destroy - the old server group is destroyed.
https://spinnaker.io/docs/guides/tutorials/codelabs/appengine-source-to-prod/
23