Bernard Allotey
Bernard Allotey

Reputation: 822

How to use Cloud Deploy with Cloud Run without completely resetting service

When following the quick start to deploy a cloud run service using Google cloud deploy, everything works fine. I can't figure out, however, how to not have the cloud run service have all of its settings removed. I have some secrets and cloud sql connections that need to be added to the container, but all of that stuff gets deleted whenever a new release occurs. Any tips?

Here is the configuration I'm using for the service:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: backend
spec:
  template:
    metadata:
      annotations:
        run.googleapis.com/startup-cpu-boost: 'true'
    spec:
      containers:
      - image: backend
      env:
      - name: DB_USER
        value: postgres
      - name: ApiKey
        valueFrom:
          secretKeyRef:
            name: test-key
            key: '1'
      - name: DB_PASS
        valueFrom:
          secretKeyRef:
            name: postgres-pass
            key: '1'

The command I'm using is gcloud deploy releases create rel-b256 --project {projectName} --region us-east1 --delivery-pipeline backend-pipeline --images backend={backendPath}

Upvotes: 1

Views: 631

Answers (2)

Bernard Allotey
Bernard Allotey

Reputation: 822

Ok, that was quite the ride of testing, but I figured out that my issue is that in my service yaml, if the yaml is mis-formatted, that the changes do not get correctly applied. In my case, in spec.template.spec, I had:

containers:
- image: backend
env:
- name: DB_USER
  value: postgres

when I actually needed:

containers:
- image: backend
  env: 
  - name: DB_USER
    value: postgres

Updating the yaml seemed to fix my issue and the settings were getting correctly applied to the service as intended.

Upvotes: 0

anon
anon

Reputation:

Save them in an .env file or any other IaC template you wish.

Upvotes: -1

Related Questions