Advertisement
perimcomm

API-with-CloudSQL

Aug 23rd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: <api>
  5. labels:
  6. app: <api>
  7. spec:
  8. replicas: 1
  9. selector:
  10. matchLabels:
  11. app: <api>
  12. template:
  13. metadata:
  14. labels:
  15. app: <api>
  16. spec:
  17. containers:
  18. - name: <api>
  19. image: gcr.io/<omitted>/<ommited>:v5
  20. env:
  21. - name: NODE_ENV
  22. value: local
  23. - name: DB_DATABASE
  24. value: <database>
  25. - name: DB_HOST
  26. value: 127.0.0.1:3306
  27. - name: DB_USER
  28. valueFrom:
  29. secretKeyRef:
  30. name: cloudsql-db-credentials
  31. key: username
  32. - name: DB_PASSWORD
  33. valueFrom:
  34. secretKeyRef:
  35. name: cloudsql-db-credentials
  36. key: password
  37. ports:
  38. - containerPort: 3000
  39. - name: cloudsql-proxy
  40. image: gcr.io/cloudsql-docker/gce-proxy:1.11
  41. command: ["/cloud_sql_proxy","-instances=<INSTANCE_CONNECTION_NAME>=tcp:3306","-credential_file=/secrets/cloudsql/credentials.json"]
  42. volumeMounts:
  43. - name: cloudsql-instance-credentials
  44. mountPath: /secrets/cloudsql
  45. readOnly: true
  46. volumes:
  47. - name: cloudsql-instance-credentials
  48. secret:
  49. secretName: cloudsql-instance-credentials
  50.  
  51. ---
  52.  
  53. apiVersion: v1
  54. kind: Service
  55. metadata:
  56. name: <api-service>
  57. spec:
  58. externalTrafficPolicy: Cluster
  59. selector:
  60. app: <api>
  61. ports:
  62. - protocol: TCP
  63. port: 80
  64. targetPort: 3000
  65. type: LoadBalancer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement