<p>I am following this tutorial: <a href="https://cloud.google.com/sql/docs/mysql/connect-instance-kubernetes" rel="nofollow noreferrer">Connect to Cloud SQL for MySQL from Google Kubernetes Engine</a>.
I have created a cluster. I have created a docker image in the repository. I have created a database. I am able to run my application outside of Kubernetes and it connects to the database. But after deploying application, pods are not in a valid state and I see in the logs of the pod error:</p>
<pre><code>Caused by: java.lang.RuntimeException: [quizdev:us-central1:my-instance] Failed to update metadata for Cloud SQL instance.
       ...[na:na] 
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/quizdev/instances/my-instance/connectSettings
{
  &quot;code&quot;: 403,
  &quot;details&quot;: [
    {
      &quot;@type&quot;: &quot;type.googleapis.com/google.rpc.ErrorInfo&quot;,
      &quot;reason&quot;: &quot;ACCESS_TOKEN_SCOPE_INSUFFICIENT&quot;,
      &quot;domain&quot;: &quot;googleapis.com&quot;,
      &quot;metadata&quot;: {
        &quot;service&quot;: &quot;sqladmin.googleapis.com&quot;,
        &quot;method&quot;: &quot;google.cloud.sql.v1beta4.SqlConnectService.GetConnectSettings&quot;
      }
    }
  ],
  &quot;errors&quot;: [
    {
      &quot;domain&quot;: &quot;global&quot;,
      &quot;message&quot;: &quot;Insufficient Permission&quot;,
      &quot;reason&quot;: &quot;insufficientPermissions&quot;
       }
  ],
  &quot;message&quot;: &quot;Request had insufficient authentication scopes.&quot;,
  &quot;status&quot;: &quot;PERMISSION_DENIED&quot;
}
        at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) ~[google-api-client-2.2.0.jar:2.2.0]
        ... 

2023-06-14T06:57:49.508Z  WARN 1 --- [           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : HHH000342: Could not obtain connection to query metadata
</code></pre>
<p>What could be the issue? What can I check to diagnose the problem?</p>
<h2>Edit</h2>
<p>I have created the cluster using this command:</p>
<pre><code>  gcloud container clusters create questy-java-cluster \
  --num-nodes 2 \
  --machine-type n1-standard-1 \
  --zone us-central1-c
</code></pre>

<p>I'm pretty sure that you create a cluster by default. If you did that, you used the Compute Engine default parameter that you can see here</p>
<p><a href="https://i.stack.imgur.com/FKEyE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FKEyE.png" alt="enter image description here" /></a></p>
<p>Default service account and access scope. If you did that, it's normal you have no access: the minimal scope does not allow the Cloud SQL access.</p>
<hr />
<p>To solve that, you have to select either a user managed service account (the best solution) or still use the default service account but allow full scopes access.</p>
<p>2 solutions to enforce that:</p>
<ul>
<li>Either delete and recreate correctly your cluster</li>
<li>Or, you can create another node pool with the correct parameters.</li>
</ul>
