| 1 |
.\" Hey, Emacs! This is an -*- nroff -*- source file. |
| 2 |
.\" Copyright (C), 2018 Google Cloud Platform |
| 3 |
.\" You may distribute this file under the terms of the GNU Free |
| 4 |
.\" Documentation License. |
| 5 |
.TH cloud_sql_proxy 1 2018-05-10 "Debian" "Debian GNU/Linux manual" |
| 6 |
.SH NAME |
| 7 |
cloud_sql_proxy \- connect securely to a 2nd generation cloud sql database |
| 8 |
.SH SYNOPSIS |
| 9 |
.B cloud_sql_proxy |
| 10 |
|
| 11 |
.SH DESCRIPTION |
| 12 |
The Cloud SQL Proxy allows simple, secure connectivity to Google Cloud |
| 13 |
SQL. It is a long-running process that opens local sockets (either TCP |
| 14 |
or Unix sockets) according to the parameters passed to it. A local |
| 15 |
application connects to a Cloud SQL instance by using the |
| 16 |
corresponding socket. |
| 17 |
.SS Authorization |
| 18 |
By default, the proxy will authenticate under the default service account |
| 19 |
of the Compute Engine VM it is running on. Therefore, the VM must have at |
| 20 |
least the sqlservice.admin |
| 21 |
.UR https://www.googleapis.com/auth/sqlservice.admin |
| 22 |
API scope |
| 23 |
.UE |
| 24 |
and the associated project must have the SQL Admin API enabled. The default |
| 25 |
service account must also have at least |
| 26 |
.B WRITER/EDITOR |
| 27 |
privileges to any projects of target SQL instances. |
| 28 |
.IP \(bu 4 |
| 29 |
On Google Compute Engine, the default service account is used. |
| 30 |
The Cloud SQL API must be enabled for the VM. |
| 31 |
.IP \(bu 4 |
| 32 |
When the gcloud command-line tool is installed on the local machine, |
| 33 |
the |
| 34 |
.I "active account" |
| 35 |
is used for authentication. Run |
| 36 |
.I 'gcloud auth list' |
| 37 |
to see which accounts are installed on your local machine and |
| 38 |
.I 'gcloud config list account' |
| 39 |
to view the active account. |
| 40 |
.IP \(bu 4 |
| 41 |
To configure the proxy using a service account, pass the |
| 42 |
.B -credential_file |
| 43 |
parameter or set the |
| 44 |
.B GOOGLE_APPLICATION_CREDENTIALS |
| 45 |
environment variable. This will override gcloud or GCE (Google |
| 46 |
Compute Engine) credentials, if they exist. |
| 47 |
.SH OPTIONS |
| 48 |
.SS General |
| 49 |
.TP |
| 50 |
.B \-quiet |
| 51 |
Disable log messages (e.g. when new connections are established). |
| 52 |
.B WARNING: |
| 53 |
this option disables ALL logging output (including connection errors), |
| 54 |
which will likely make debugging difficult. The |
| 55 |
.I -quiet |
| 56 |
flag takes precedence over the |
| 57 |
.I -verbose |
| 58 |
flag. |
| 59 |
.TP |
| 60 |
.B \-verbose |
| 61 |
When explicitly set to false, disable log messages that are not errors nor |
| 62 |
first-time startup messages (e.g. when new connections are established |
| 63 |
or closed without errors). |
| 64 |
.TP |
| 65 |
.B \-version |
| 66 |
Print the version of the proxy and exit |
| 67 |
.SS Connection |
| 68 |
.TP |
| 69 |
.B \-credential_file |
| 70 |
If provided, this json file will be used to retrieve Service Account credentials. |
| 71 |
You may set the |
| 72 |
.B GOOGLE_APPLICATION_CREDENTIALS |
| 73 |
environment variable for the same effect. |
| 74 |
.TP |
| 75 |
.B \-token |
| 76 |
When set, the proxy uses this Bearer token for authorization |
| 77 |
.TP |
| 78 |
.B \-max_connections |
| 79 |
If provided, the maximum number of connections to establish before |
| 80 |
refusing new connections. Defaults to 0 (no limit) |
| 81 |
.TP |
| 82 |
.B \-instances |
| 83 |
To connect to a specific list of instances, set the instances parameter |
| 84 |
to a comma-separated list of ully qualified instance connection strings |
| 85 |
.B (project:region:name). |
| 86 |
For example: |
| 87 |
.RS |
| 88 |
.RS |
| 89 |
\-instances=my-project:my-region:my-instance |
| 90 |
.RE 3 |
| 91 |
.RS |
| 92 |
.RS |
| 93 |
.IP |
| 94 |
For connectivity over TCP, you must specify a tcp port as part of the |
| 95 |
instance string. For example, the following example opens a loopback TCP |
| 96 |
socket on port 3306, which will be proxied to connect to the instance |
| 97 |
.I 'my-instance' |
| 98 |
in project |
| 99 |
.I 'my-project': |
| 100 |
.RS |
| 101 |
.RS |
| 102 |
\-instances=my-project:my-region:my-instance=tcp:3306 |
| 103 |
.RE 2 |
| 104 |
.PP |
| 105 |
When connecting over TCP, the -instances parameter is required. |
| 106 |
.PP |
| 107 |
Supplying INSTANCES environment variable achieves the same effect. One can |
| 108 |
use that to keep k8s manifest files constant across multiple |
| 109 |
environments. If the name has the suffix |
| 110 |
.B '=tcp:port', |
| 111 |
a TCP server is opened on the specified port to proxy to that |
| 112 |
instance. Otherwise, one socket file per instance is opened |
| 113 |
in |
| 114 |
.I dir. |
| 115 |
You may use |
| 116 |
.B INSTANCES |
| 117 |
environment variable for the same effect. Using both will use value |
| 118 |
from flag. Not compatible with |
| 119 |
.I -fuse |
| 120 |
.RE |
| 121 |
.TP |
| 122 |
.B \-instances_metadata |
| 123 |
When running on GCE (Google Compute Engine) you can avoid the need to |
| 124 |
specify the list of instances on the command line by using the |
| 125 |
Metadata server. This parameter specifies a path to a metadata value |
| 126 |
which is then polled for a comma-separated list of fully qualified |
| 127 |
instances |
| 128 |
.B (project:region:name) |
| 129 |
to connect to in the exactly the same way as the |
| 130 |
.I -instances |
| 131 |
parameter. Updates to the metadata value will be observed and acted on |
| 132 |
by the Proxy. For example, to use the instance metadata value named |
| 133 |
.I cloud-sql-instances |
| 134 |
you would provide |
| 135 |
.I instance/attributes/cloud-sql-instances. |
| 136 |
.TP |
| 137 |
.B \-check_region |
| 138 |
If specified, the |
| 139 |
.I region |
| 140 |
portion of the connection string is required for Unix socket-based |
| 141 |
connections. |
| 142 |
.TP |
| 143 |
.B \-projects |
| 144 |
To direct the proxy to open connections for each Cloud SQL Instance in |
| 145 |
the comma-separated list of projects specified, set the projects |
| 146 |
parameter: |
| 147 |
.RS |
| 148 |
.RS |
| 149 |
\-projects=my-project |
| 150 |
.RE |
| 151 |
.RE |
| 152 |
.TP |
| 153 |
.B \-refresh_config_throttle |
| 154 |
If set, this flag specifies the amount of forced sleep between |
| 155 |
successive API calls in order to protect client API quota. Minimum |
| 156 |
allowed value is 1s |
| 157 |
.TP |
| 158 |
.B \-dir |
| 159 |
When using Unix sockets (the default for systems which support them), |
| 160 |
the Proxy places the sockets representing database instances in the |
| 161 |
directory specified by the |
| 162 |
.I -dir |
| 163 |
parameter. |
| 164 |
.TP |
| 165 |
.B \-fuse |
| 166 |
If your local environment has FUSE installed, you can specify the |
| 167 |
.I -fuse |
| 168 |
flag to avoid the requirement to specify instances in advance. Mount a |
| 169 |
directory at |
| 170 |
.I dir |
| 171 |
using FUSE for accessing instances. Note that the |
| 172 |
directory at |
| 173 |
.I dir |
| 174 |
must be empty before this program is started. With |
| 175 |
.B FUSE, |
| 176 |
any attempts to open a Unix socket in the directory specified by |
| 177 |
.I -dir |
| 178 |
automatically creates that socket and connects to the corresponding |
| 179 |
instance. |
| 180 |
.TP |
| 181 |
.B \-fuse_tmp |
| 182 |
Used as a temporary directory if |
| 183 |
.I -fuse |
| 184 |
is set. Note that files in this directory can be removed automatically |
| 185 |
by this program. |
| 186 |
.SS Automatic instance discovery |
| 187 |
If the Google Cloud SQL is installed on the local machine and no instance |
| 188 |
connection flags are specified, the proxy connects to all instances in the |
| 189 |
gcloud tool's active project. Run |
| 190 |
.I 'gcloud config list project' |
| 191 |
to display the active project. |
| 192 |
.SH FILES |
| 193 |
.TP |
| 194 |
.B Credentials |
| 195 |
By default user account credentials are acquired by |
| 196 |
.I gcloud auth login |
| 197 |
and stored locally on the system. |
| 198 |
.I gcloud auth activate-service-account |
| 199 |
authorizes access using a service account. As with |
| 200 |
.I gcloud init |
| 201 |
and |
| 202 |
.I gcloud auth login, |
| 203 |
this command saves the service account credentials to the local system |
| 204 |
on successful completion and sets the specified account as the active |
| 205 |
account in your Cloud SDK configuration. To configure the proxy using |
| 206 |
a service account, pass the |
| 207 |
.I -credential_file |
| 208 |
parameter or set the |
| 209 |
.B GOOGLE_APPLICATION_CREDENTIALS |
| 210 |
environment variable. This will override gcloud or GCE (Google |
| 211 |
Compute Engine) credentials, if they exist. |
| 212 |
.TP |
| 213 |
.B sockets directory |
| 214 |
When using Unix sockets (the default for systems which support them), |
| 215 |
the Proxy places the sockets rep‐ resenting database instances in the |
| 216 |
directory specified by the |
| 217 |
.I -dir |
| 218 |
parameter. With |
| 219 |
.B FUSE |
| 220 |
one can also interact with the proxy using thius directory to specify |
| 221 |
instances of cloud SQL databases to connect to on the fly. |
| 222 |
.TP |
| 223 |
.B /dev/fuse |
| 224 |
Optional functionality can be enabled ( |
| 225 |
.I --fuse |
| 226 |
) with access to |
| 227 |
.B /dev/fuse |
| 228 |
as well as the |
| 229 |
.B fusermount |
| 230 |
binary. |
| 231 |
.SH "SEE ALSO" |
| 232 |
.BR fusermount (1), |
| 233 |
.BR mount(8), |
| 234 |
.BR mount.fuse(8), |
| 235 |
.BR ulockmgr_server(1), |
| 236 |
.BR mysql(1), |
| 237 |
.BR postgres(1). |
| 238 |
.SH BUGS |
| 239 |
The upstream issue reporting system is at |
| 240 |
.UR https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues |
| 241 |
github |
| 242 |
.UE |
| 243 |
.SH AUTHOR |
| 244 |
Manoj Srivastava <[email protected]> |