GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-proxy-operator

Auto IAM Auth not working as intended?

未关闭
#719 4 条评论 4 个 reaction 已指派 1 人 已被 @hessjcg 认领 在 GitHub 查看
主要语言
Go
星标
120
派生
18
PR 合并指标
30 天内没有已合并 PR

描述

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?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。