Skip to content

Commit b1b6b4d

Browse files
authored
Update Cloud SQL sample apps with Kubernetes Engine yaml files. (GoogleCloudPlatform#6365)
* Update Cloud SQL sample apps w/ Kubernetes Engine * Add license.
1 parent afa1cf5 commit b1b6b4d

File tree

6 files changed

+224
-0
lines changed

6 files changed

+224
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright 2021 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_mysql_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+
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: INSTANCE_CONNECTION_NAME
42+
value: <INSTANCE_CONNECTION_NAME>
43+
- name: DB_HOST
44+
value: "127.0.0.1"
45+
- name: DB_PORT
46+
value: "3306"
47+
- name: DB_USER
48+
valueFrom:
49+
secretKeyRef:
50+
name: <YOUR-DB-SECRET>
51+
key: username
52+
- name: DB_PASS
53+
valueFrom:
54+
secretKeyRef:
55+
name: <YOUR-DB-SECRET>
56+
key: password
57+
- name: DB_NAME
58+
valueFrom:
59+
secretKeyRef:
60+
name: <YOUR-DB-SECRET>
61+
key: database
62+
# [END cloud_sql_mysql_java_gke_quickstart_deployment]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2021 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_mysql_java_gke_quickstart_sa]
16+
apiVersion: v1
17+
kind: ServiceAccount
18+
metadata:
19+
name: <YOUR-KSA-NAME> # TODO(developer): replace this value.
20+
# [END cloud_sql_mysql_java_gke_quickstart_sa]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2021 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_mysql_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_mysql_java_gke_quickstart_service]
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright 2021 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_postgres_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+
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: INSTANCE_CONNECTION_NAME
42+
value: <INSTANCE_CONNECTION_NAME>
43+
- name: DB_HOST
44+
value: "127.0.0.1"
45+
- name: DB_PORT
46+
value: "5432"
47+
- name: DB_USER
48+
valueFrom:
49+
secretKeyRef:
50+
name: <YOUR-DB-SECRET>
51+
key: username
52+
- name: DB_PASS
53+
valueFrom:
54+
secretKeyRef:
55+
name: <YOUR-DB-SECRET>
56+
key: password
57+
- name: DB_NAME
58+
valueFrom:
59+
secretKeyRef:
60+
name: <YOUR-DB-SECRET>
61+
key: database
62+
# [END cloud_sql_postgres_java_gke_quickstart_deployment]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2021 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_postgres_java_gke_quickstart_sa]
16+
apiVersion: v1
17+
kind: ServiceAccount
18+
metadata:
19+
name: <YOUR-KSA-NAME> # TODO(developer): replace this value.
20+
# [END cloud_sql_postgres_java_gke_quickstart_sa]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2021 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_postgres_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_postgres_java_gke_quickstart_service]

0 commit comments

Comments
 (0)