FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

function-rds-metrics/example at main · upbound/function-rds-metrics · GitHub

Latest commit

 

History

History

README.md

RDS Metrics Function Examples

You can run the RDS metrics function locally and test it using crossplane beta render with these example manifests.

Setup

  1. Create AWS credentials secret:
kubectl create secret generic aws-creds -n crossplane-system --from-file=credentials=$HOME/.aws/credentials --dry-run=client -o yaml | kubectl apply -f -
  1. Or use the example secret (for testing only):
kubectl apply -f secrets/aws-creds.yaml

Testing Scenarios

Basic Test

# Run the function locally
$ go run . --insecure --debug

# In another terminal, test basic functionality
$ crossplane render xr.yaml composition.yaml functions.yaml --function-credentials=secrets/aws-creds.yaml -rc

Custom Metrics Query

$ crossplane render custom-metrics-query/xr.yaml custom-metrics-query/composition.yaml functions.yaml --function-credentials=secrets/aws-creds.yaml -rc

Context Testing

$ crossplane render context-testing/xr.yaml context-testing/composition.yaml functions.yaml --function-credentials=secrets/aws-creds.yaml -rc

Dynamic Database Name from XR

$ crossplane render database-ref-from-xr/xr.yaml database-ref-from-xr/composition.yaml functions.yaml --function-credentials=secrets/aws-creds.yaml --include-context

Basic Metrics Query

$ crossplane render basic-metrics-query/xr.yaml basic-metrics-query/composition.yaml functions.yaml --function-credentials=secrets/aws-creds.yaml

Expected Output

The function should:

  1. Write RDS metrics to XR status at the specified target path
  2. Write metrics to pipeline context for downstream functions
  3. Set appropriate Crossplane conditions

Example successful output:

---
apiVersion: example.crossplane.io/v1
kind: XR
metadata:
  name: example-rds-metrics-test
status:
  rdsMetrics:
    databaseName: "example-rds-instance"
    region: "us-east-1"
    timestamp: "2025-01-26T..."
    metrics:
      CPUUtilization:
        value: 25.5
        unit: "Percent"
        timestamp: "2025-01-26T..."
---
apiVersion: render.crossplane.io/v1beta1
kind: Result
message: Successfully fetched metrics for RDS instance example-rds-instance
severity: SEVERITY_NORMAL
step: fetch-metrics

Back | FazBrowse Home | New Git URL