Skip to content

Commit 2e9c845

Browse files
authored
Update Cloud SQL for SQL Server sample app w/ Kubernetes Engine (GoogleCloudPlatform#6696)
1 parent dd70907 commit 2e9c845

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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_java_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+
# For more information about using Kubernetes service accounts see:
30+
# https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts
31+
serviceAccountName: <YOUR-KSA-NAME> # TODO(developer): replace this value.
32+
containers:
33+
- name: gke-cloud-sql-app
34+
# Replace <LOCATION> with your Artifact Registry location (e.g., us-central1).
35+
# Replace <YOUR_PROJECT_ID> with your project ID.
36+
image: <LOCATION>-docker.pkg.dev/<YOUR_PROJECT_ID>/gke-cloud-sql-repo/gke-sql:latest
37+
# This app listens on port 8080 for web traffic by default.
38+
ports:
39+
- containerPort: 8080
40+
env:
41+
- name: PORT
42+
value: "8080"
43+
- name: INSTANCE_CONNECTION_NAME
44+
value: <INSTANCE_CONNECTION_NAME>
45+
- name: DB_HOST
46+
value: "127.0.0.1"
47+
- name: DB_PORT
48+
value: "1433"
49+
- name: DB_USER
50+
valueFrom:
51+
secretKeyRef:
52+
name: <YOUR-DB-SECRET>
53+
key: username
54+
- name: DB_PASS
55+
valueFrom:
56+
secretKeyRef:
57+
name: <YOUR-DB-SECRET>
58+
key: password
59+
- name: DB_NAME
60+
valueFrom:
61+
secretKeyRef:
62+
name: <YOUR-DB-SECRET>
63+
key: database
64+
# [END cloud_sql_sqlserver_java_gke_quickstart_deployment]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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_java_gke_quickstart_sa]
16+
apiVersion: v1
17+
kind: ServiceAccount
18+
metadata:
19+
# For more information about using Kubernetes service accounts see:
20+
# https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts
21+
name: <YOUR-KSA-NAME> # TODO(developer): replace this value.
22+
# [END cloud_sql_sqlserver_java_gke_quickstart_sa]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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_java_gke_quickstart_service]
16+
# The service provides a load-balancing proxy over the gke-cloud-sql-app
17+
# pods. By specifying the type as a 'LoadBalancer', Kubernetes Engine will
18+
# create an external HTTP load balancer.
19+
apiVersion: v1
20+
kind: Service
21+
metadata:
22+
name: gke-cloud-sql-app
23+
spec:
24+
type: LoadBalancer
25+
selector:
26+
app: gke-cloud-sql-app
27+
ports:
28+
- port: 80
29+
targetPort: 8080
30+
# [END cloud_sql_sqlserver_java_gke_quickstart_service]

0 commit comments

Comments
 (0)