Skip to content

Commit 5ea10ad

Browse files
authored
Merge branch 'main' into k_anonym_deidentify_cloud_storage
2 parents f6c54cd + e2bbb0c commit 5ea10ad

File tree

6 files changed

+126
-20
lines changed

6 files changed

+126
-20
lines changed

cloud-sql/mysql/mysql/deployment.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,21 @@ spec:
6161
# This uses the latest version of the Cloud SQL proxy
6262
# It is recommended to use a specific version for production environments.
6363
# See: https://github.com/GoogleCloudPlatform/cloudsql-proxy
64-
image: gcr.io/cloudsql-docker/gce-proxy:latest
65-
command:
66-
- "/cloud_sql_proxy"
67-
64+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:latest
65+
args:
6866
# If connecting from a VPC-native GKE cluster, you can use the
6967
# following flag to have the proxy connect over private IP
70-
# - "-ip_address_types=PRIVATE"
68+
# - "--private-ip"
69+
70+
# If you are not connecting with Automatic IAM, you can delete
71+
# the following flag.
72+
- "--auto-iam-authn"
7173

7274
# tcp should be set to the port the proxy should listen on
7375
# and should match the DB_PORT value set above.
7476
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
75-
- "-instances=<INSTANCE_CONNECTION_NAME>=tcp:3306"
77+
- "--port=3306"
78+
- "<INSTANCE_CONNECTION_NAME>"
7679
securityContext:
7780
# The default Cloud SQL proxy image runs as the
7881
# "nonroot" user and group (uid: 65532) by default.

cloud-sql/postgres/knex/deployment.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ spec:
3838
env:
3939
- name: PORT
4040
value: "8080"
41+
# This project uses environment variables to determine
42+
# how you would like to run your application
43+
# To use the Node.js connector (recommended) - use INSTANCE_CONNECTION_NAME (proj:region:instance)
44+
# To use TCP - Setting INSTANCE_HOST will use TCP (e.g., 127.0.0.1)
45+
# To use Unix, use INSTANCE_UNIX_SOCKET (e.g., /cloudsql/proj:region:instance)
4146
- name: INSTANCE_HOST
4247
value: "127.0.0.1"
4348
- name: DB_PORT
44-
value: "5432"
49+
value: "5432"
50+
# For Automatic IAM Authentication with the Node.js Connector
51+
# use DB_IAM_USER instead of DB_USER (recommended)
52+
# You may also remove the DB_PASS environment variable if
53+
# you use Automatic IAM Authentication
4554
- name: DB_USER
4655
valueFrom:
4756
secretKeyRef:
@@ -57,22 +66,27 @@ spec:
5766
secretKeyRef:
5867
name: <YOUR-DB-SECRET>
5968
key: database
69+
# If you are using the Node.js Connector (recommended), you can
70+
# remove cloud-sql-proxy (everything below this line)
6071
- name: cloud-sql-proxy
6172
# This uses the latest version of the Cloud SQL proxy
6273
# It is recommended to use a specific version for production environments.
6374
# See: https://github.com/GoogleCloudPlatform/cloudsql-proxy
64-
image: gcr.io/cloudsql-docker/gce-proxy:latest
65-
command:
66-
- "/cloud_sql_proxy"
67-
75+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:latest
76+
args:
6877
# If connecting from a VPC-native GKE cluster, you can use the
6978
# following flag to have the proxy connect over private IP
70-
# - "-ip_address_types=PRIVATE"
79+
# - "--private-ip"
80+
81+
# If you are not connecting with Automatic IAM, you can delete
82+
# the following flag.
83+
- "--auto-iam-authn"
7184

7285
# tcp should be set to the port the proxy should listen on
7386
# and should match the DB_PORT value set above.
7487
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
75-
- "-instances=<INSTANCE_CONNECTION_NAME>=tcp:5432"
88+
- "--port=5432"
89+
- "<INSTANCE_CONNECTION_NAME>"
7690
securityContext:
7791
# The default Cloud SQL proxy image runs as the
7892
# "nonroot" user and group (uid: 65532) by default.

