<p>I have a cluster for staging that's been up for over a year using CloudSQL, and now I'd like to bring up another GKE cluster (same google project) pointed at the same database for testing. However, I'm seeing errors when trying to use the credentials.json from the old cluster in the new one. </p>

<pre><code>googleapi: Error 403: The client is not authorized to make this request., notAuthorized" 
</code></pre>

<p>I've poked around IAM to find a way to open the permissions to the new cluster but haven't found a way even though I see a service account with the "Cloud SQL Client" role.</p>

<p>What's the right way to share credentials or open permissions (or do I need to create a new service account for this)?</p>

<p>Our template deployment yaml looks like:</p>

<pre><code>  - name: postgres-proxy
    image: gcr.io/cloudsql-docker/gce-proxy:1.09
    imagePullPolicy: Always
    command: ["/cloud_sql_proxy",
              "--dir=/cloudsql",
              "-instances=@@PROJECT@@:us-central1:@@DBINST@@=tcp:5432",
              "-credential_file=/secrets/cloudsql/credentials.json"]
    volumeMounts:
      - name: cloudsql-oauth-credentials
        mountPath: /secrets/cloudsql
        readOnly: true
      - name: ssl-certs
        mountPath: /etc/ssl/certs
      - name: cloudsql
        mountPath: /cloudsql
</code></pre>

<p>As you are receiving the Error 403 from some Google API it appears a IAM permission error. To resolve the issue please make sure 'Cloud SQL Client' role is assigned to your service account. To check what permissions are added to your service account go to the Cloud Project IAM page (Left Menu > IAM &amp; Admin > IAM) and look for the row with the service account that is having the issue. The service account should say "Cloud SQL Client" on the Role column. </p>

<p>In case if you find "Cloud SQL Client" Role is not added to the service account, please try to follow the instructions outlined in <a href="https://cloud.google.com/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_account_for_a_resource" rel="nofollow noreferrer">this document</a>. If the service account is not already in the members list, it will not have any Role assigned to it. Click Add and enter the email address of the service account. If the service account is already on the members list, it has existing Roles. Click the drop-down list under Role(s) for the service account that you want to edit or you can add "Cloud SQL Client" Role as an additional Role to the service account. You need to select the "Cloud SQL Client" Role from the drop-down list under “Cloud SQL”. </p>

<p>In case if you see the "Cloud SQL Client" Role already exists, click on edit to open the drop-down list. After that click on delete and save it. Please make sure the service account is removed from the IAM page. Click the ADD button on top of the Cloud Project IAM page. Enter the service account email address and select the "Cloud SQL Client" role from the drop-down list under “Cloud SQL”. After that click the SAVE button and the service account should appear again under in the list. With this we are removing and then adding again the permissions for the service account.</p>

<p>You can also try by adding a new service account as outlined in <a href="https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating_a_service_account" rel="nofollow noreferrer">this document</a> and by selecting the "Cloud SQL Client" role from the drop-down list under “Cloud SQL”.  Please note that you need “Service Account Admin” role or the “Editor” primitive role to do the operations. </p>

<p>If still does not resolve the issue please make sure the “Cloud SQL Instance” name is correct. You can copy and paste the "Instance connection name" from the Google Cloud Console page of the Cloud SQL Instance as outlined in this <a href="https://stackoverflow.com/questions/36410483/getting-notauthorized-error-with-cloud-sql-proxy-locally">StackOverflow issue</a>.</p>

<p>Alternatively <a href="https://stackoverflow.com/questions/45766105/how-do-i-connect-to-a-cloud-sql-instance-using-a-service-account">by updating the secret to use the right key</a> you can resolve the issue. You can make more than one key for a service account. </p>
