Skip to content

Commit 04a8d56

Browse files
committed
docs(tutorials): migrate alerting tutorials to redis as a Resource
The gcp-microservices-demo sample moves its Redis cache from a Component to a Resource of type ClusterResourceType/valkey. The two alerting tutorials reference that sample and need to keep up. - component-alerts-and-incidents.mdx: drop the removed redis-component.yaml from the kubectl apply block and add the Resource provisioning + promote step before the components apply. Redis was incidental to this tutorial (alerts target frontend / recommendation / cart). - configure-budget-alert-and-cost-analysis.mdx: same apply-block update, plus pivot the budget alert target from redis to productcatalog throughout Steps 4-6 (heading, trait instance name, ReleaseBinding name, prose). Resources don't accept componentTypeEnvironmentConfigs cost overrides, so the alert needs a Component target; productcatalog also avoids stepping on the alerts tutorial's already-touched components. Signed-off-by: Miraj Abeysekara <miraj@wso2.com>
1 parent f8c16d9 commit 04a8d56

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

docs/tutorials/component-alerts-and-incidents.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ Deploy the sample using the following commands if you haven't already:
382382
{`
383383
kubectl apply -f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/gcp-microservice-demo-project.yaml
384384
385+
# Provision the Redis cache, then promote the binding to the latest release.
386+
387+
kubectl apply -f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/resources/redis.yaml
388+
until release=$(kubectl get resource redis -n default -o jsonpath='{.status.latestRelease.name}') && [ -n "$release" ]; do sleep 2; done
389+
kubectl patch resourcereleasebinding redis-development -n default --type=merge -p "{\\"spec\\":{\\"resourceRelease\\":\\"$release\\"}}"
390+
385391
kubectl apply \\
386392
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/ad-component.yaml \\
387393
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/cart-component.yaml \\
@@ -392,7 +398,6 @@ kubectl apply \\
392398
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/payment-component.yaml \\
393399
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/productcatalog-component.yaml \\
394400
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/recommendation-component.yaml \\
395-
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/redis-component.yaml \\
396401
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/shipping-component.yaml
397402
`}
398403

docs/tutorials/configure-budget-alert-and-cost-analysis.mdx

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ Deploy the sample using the following commands if you haven't already:
385385
{`
386386
kubectl apply -f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/gcp-microservice-demo-project.yaml
387387
388+
# Provision the Redis cache, then promote the binding to the latest release.
389+
390+
kubectl apply -f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/resources/redis.yaml
391+
until release=$(kubectl get resource redis -n default -o jsonpath='{.status.latestRelease.name}') && [ -n "$release" ]; do sleep 2; done
392+
kubectl patch resourcereleasebinding redis-development -n default --type=merge -p "{\\"spec\\":{\\"resourceRelease\\":\\"$release\\"}}"
393+
388394
kubectl apply \\
389395
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/ad-component.yaml \\
390396
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/cart-component.yaml \\
@@ -395,54 +401,53 @@ kubectl apply \\
395401
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/payment-component.yaml \\
396402
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/productcatalog-component.yaml \\
397403
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/recommendation-component.yaml \\
398-
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/redis-component.yaml \\
399404
-f https://raw.githubusercontent.com/openchoreo/openchoreo/${versions.githubRef}/samples/gcp-microservices-demo/components/shipping-component.yaml
400405
`}
401406

402407
</CodeBlock>
403408

404-
### Step 4: Define a Budget Alert Rule for the Redis Component
409+
### Step 4: Define a Budget Alert Rule for the Product Catalog Component
405410

406411
Developers attach the budget alert rule as a trait to the component once. The alert rule automatically propagates to all environments as the component is promoted.
407412

408-
In this step we attach a budget-based alert to the `redis` component:
413+
In this step we attach a budget-based alert to the `productcatalog` component:
409414

410-
- Trigger: cost of the redis component exceeds USD 2 in 5 minutes
411-
- Trait instance name: `redis-budget-alert`
415+
- Trigger: cost of the productcatalog component exceeds USD 2 in 5 minutes
416+
- Trait instance name: `productcatalog-budget-alert`
412417