cloud-sql/sqlserver/mssql/deployment.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@ spec:
6161
# This uses the latest version of the Cloud SQL proxy
6262
# It is recommended to use a specific version for production environments.
6363
# See: https://github.com/GoogleCloudPlatform/cloudsql-proxy
64-
image: gcr.io/cloudsql-docker/gce-proxy:latest
65-
command:
66-
- "/cloud_sql_proxy"
67-
64+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:latest
65+
args:
6866
# If connecting from a VPC-native GKE cluster, you can use the
6967
# following flag to have the proxy connect over private IP
70-
# - "-ip_address_types=PRIVATE"
68+
# - "--private-ip"
7169

7270
# tcp should be set to the port the proxy should listen on
7371
# and should match the DB_PORT value set above.
7472
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
75-
- "-instances=<INSTANCE_CONNECTION_NAME>=tcp:1433"
73+
- "--port=1433"
74+
- "<INSTANCE_CONNECTION_NAME>"
7675
securityContext:
7776
# The default Cloud SQL proxy image runs as the
7877
# "nonroot" user and group (uid: 65532) by default.

run/filesystem/gcsfuse.Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START cloudrun_fuse_dockerfile]
16+
17+
# Use the official Node.js image.
18+
# https://hub.docker.com/_/node
19+
FROM node:20-slim
20+
21+
# Install system dependencies
22+
RUN apt-get update && apt-get install -y \
23+
curl \
24+
gnupg \
25+
lsb-release \
26+
tini && \
27+
gcsFuseRepo=gcsfuse-`lsb_release -c -s` && \
28+
echo "deb http://packages.cloud.google.com/apt $gcsFuseRepo main" | \
29+
tee /etc/apt/sources.list.d/gcsfuse.list && \
30+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
31+
apt-key add - && \
32+
apt-get update && \
33+
apt-get install -y gcsfuse && \
34+
apt-get clean
35+
36+
# Set fallback mount directory
37+
ENV MNT_DIR /mnt/gcs
38+
39+
# Copy local code to the container image.
40+
ENV APP_HOME /app
41+
WORKDIR $APP_HOME
42+
COPY package*.json ./
43+
44+
# Install production dependencies.
45+
RUN npm install --only=production
46+
47+
# Copy local code to the container image.
48+
COPY . ./
49+
50+
# Ensure the script is executable
51+
RUN chmod +x /app/gcsfuse_run.sh
52+
53+
# Use tini to manage zombie processes and signal forwarding
54+
# https://github.com/krallin/tini
55+
ENTRYPOINT ["/usr/bin/tini", "--"]
56+
57+
# Pass the wrapper script as arguments to tini
58+
CMD ["/app/gcsfuse_run.sh"]
59+
# [END cloudrun_fuse_dockerfile]

run/filesystem/gcsfuse_run.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# [START cloudrun_fuse_script]
16+
#!/usr/bin/env bash
17+
set -eo pipefail
18+
19+
# Create mount directory for service
20+
mkdir -p $MNT_DIR
21+
22+
echo "Mounting GCS Fuse."
23+
gcsfuse --debug_gcs --debug_fuse $BUCKET $MNT_DIR
24+
echo "Mounting completed."
25+
26+
# Start the application
27+
node index.js &
28+
29+
# Exit immediately when one of the background processes terminate.
30+
wait -n
31+
# [END cloudrun_fuse_script]

run/filesystem/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mount -o nolock $FILESTORE_IP_ADDRESS:/$FILE_SHARE_NAME $MNT_DIR
2525
echo "Mounting completed."
2626

2727
# Start the application
28-
node index.js
28+
node index.js &
2929

3030
# Exit immediately when one of the background processes terminate.
3131
wait -n

0 commit comments

Comments
 (0)