2017-10-09 7 views
0

이전에 사이드카 패턴으로 작업 한 클라우드 SQL 프록시를 가지고 있었지만 cloudsql-proxy repo에서 Cloud SQL Proxy in a Kubernetes cluster을 찾았습니다. 그래서 그것을 자체적으로 설명하기로했습니다.Cloud sql proxy kubernetes에서 충돌

나는 즉시 문제가 발생했다. 처음 연결했을 때 컨테이너가 충돌했다. 가능한 한 순수한 테스트 케이스로 돌아가서 livenessProbe을 추가하기로 결정했습니다.

I found that this recommended configuration self-crashes :

❯❯❯ kubectl get pods 
NAME       READY  STATUS RESTARTS AGE 
cloudsqlproxy-109958711-ks4bf 1/1  Running 5   2m 

배포 :

--- 
apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: cloudsqlproxy 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: cloudsqlproxy 
    spec: 
     containers: 
     - image: gcr.io/cloudsql-docker/gce-proxy:1.09 
     name: cloudsqlproxy 
     command: "/cloud_sql_proxy", "--dir=/cloudsql", 
        "-instances=foo:us-central1:db=tcp:3306", 
        "-credential_file=/secrets/cloudsql/credentials.json"] 
     ports: 
     - name: port-db 
      containerPort: 3306 

     livenessProbe: 
      exec: 
      command: ["netcat", "-U", "/cloudsql/foo:us-central1:db=tcp:3306"] 
      initialDelaySeconds: 5 
      timeoutSeconds: 10 

     volumeMounts: 
      - name: cloudsql-instance-credentials 
      mountPath: /secrets/cloudsql 
      readOnly: true 
      - name: ssl-certs 
      mountPath: /etc/ssl/certs 
      - name: cloudsql 
      mountPath: /cloudsql 
     volumes: 
     - name: cloudsql-instance-credentials 
      secret: 
      secretName: cloudsql-instance-credentials 
     - name: ssl-certs 
      hostPath: 
      path: /etc/ssl/certs 
     - name: cloudsql 
      emptyDir: 

서비스 :

E 2017/10/09 13:51:35 Listening on 127.0.0.1:3306 for foo:us-central1:db 
E 2017/10/09 13:51:35 Ready for new connections 
E 2017/10/09 13:52:38 using credential file for authentication; [email protected] 
E 2017/10/09 13:52:38 Listening on 127.0.0.1:3306 for foo:us-central1:db 
E 2017/10/09 13:52:38 Ready for new connections 
E 2017/10/09 13:54:26 using credential file for authentication; [email protected] 
E 2017/10/09 13:54:26 Listening on 127.0.0.1:3306 for foo:us-central1:db 
E 2017/10/09 13:54:26 Ready for new connections 
01 :
apiVersion: v1 
kind: Service 
metadata: 
    name: cloudsqlproxy-service 
spec: 
    ports: 
    - port: 3306 
    targetPort: port-db 
    selector: 
    app: cloudsqlproxy 

로그

가 시작 듣기를 제외하고 아무것도 보여주지

무엇이 누락 되었습니까? 어디에서 충돌 사고의 원인을 찾아야합니까? 구성 오류가 있습니까?

답변

0

내 환경에서 사용 권한 문제가있는 것으로 나타나고 a bug?이 기록되지 않고 실패합니다. 나는 사이드카로 배치 할 때만 로그를 얻을 수있었습니다.

2017/10/09 15:34:10 using credential file for authentication; [email protected] 
2017/10/09 15:34:10 Listening on 127.0.0.1:3306 for foo:us-central1:db 
2017/10/09 15:34:10 Ready for new connections 
2017/10/09 15:34:30 New connection for "foo:us-central1:db" 
2017/10/09 15:34:30 couldn't connect to "foo:us-central1:db": ensure that the account has access to "foo:us-central1:db" (and make sure there's no typo in that name). Error during createEphemeral for foo:us-central1:db: googleapi: Error 403: The client is not authorized to make this request., notAuthorized 
2017/10/09 15:34:30 New connection for "foo:us-central1:db" 

이 시점에서 사용 권한을 다시 만들고 내 사이드카 프로토 타입에서 다시 시도한 다음 격리 된 배포로 다시 이동합니다.