You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use an Environment-level API key (not Project or Org key) for Cloud Run deployments
50
+
:::
48
51
49
52
### 6. Ready to deploy !
50
53
@@ -53,14 +56,196 @@ Click on the "Create" button to deploy the PDP.
53
56
You can see the logs of the deployment in the "Logs" tab, and if the deployment succeeded, you will see the URL of the PDP in the top section of the Cloud Run service.
54
57

55
58
59
+
:::info Signal 6 in Cloud Run
60
+
A common misconfiguration issue that can be encountered when deploying the PDP to Google Cloud Run is having the platform unexpectedly terminate the PDP container with a Signal 6 (SIGABRT). This issue stems from Cloud Run's CPU allocation settings, which allow background task processes, such as the PDP, to release CPU resources when idle. Consequently, this results in the container's termination due to insufficient CPU availability.
61
+
To address this issue and ensure uninterrupted service, we recommend adding the `run.googleapis.com/cpu-throttling: false` annotation in the YAML configuration.
62
+
63
+
For a deeper understanding of CPU allocation settings in Cloud Run and how they impact your applications, please refer to the following documentation: [Cloud Run CPU Allocation Settings](https://cloud.google.com/run/docs/configuring/cpu-allocation).
64
+
:::
65
+
56
66
## YAML file
57
67
58
68
We shared the YAML file that we used to deploy the PDP on GCP Cloud Run.
59
69
Take a look at the following [Deployments Github Repository](https://github.com/permitio/permit-pdp-deployments-examples/blob/main/gcp/cloud-run.yaml)
60
70
61
-
:::info Signal 6 in Cloud Run
62
-
A common misconfiguration issue that can be encountered when deploying the PDP to Google Cloud Run is having the platform unexpectedly terminate the PDP container with a Signal 6 (SIGABRT). This issue stems from Cloud Run's CPU allocation settings, which allow background task processes, such as the PDP, to release CPU resources when idle. Consequently, this results in the container's termination due to insufficient CPU availability.
63
-
To address this issue and ensure uninterrupted service, we recommend adding the `run.googleapis.com/cpu-throttling: false` annotation in the YAML configuration.
71
+
### Known-Good Reference Deployment (YAML / CLI)
72
+
73
+
The following configuration is known to work on Cloud Run and addresses autoscaling, CPU throttling, startup probes, and environment variables appropriately.
74
+
75
+
#### Prerequisites
76
+
77
+
- gcloud installed and authenticated
78
+
- Cloud Run and Secret Manager APIs enabled
79
+
- Permit Environment API Key stored in Secret Manager
| `run.googleapis.com/cpu-throttling` | `"false"` | Prevents SIGABRT errors by keeping CPU allocated |
168
+
| `autoscaling.knative.dev/minScale` | `"1"` | Avoids cold starts that cause authorization failures |
169
+
| `containerPort` | `7000` | Default PDP port |
170
+
| `startupProbe.timeoutSeconds` | `240` | Allows time for initial policy sync |
171
+
172
+
:::note
173
+
Replace `YOUR_SERVICE_ACCOUNT_EMAIL` with the service account email obtained in Step 3 (the `$SERVICE_ACCOUNT` variable value).
174
+
:::
64
175
65
-
For a deeper understanding of CPU allocation settings in Cloud Run and how they impact your applications, please refer to the following documentation: [Cloud Run CPU Allocation Settings](https://cloud.google.com/run/docs/configuring/cpu-allocation).
176
+
#### Step 5: Deploy the Service
177
+
178
+
```bash
179
+
gcloud run services replace permit-pdp-service.yaml --region=us-central1
180
+
```
181
+
182
+
#### Step 6: Allow Public Access (Optional)
183
+
184
+
:::warning Security Risk
185
+
Exposing the PDP publicly allows anyone to query your authorization decisions. Only use this for development or testing environments. For production, use Cloud Run's IAM authentication or VPC connectors for private access.
186
+
:::
187
+
188
+
If you need unauthenticated access to the PDP:
189
+
190
+
```bash
191
+
gcloud run services add-iam-policy-binding permit-pdp \
192
+
--region=us-central1 \
193
+
--member="allUsers" \
194
+
--role="roles/run.invoker"
195
+
```
196
+
197
+
#### Step 7: Verify the Deployment
198
+
199
+
Check the health endpoint:
200
+
201
+
```bash
202
+
# Get the service URL
203
+
SERVICE_URL=$(gcloud run services describe permit-pdp --region=us-central1 --format="value(status.url)")
204
+
205
+
# Check health
206
+
curl ${SERVICE_URL}/health
207
+
```
208
+
Expected response:
209
+
```json
210
+
{
211
+
"components": {
212
+
"horizon": {
213
+
"details": {
214
+
"direct_check": "success",
215
+
"watchdog": "error"
216
+
},
217
+
"error": null,
218
+
"status": "ok"
219
+
},
220
+
"opa": {
221
+
"error": null,
222
+
"status": "ok"
223
+
}
224
+
},
225
+
"status": "ok"
226
+
}
227
+
```
228
+
229
+
:::note
230
+
The `"watchdog": "error"` in the response is expected behavior in Cloud Run environments due to how Cloud Run handles background processes. As long as `"status": "ok"` appears at the top level, your PDP is healthy and operational.
0 commit comments