GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-proxy-operator
Auto IAM Auth not working as intended?
- Lenguaje dominante
- Go
- Estrellas
- 120
- Forks
- 18
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hello!
I've been trying to get the operator to work with my application using a config similar to:
```
apiVersion: cloudsql.cloud.google.com/v1
kind: AuthProxyWorkload
metadata:
name: my-proxy
spec:
authProxyContainer:
authentication:
impersonationChain:
- @.iam.gserviceaccount.com
workloadSelector:
kind: "Deployment"
selector:
matchExpressions:
- key: "component"
operator: In
values:
- my-app
instances:
- connectionString: ""
port: 5432
privateIP: true
autoIAMAuthN: true
```
This generates an init container like so (some parts removed for brevity) - so far so good:
```
initContainers:
- args:
- ?auto-iam-authn=true&port=5432&private-ip=true
env:
- name: CSQL_PROXY_HTTP_PORT
value: "9801"
- name: CSQL_PROXY_HTTP_ADDRESS
value: 0.0.0.0
- name: CSQL_PROXY_HEALTH_CHECK
value: "true"
- name: CSQL_PROXY_EXIT_ZERO_ON_SIGTERM
value: "true"
- name: CSQL_PROXY_QUITQUITQUIT
value: "true"
- name: CSQL_PROXY_ADMIN_PORT
value: "9091"
- name: CSQL_PROXY_IMPERSONATE_SERVICE_ACCOUNT
value: @.iam.gserviceaccount.com
- name: CSQL_PROXY_USER_AGENT
value: cloud-sql-proxy-operator/1.7.2
- name: CSQL_PROXY_STRUCTURED_LOGS
value: "true"
- name: CSQL_PROXY_QUIT_URLS
value: http://localhost:9091/quitquitquit
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.19.0
name: csql-dagster-dagster
```
No issues appear in the logs for the init container, but my application receives an error:
```
FATAL: Cloud SQL IAM service account authentication failed for user "@.iam"
```
After checking I've configured everything right a few times, I tried using the sidecar method instead of the operator using the example from the docs:
```
- name: cloud-sql-proxy
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.19.0
args:
- "--private-ip"
- "--auto-iam-authn"
- "--structured-logs"
- "--impersonate-service-account=@.iam.gserviceaccount.com"
- "--port=5432"
- ""
```
This worked straight away.
After playing around with some of the arguments, I found using the instance configuration parameter of `auto-iam-authn=true` instead of the flag or environment variable is what causes the authentication to fail.
Works:
```
- "--auto-iam-authn"
- ""
```
or
```
env:
- name: CSQL_PROXY_AUTO_IAM_AUTHN
value: 'true'
args:
- ""
```
Doesn't work:
```
- "?auto-iam-authn=true"
```
I'm therefore curious:
1. Why would this behave differently - does the instance config do something separate from the flag/envvar ?
2. Should the operator be using one of those other methods and not the instance configuration for IAM Auth?
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.