413418
```bash
414-
# redis component: budget-based alert
415-
if kubectl get component redis -n default \
419+
# productcatalog component: budget-based alert
420+
if kubectl get component productcatalog -n default \
416421
-o jsonpath='{.spec.traits[*].instanceName}' 2>/dev/null \
417-
| tr ' ' '\n' | grep -qx "redis-budget-alert"; then
418-
echo "Trait 'redis-budget-alert' already exists on component 'redis', skipping."
422+
| tr ' ' '\n' | grep -qx "productcatalog-budget-alert"; then
423+
echo "Trait 'productcatalog-budget-alert' already exists on component 'productcatalog', skipping."
419424
else
420-
kubectl patch component redis -n default --type=json -p='[
425+
kubectl patch component productcatalog -n default --type=json -p='[
421426
{
422427
"op": "add",
423428
"path": "/spec/traits/-",
424429
"value": {
425430
"name": "observability-alert-rule",
426431
"kind": "ClusterTrait",
427-
"instanceName": "redis-budget-alert",
432+
"instanceName": "productcatalog-budget-alert",
428433
"parameters": {
429-
"description": "Alert when redis cost for 5mins exceeds USD 2",
434+
"description": "Alert when productcatalog cost for 5mins exceeds USD 2",
430435
"severity": "warning",
431436
"source": { "type": "budget" },
432437
"condition": { "window": "5m", "interval": "1m", "operator": "gt", "threshold": 2 }
433438
}
434439
}
435440
}
436-
]' 2>/dev/null || kubectl patch component redis -n default --type=json -p='[
441+
]' 2>/dev/null || kubectl patch component productcatalog -n default --type=json -p='[
437442
{
438443
"op": "add",
439444
"path": "/spec/traits",
440445
"value": [{
441446
"name": "observability-alert-rule",
442447
"kind": "ClusterTrait",
443-
"instanceName": "redis-budget-alert",
448+
"instanceName": "productcatalog-budget-alert",
444449
"parameters": {
445-
"description": "Alert when redis cost for 5mins exceeds USD 2",
450+
"description": "Alert when productcatalog cost for 5mins exceeds USD 2",
446451
"severity": "warning",
447452
"source": { "type": "budget" },
448453
"condition": { "window": "5m", "interval": "1m", "operator": "gt", "threshold": 2 }
@@ -466,7 +471,7 @@ Without a notification channel, the ReleaseBinding will fail to apply the alert
466471

467472
### Step 5: Inflate OpenCost Node Pricing for Faster Alert Triggering
468473

469-
OpenCost calculates component cost based on the configured per-unit prices of CPU and memory on the underlying nodes. With the default pricing values, the projected cost of the `redis` component grows very slowly, so a budget alert with a low threshold (USD 2) can take a long time to fire during testing.
474+
OpenCost calculates component cost based on the configured per-unit prices of CPU and memory on the underlying nodes. With the default pricing values, the projected cost of the `productcatalog` component grows very slowly, so a budget alert with a low threshold (USD 2) can take a long time to fire during testing.
470475

471476
To make the budget alert trigger within a few minutes, temporarily override OpenCost's custom pricing model with significantly inflated CPU and RAM prices, then restart the OpenCost deployment so the new values take effect:
472477

@@ -488,7 +493,7 @@ This change is purely for accelerating the test scenario in this tutorial. Rever
488493

489494
This step creates a `ReleaseBinding` that:
490495

491-
- Deliberately inflates the `redis` component's CPU and memory requests/limits in the `development` environment so the projected cost crosses the USD 2 threshold within a few minutes
496+
- Deliberately inflates the `productcatalog` component's CPU and memory requests/limits in the `development` environment so the projected cost crosses the USD 2 threshold within a few minutes
492497
- Configures the budget alert for the `development` environment via `traitEnvironmentConfigs`:
493498
- Enables the alert rule
494499
- Selects the webhook notification channel
@@ -500,16 +505,16 @@ Apply the scenario:
500505
```bash
501506
kubectl apply -f - <<'EOF'
502507
---
503-
# ReleaseBinding for redis component with oversized resource requests/limits to trigger a budget alert
508+
# ReleaseBinding for productcatalog component with oversized resource requests/limits to trigger a budget alert
504509
apiVersion: openchoreo.dev/v1alpha1
505510
kind: ReleaseBinding
506511
metadata:
507-
name: redis-development
512+
name: productcatalog-development
508513
namespace: default
509514
spec:
510515
owner:
511516
projectName: gcp-microservice-demo
512-
componentName: redis
517+
componentName: productcatalog
513518
environment: development
514519
componentTypeEnvironmentConfigs:
515520
resources:
@@ -520,7 +525,7 @@ spec:
520525
cpu: "1000m"
521526
memory: "1000Mi"
522527
traitEnvironmentConfigs:
523-
redis-budget-alert:
528+
productcatalog-budget-alert:
524529
enabled: true
525530
actions:
526531
notifications:
@@ -538,7 +543,7 @@ EOF
538543

539544
### Step 7: Verify the Budget Alert and AI Cost Analysis
540545

541-
Within a few minutes of applying the redis `ReleaseBinding`, the `redis-budget-alert` should fire because the inflated CPU/memory requests push the cost above the threshold.
546+
Within a few minutes of applying the productcatalog `ReleaseBinding`, the `productcatalog-budget-alert` should fire because the inflated CPU/memory requests push the cost above the threshold.
542547

543548
- Confirm alert delivery to the configured webhook notification channel.
544549
- Confirm that an incident was created for the budget alert in the Backstage portal.
@@ -548,7 +553,7 @@ You can also acknowledge and resolve the incident via the Backstage portal once
548553

549554
## Summary
550555

551-
You attached a **budget-based observability alert rule** to the `redis` component (as an `observability-alert-rule` trait), configured a **webhook notification channel**, and enabled **incident creation** and **AI cost analysis** via `ReleaseBinding` `traitEnvironmentConfigs`.
556+
You attached a **budget-based observability alert rule** to the `productcatalog` component (as an `observability-alert-rule` trait), configured a **webhook notification channel**, and enabled **incident creation** and **AI cost analysis** via `ReleaseBinding` `traitEnvironmentConfigs`.
552557

553558
Then you triggered the budget alert using a controlled cost-overrun scenario and verified that the **FinOps Agent** produced an AI cost analysis report with an actionable rightsizing recommendation.
554559

0 commit comments

Comments
 (0)