Skip to content

Commit 31dd087

Browse files
jsimonwebchingor13
andauthored
Update Cloud SQL for SQL Server sample app w/ Kubernetes Engine files. (GoogleCloudPlatform#2494)
* Update Cloud SQL for SQL Server sample app w/ Kubernetes Engine * Update cloud-sql/sqlserver/mssql/service.yaml Co-authored-by: Jeff Ching <chingor@google.com> * Update cloud-sql/sqlserver/mssql/service-account.yaml Co-authored-by: Jeff Ching <chingor@google.com> * Address review comments. * Update cloud-sql/sqlserver/mssql/Dockerfile Co-authored-by: Jeff Ching <chingor@google.com> Co-authored-by: Jeff Ching <chingor@google.com>
1 parent 983eddc commit 31dd087

4 files changed

Lines changed: 169 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2022 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+
# Use the official lightweight Node.js 14 image.
16+
17+
# https://hub.docker.com/_/node
18+
FROM node:14-slim
19+
20+
# Create and change to the app directory.
21+
WORKDIR /app
22+
23+
# Copy application dependency manifests to the container image.
24+
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
25+
# Copying this separately prevents re-running npm install on every code change.
26+
COPY package*.json ./
27+
28+
# Install dependencies.
29+
# If you add a package-lock.json speed your build by switching to 'npm ci'.
30+
# RUN npm ci --only=production
31+
RUN npm install --production
32+
33+
# Copy local code to the container image.
34+
COPY . ./
35+
36+
# Run the web service on container startup.
37+
CMD [ "npm", "start" ]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copyright 2022 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 cloud_sql_sqlserver_mssql_gke_quickstart_deployment]
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
name: gke-cloud-sql-quickstart
20+
spec:
21+
selector:
22+
matchLabels:
23+
app: gke-cloud-sql-app
24+
template:
25+
metadata:
26+
labels:
27+
app: gke-cloud-sql-app
28+
spec:
29+
serviceAccountName: <YOUR-KSA-NAME>
30+
containers:
31+
- name: gke-cloud-sql-app
32+
# Replace <LOCATION> with your Artifact Registry location (e.g., us-central1).
33+
# Replace <YOUR_PROJECT_ID> with your project ID.
34+
image: <LOCATION>-docker.pkg.dev/<YOUR_PROJECT_ID>/gke-cloud-sql-repo/gke-sql:latest
35+
# This app listens on port 8080 for web traffic by default.
36+
ports:
37+
- containerPort: 8080
38+
env:
39+
- name: PORT
40+
value: "8080"
41+
- name: DB_HOST
42+
value: "127.0.0.1"
43+
- name: DB_PORT
44+
value: "1433"
45+
- name: DB_USER
46+
valueFrom:
47+
secretKeyRef:
48+
name: <YOUR-DB-SECRET>
49+
key: username
50+
- name: DB_PASS
51+
valueFrom:
52+
secretKeyRef:
53+
name: <YOUR-DB-SECRET>
54+
key: password
55+
- name: DB_NAME
56+
valueFrom:
57+
secretKeyRef:
58+
name: <YOUR-DB-SECRET>
59+
key: database
60+
- name: cloud-sql-proxy
61+
# This uses the latest version of the Cloud SQL proxy
62+
# It is recommended to use a specific version for production environments.
63+
# See: https://github.com/GoogleCloudPlatform/cloudsql-proxy
64+
image: gcr.io/cloudsql-docker/gce-proxy:latest
65+
command:
66+
- "/cloud_sql_proxy"
67+
68+
# If connecting from a VPC-native GKE cluster, you can use the
69+
# following flag to have the proxy connect over private IP
70+
# - "-ip_address_types=PRIVATE"
71+
72+
# tcp should be set to the port the proxy should listen on
73+
# and should match the DB_PORT value set above.
74+
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
75+
- "-instances=<INSTANCE_CONNECTION_NAME>=tcp:1433"
76+
securityContext:
77+
# The default Cloud SQL proxy image runs as the
78+
# "nonroot" user and group (uid: 65532) by default.
79+
runAsNonRoot: true
80+
# [END cloud_sql_sqlserver_mssql_gke_quickstart_deployment]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2022 Google LLC
2+
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+
16+
# [START cloud_sql_sqlserver_mssql_gke_quickstart_sa]
17+
apiVersion: v1
18+
kind: ServiceAccount
19+
metadata:
20+
name: <YOUR-KSA-NAME> # TODO(developer): replace this value
21+
# [END cloud_sql_sqlserver_mssql_gke_quickstart_sa]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2022 Google LLC
2+
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+
16+
# [START cloud_sql_sqlserver_mssql_gke_quickstart_service]
17+
# The service provides a load-balancing proxy over the gke-cloud-sql-app
18+
# pods. By specifying the type as a 'LoadBalancer', Kubernetes Engine will
19+
# create an external HTTP load balancer.
20+
apiVersion: v1
21+
kind: Service
22+
metadata:
23+
name: gke-cloud-sql-app
24+
spec:
25+
type: LoadBalancer
26+
selector:
27+
app: gke-cloud-sql-app
28+
ports:
29+
- port: 80
30+
targetPort: 8080
31+
# [END cloud_sql_sqlserver_mssql_gke_quickstart_service]

0 commit comments

Comments
 (0)