https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Amit Gupta

06/23/2022, 7:40 PM
Hey All, How to set database as cloud sql instead of sqlite in Prefect Kubernetes Setup?
k

Kevin Kho

06/23/2022, 7:44 PM
Have you seen this ?
a

Amit Gupta

06/23/2022, 7:52 PM
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

Kevin Kho

06/23/2022, 7:53 PM
Did you use the helm chart or are you deploying Orion in one pod?
a

Amit Gupta

06/23/2022, 8:06 PM
Used this to deploy
prefect orion kubernetes-manifest | kubectl apply -f -
k

Kevin Kho

06/23/2022, 8:08 PM
Then I think in the manifest, you just need to add the extra environment variable to point to postgres
a

Amit Gupta

06/23/2022, 8:14 PM
Can’t find anything related to same in the manifest file
k

Kevin Kho

06/23/2022, 8:18 PM
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

Amit Gupta

06/23/2022, 8:20 PM
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

Pretush Gupta

06/27/2022, 4:50 AM
any update on this?
k

Kevin Kho

06/27/2022, 3:16 PM
What did you try?
p

Pretush Gupta

06/28/2022, 5:26 AM
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

Kevin Kho

06/28/2022, 8:35 AM
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

Pretush Gupta

06/28/2022, 8:37 AM
yess
19 Views