Skip to content
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

feat(runjob): add support for cloud_sql_instance #1688

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,49 @@ spec:
description: A list of Volumes to make available to containers.
items:
properties:
cloudSqlInstance:
description: For Cloud SQL volumes, contains the specific
instances that should be mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run
for more information on how to connect Cloud SQL and
Cloud Run.
properties:
instanceRefs:
items:
description: 'The Cloud SQL instance connection
names, as can be found in https://console.cloud.google.com/sql/instances.
Visit https://cloud.google.com/sql/docs/mysql/connect-run
for more information on how to connect Cloud
SQL and Cloud Run. Format: {project}:{location}:{instance}'
oneOf:
- not:
required:
- external
required:
- name
- not:
anyOf:
- required:
- name
- required:
- namespace
required:
- external
properties:
external:
description: 'Allowed value: The `connectionName`
field of a `SQLInstance` resource.'
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More
info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
type: object
type: array
type: object
emptyDir:
description: Ephemeral storage used as a shared volume.
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: run.cnrm.cloud.google.com/v1beta1
kind: RunJob
metadata:
name: runjob-sample-sql
spec:
launchStage: "GA"
location: "us-central1"
projectRef:
external: ${PROJECT_ID?}
template:
template:
containers:
- image: "us-docker.pkg.dev/cloudrun/container/hello"
volumeMounts:
- name: "cloudsql"
mountPath: "/cloudsql"
volumes:
- name: "cloudsql"
cloudSqlInstance:
instanceRefs:
- name: runjob-dep-sql
lifecycle:
ignore_changes:
- launch_stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
metadata:
name: runjob-dep-sql
spec:
region: us-central1
databaseVersion: MYSQL_5_7
settings:
tier: db-n1-standard-1
10 changes: 9 additions & 1 deletion config/servicemappings/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ spec:
- observed_generation
- labels
- template.labels
- template.template.volumes.cloud_sql_instance
iamConfig:
policyName: google_cloud_run_v2_job_iam_policy
policyMemberName: google_cloud_run_v2_job_iam_member
Expand Down Expand Up @@ -84,6 +83,15 @@ spec:
kind: IAMServiceAccount
version: v1beta1
group: iam.cnrm.cloud.google.com
- tfField: template.template.volumes.cloud_sql_instance.instances
description: |-
The Cloud SQL instance connection names, as can be found in https://console.cloud.google.com/sql/instances. Visit https://cloud.google.com/sql/docs/mysql/connect-run for more information on how to connect Cloud SQL and Cloud Run. Format: {project}:{location}:{instance}
key: instanceRefs
targetField: connection_name
gvk:
kind: SQLInstance
version: v1beta1
group: sql.cnrm.cloud.google.com
- tfField: template.template.volumes.secret.secret
description: |-
The name of the secret in Cloud Secret Manager. Format: {secret} if the secret is in the same project. projects/{project}/secrets/{secret} if the secret is in a different project.
Expand Down
43 changes: 43 additions & 0 deletions crds/run_v1beta1_runjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,49 @@ spec:
description: A list of Volumes to make available to containers.
items:
properties:
cloudSqlInstance:
description: For Cloud SQL volumes, contains the specific
instances that should be mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run
for more information on how to connect Cloud SQL and Cloud
Run.
properties:
instances:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this file is generated and field name should be updated to instanceRefs as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I missed it running make manifests, fixed with 26dbc18

items:
description: 'The Cloud SQL instance connection names,
as can be found in https://console.cloud.google.com/sql/instances.
Visit https://cloud.google.com/sql/docs/mysql/connect-run
for more information on how to connect Cloud SQL
and Cloud Run. Format: {project}:{location}:{instance}'
oneOf:
- not:
required:
- external
required:
- name
- not:
anyOf:
- required:
- name
- required:
- namespace
required:
- external
properties:
external:
description: 'Allowed value: The `connectionName`
field of a `SQLInstance` resource.'
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
namespace:
description: 'Namespace of the referent. More
info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
type: string
type: object
type: array
type: object
emptyDir:
description: Ephemeral storage used as a shared volume.
properties:
Expand Down
9 changes: 9 additions & 0 deletions pkg/clients/generated/apis/run/v1beta1/runjob_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions pkg/clients/generated/apis/run/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: run.cnrm.cloud.google.com/v1beta1
kind: RunJob
metadata:
name: runjob-${uniqueId}
spec:
launchStage: "GA"
location: "us-central1"
projectRef:
external: "${projectId}"
template:
template:
volumes:
- name: "cloudsql"
cloudSqlInstance:
instanceRefs:
- name: sqlinstance-1-${uniqueId}
containers:
- image: "us-docker.pkg.dev/cloudrun/container/hello"
volumeMounts:
- name: "cloudsql"
mountPath: "/cloudsql"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
metadata:
name: sqlinstance-1-${uniqueId}
spec:
region: us-central1
databaseVersion: MYSQL_5_7
settings:
tier: db-n1-standard-1
---
apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
metadata:
name: sqlinstance-2-${uniqueId}
spec:
region: us-central1
databaseVersion: MYSQL_5_7
settings:
tier: db-n1-standard-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: run.cnrm.cloud.google.com/v1beta1
kind: RunJob
metadata:
name: runjob-${uniqueId}
spec:
launchStage: "GA"
location: "us-central1"
projectRef:
external: "${projectId}"
template:
template:
volumes:
- name: "cloudsql"
cloudSqlInstance:
instanceRefs:
- name: sqlinstance-1-${uniqueId}
- name: sqlinstance-2-${uniqueId}
containers:
- name: "container-name"
image: "us-docker.pkg.dev/cloudrun/container/hello"
volumeMounts:
- name: "cloudsql"
mountPath: "/cloudsql-new-path"
Loading
Loading