Hey All, How to set database as cloud sql instead ...
# prefect-community
a
Hey All, How to set database as cloud sql instead of sqlite in Prefect Kubernetes Setup?
k
Have you seen this ?
a
Yes, it specify setting up database on same host and for docker mode only. It doesn’t specify how to use remote Postgres/CloudSql when using Prefect in Kubrenetes
k
Did you use the helm chart or are you deploying Orion in one pod?
a
Used this to deploy
prefect orion kubernetes-manifest | kubectl apply -f -
k
Then I think in the manifest, you just need to add the extra environment variable to point to postgres
a
Can’t find anything related to same in the manifest file
k
There is this section which has the container. You can try putting the env variable in the
api
container so that orion starts pointing to the database you want
Copy code
spec:
  selector:
    matchLabels:
      app: orion
  replicas: 1  # We're using SQLite, so we should only run 1 pod
  template:
    metadata:
      labels:
        app: orion
    spec:
      containers:
      - name: api
        image: prefecthq/prefect:2.0b7-python3.8
        command: ["prefect", "orion", "start", "--host", "0.0.0.0", "--log-level", "WARNING"]
        imagePullPolicy: "IfNotPresent"
        ports:
        - containerPort: 4200
      - name: agent
        image: prefecthq/prefect:2.0b7-python3.8
        command: ["prefect", "agent", "start", "kubernetes"]
        imagePullPolicy: "IfNotPresent"
        env:
          - name: PREFECT_API_URL
            value: <http://orion:4200/api>
Actually the agent might need it too
a
ok. Thanks Let me try
@Pretush Gupta
Hi Kevin, We tried but could not connect to our existing Postgres Instance. Could you please help us where to specify the Postgres connection in the Manifest or could you point us to config file where can we specify the same?
p
any update on this?
k
What did you try?
p
I tried deploying .yaml on kubernetes in cluster but it doesn’t connect with my postres server. So I need help with connecting postgres server using helm chart to kubernetes.
@Aishwarya Vaibhav
k
I get that but how did you try connecting?
Copy code
spec:
  selector:
    matchLabels:
      app: orion
  replicas: 1  # We're using SQLite, so we should only run 1 pod
  template:
    metadata:
      labels:
        app: orion
    spec:
      containers:
      - name: api
        image: prefecthq/prefect:2.0b7-python3.8
        command: ["prefect", "orion", "start", "--host", "0.0.0.0", "--log-level", "WARNING"]
        imagePullPolicy: "IfNotPresent"
        ports:
        - containerPort: 4200
        env:
          - name: PREFECT_ORION_DATABASE_CONNECTION_URL
            value: <postgresql+asyncpg://postgres:yourTopSecretPassword@localhost:5432/orion>
like that?
p
yess