2017-08-11 24 views
0

なんらかの理由で、私はクラウドSQLプロキシ経由でSQLインスタンスに接続できません。cloud_sql_proxyを使用してコンテナからクラウドSQLに接続できません


私は(kubectl exec ...経由)wordpressコンテナにtelnet 127.0.0.1 3306をやってみました:私は上記と同じ動作を取得cloudsql-proxy容器にI kubectl exec..場合でも

bash-4.3# telnet 127.0.0.1 3306 
Connection closed by foreign host 

ただし、これをローカルで行うと正常に動作します。


どうすればこの問題を診断できますか?その原因は何ですか?ここで


(展開中)私のコンテナの設定です:

containers: 
    - image: eu.gcr.io/abcxyz/wordpress:initial 
     name: wordpress 
     imagePullPolicy: "Always" 
     env: 
     - name: WORDPRESS_HOST 
      value: localhost 
     - name: WORDPRESS_DB_USERNAME 
      valueFrom: 
      secretKeyRef: 
       name: cloudsql-db-credentials 
       key: username 
     volumeMounts: 
     - name: wordpress-persistent-storage 
      mountPath: /var/www/html 
    - image: eu.gcr.io/abcxyz/nginx:initial 
     name: nginx 
     imagePullPolicy: "Always" 
     ports: 
     - containerPort: 80 
      name: nginx 
     volumeMounts: 
     - name: wordpress-persistent-storage 
      mountPath: /var/www/html 
    - image: gcr.io/cloudsql-docker/gce-proxy:1.09 
     name: cloudsql-proxy 
     command: ["/cloud_sql_proxy", "--dir=/cloudsql", 
       "-instances=abcxyz:europe-west1:wordpressdb=tcp:3306", 
       "-credential_file=/secrets/cloudsql/credentials.json"] 
     volumeMounts: 
     - name: cloudsql-instance-credentials 
      mountPath: /secrets/cloudsql 
      readOnly: true 
     - name: ssl-certs 
      mountPath: /etc/ssl/certs 
     - name: cloudsql 
      mountPath: /cloudsql 

私は以下を参照してくださいcloudsql-proxyからログを取得する場合:

2017/08/11 12:55:03 New connection for "abcxyz:europe-west1:wordpressdb" 
    2017/08/11 12:55:03 couldn't connect to "abcxyz:europe-west1:wordpressdb": ensure that the account has access to "abcxyz:europe-west1:wordpressdb" (and make sure there's no typo in that name). Error during createEphemeral for abcxyz:europe-west1:wordpressdb: googleapi: Error 403: The client is not authorized to make this request., notAuthorized 

サービスアカウント質問にはCloud SQL Admin権限があります。

答えて

1

サービスアカウントにCloud SQL Client権限を追加する必要がありました。

更新:私はこの問題を再度実行しましたが、何らかの理由でサービスアカウントが上記のエラーを繰り返しています。私は働いていた別のサービスアカウントを作成しなければならなかった...

関連する問題