Debian Codegraph @

examples/k8s-sidecar/proxy_with_sa_key.yaml

raw
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 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18 name: <YOUR-DEPLOYMENT-NAME>
19 spec:
20 selector:
21 matchLabels:
22 app: <YOUR-APPLICATION-NAME>
23 template:
24 metadata:
25 labels:
26 app: <YOUR-APPLICATION-NAME>
27 spec:
28 containers:
29 - name: <YOUR-APPLICATION-NAME>
30 # ... other container configuration
31 env:
32 - name: DB_USER
33 valueFrom:
34 secretKeyRef:
35 name: <YOUR-DB-SECRET>
36 key: username
37 - name: DB_PASS
38 valueFrom:
39 secretKeyRef:
40 name: <YOUR-DB-SECRET>
41 key: password
42 - name: DB_NAME
43 valueFrom:
44 secretKeyRef:
45 name: <YOUR-DB-SECRET>
46 key: database
47 - name: cloud-sql-proxy
48 # It is recommended to use the latest version of the Cloud SQL proxy
49 # Make sure to update on a regular schedule!
50 image: gcr.io/cloudsql-docker/gce-proxy:1.28.0 # make sure the use the latest version
51 command:
52 - "/cloud_sql_proxy"
53
54 # If connecting from a VPC-native GKE cluster, you can use the
55 # following flag to have the proxy connect over private IP
56 # - "-ip_address_types=PRIVATE"
57
58 # By default, the proxy will write all logs to stderr. In some
59 # environments, anything printed to stderr is considered an error. To
60 # disable this behavior and write all logs to stdout (except errors
61 # which will still go to stderr), use:
62 - "-log_debug_stdout"
63
64 # Replace DB_PORT with the port the proxy should listen on
65 # Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
66 - "-instances=<INSTANCE_CONNECTION_NAME>=tcp:<DB_PORT>"
67
68 # [START cloud_sql_proxy_k8s_volume_mount]
69 # This flag specifies where the service account key can be found
70 - "-credential_file=/secrets/service_account.json"
71 securityContext:
72 # The default Cloud SQL proxy image runs as the
73 # "nonroot" user and group (uid: 65532) by default.
74 runAsNonRoot: true
75 volumeMounts:
76 - name: <YOUR-SA-SECRET-VOLUME>
77 mountPath: /secrets/
78 readOnly: true
79 # [END cloud_sql_proxy_k8s_volume_mount]
80 # Resource configuration depends on an application's requirements. You
81 # should adjust the following values based on what your application
82 # needs. For details, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
83 resources:
84 requests:
85 # The proxy's memory use scales linearly with the number of active
86 # connections. Fewer open connections will use less memory. Adjust
87 # this value based on your application's requirements.
88 memory: "2Gi"
89 # The proxy's CPU use scales linearly with the amount of IO between
90 # the database and the application. Adjust this value based on your
91 # application's requirements.
92 cpu: "1"
93 # [START cloud_sql_proxy_k8s_volume_secret]
94 volumes:
95 - name: <YOUR-SA-SECRET-VOLUME>
96 secret:
97 secretName: <YOUR-SA-SECRET>
98 # [END cloud_sql_proxy_k8s_volume_secret]