이전에 사이드카 패턴으로 작업 한 클라우드 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
로그
가 시작 듣기를 제외하고 아무것도 보여주지무엇이 누락 되었습니까? 어디에서 충돌 사고의 원인을 찾아야합니까? 구성 오류가 있습니까?