This is my permission setup:
1. Add Cloud SQL Client role to Default compute service account
2. Add properly Cloud SQL connections when deploy Cloud Run service
This is my Spring Boot data source configuration:
I already added dependencies for gradle project:
implementation 'mysql:mysql-connector-java:8.0.25'
implementation 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.3.2'
Result:
The application keep starting and shutdown. I added log bellow.
Question:
What happen with my set up? Why Cloud Run service can't connect to Cloud SQL?
I tried connect to Cloud SQL though proxy and it works properly.
2021-08-31 00:46:37.291 ICT
2021-08-30 17:46:37.288 INFO 1 --- [ main] c.k.b.c.f.FacebookConnectorApplication : Starting FacebookConnectorApplication using Java 11.0.11 on localhost with PID 1 (/app/classes started by root in /)Default2021-08-31 00:46:37.291 ICT
2021-08-30 17:46:37.291 INFO 1 --- [ main] c.k.b.c.f.FacebookConnectorApplication : The following profiles are active: cloud Default2021-08-31 00:46:40.916 ICT
2021-08-30 17:46:40.916 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) Default2021-08-31 00:46:40.986 ICT
2021-08-30 17:46:40.986 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] Default2021-08-31 00:46:40.986 ICT
2021-08-30 17:46:40.986 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.48] Default2021-08-31 00:46:41.207 ICT
2021-08-30 17:46:41.207 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext Default2021-08-31 00:46:41.207 ICT
2021-08-30 17:46:41.207 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3797 ms Default2021-08-31 00:46:43.779 ICT
2021-08-30 17:46:43.777 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariCP - Starting... Default2021-08-31 00:46:44.008 ICT
2021-08-30 17:46:44.008 INFO 1 --- [ main] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [xxxx:asia-southeast1:xxxxx] via SSL socket. Default2021-08-31 00:46:44.008 ICT
2021-08-30 17:46:44.008 INFO 1 --- [ main] c.g.cloud.sql.core.CoreSocketFactory : First Cloud SQL connection, generating RSA key pair. Debug2021-08-31 00:46:44.280 ICT
Container Sandbox: Unsupported syscall setsockopt(0x5a,0x1,0xc,0x3e06596abbbc,0x4,0x7). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information. Default2021-08-31 00:46:47.212 ICT
2021-08-30 17:46:47.212 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariCP - Start completed. Default2021-08-31 00:46:47.380 ICT
2021-08-30 17:46:47.379 INFO 1 --- [onnection adder] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [xxxxx:asia-southeast1:xxxxx] via SSL socket. Default2021-08-31 00:46:47.505 ICT
2021-08-30 17:46:47.504 INFO 1 --- [onnection adder] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [xxxxx:asia-southeast1:xxxxx] via SSL socket. Default2021-08-31 00:46:47.576 ICT
2021-08-30 17:46:47.576 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' Default2021-08-31 00:46:47.591 ICT
2021-08-30 17:46:47.591 INFO 1 --- [ main] c.k.b.c.f.FacebookConnectorApplication : Started FacebookConnectorApplication in 11.797 seconds (JVM running for 12.96) Default2021-08-31 00:46:47.684 ICT
2021-08-30 17:46:47.684 INFO 1 --- [onnection adder] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [psychic-era-313204:asia-southeast1:chat-bot] via SSL socket. Error2021-08-31 00:46:47.807 ICT
POST5031.19 KB13.3 sfacebookexternalua xxxxxx Error2021-08-31 00:46:48.513 ICT
POST5000 B0 msfacebookexternaluaxxxxxx Error2021-08-31 00:46:49.163 ICT
POST5000 B0 msfacebookexternalua xxxxxx Default2021-08-31 00:46:49.825 ICT
2021-08-30 17:46:49.825 INFO 1 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariCP - Shutdown initiated...