Skip to content

Commit 8f9382b

Browse files
authored
Switch to Haiku model for cost-effective AI scaling (#6)
* Working e2e tests Signed-off-by: Yury Tsarev <[email protected]> * Proper switch to haiku model Signed-off-by: Yury Tsarev <[email protected]> * Syncup test credentials namespace with composition Signed-off-by: Yury Tsarev <[email protected]> --------- Signed-off-by: Yury Tsarev <[email protected]>
1 parent c716821 commit 8f9382b

File tree

7 files changed

+63
-20
lines changed

7 files changed

+63
-20
lines changed

apis/composition-rds-metrics.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
- name: aws-creds
3636
source: Secret
3737
secretRef:
38-
namespace: database-team
38+
namespace: crossplane-system
3939
name: aws-creds
4040
- step: crossplane-contrib-function-auto-ready
4141
functionRef:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: aws.m.upbound.io/v1beta1
3+
kind: ProviderConfig
4+
metadata:
5+
name: default
6+
namespace: database-team
7+
spec:
8+
credentials:
9+
source: Upbound
10+
upbound:
11+
webIdentity:
12+
roleARN: arn:aws:iam::609897127049:role/solutions-e2e-provider-aws
File renamed without changes.

operations/rds-intelligent-scaling-cron/operation.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ spec:
2929
input:
3030
apiVersion: claude.fn.upbound.io/v1alpha1
3131
kind: Prompt
32+
modelName: claude-haiku-4-5 # haiku brings serious cost savings
3233
systemPrompt: |
3334
You are an intelligent RDS scaling system that analyzes SQLInstance resources
3435
and makes scaling decisions based on CloudWatch performance metrics.
3536
36-
Output only the JSON patch for the SQLInstance resource. Your entire response should be the JSON object, nothing else.
37+
Return a JSON patch for the SQLInstance resource.
3738
userPrompt: |
3839
You are analyzing a SQLInstance resource for potential RDS scaling needs.
3940
@@ -59,7 +60,7 @@ spec:
5960
- Ensure minimum 5-minute cooldown between scaling events
6061
6162
OUTPUT FORMAT:
62-
Provide your response as a JSON resource patch. The JSON should contain ONLY the fields that need to be updated.
63+
Return a JSON patch containing only the fields that need updating.
6364
6465
If scaling is needed:
6566
{
@@ -95,13 +96,10 @@ spec:
9596
}
9697
9798
Rules:
98-
- Use the exact resource name and namespace from the input
99-
- Only include fields that need to be updated
100-
- Use current timestamp in ISO8601 format
101-
- Provide brief, clear reasoning in annotations
102-
- IMPORTANT: v2 resources are namespaced, always include namespace in metadata
103-
- Output the JSON on a single line without extra formatting
104-
- no ```json in the output
99+
- Use exact resource name and namespace from input
100+
- Use current timestamp in ISO8601 format (YYYY-MM-DDTHH:MM:SSZ)
101+
- Provide clear, concise reasoning in decision annotation
102+
- Include namespace in metadata (v2 resources are namespaced)
105103
106104
SQLInstance Resource:
107105
{{ .Resources }}

tests/e2etest-sqlinstance/main.k

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,71 @@
11
import models.io.upbound.awsm.v1beta1 as awsv1beta1
22
import models.io.upbound.dev.meta.v1alpha1 as metav1alpha1
33
import models.io.upbound.platform.aws.v1alpha1 as platformawsv1alpha1
4+
import models.io.k8s.api.core.v1 as corev1
45

56
_items = [
67
metav1alpha1.E2ETest{
78
metadata.name: "sqlinstances"
89
spec= {
9-
crossplane.autoUpgrade.channel: "Rapid"
10+
crossplane.autoUpgrade.channel: "None"
11+
crossplane.version: "2.1.1-up.1"
1012
defaultConditions: ["Ready"]
1113
manifests: [
14+
# MariaDB instance with AI-powered scaling enabled
1215
platformawsv1alpha1.SQLInstance{
1316
metadata = {
14-
name = "configuration-aws-database-mariadb"
17+
name = "configuration-aws-database-ai-e2e-mariadb"
18+
namespace = "default"
19+
labels = {
20+
"scale" = "me"
21+
}
1522
}
1623
spec = {
24+
crossplane.compositionSelector.matchLabels = {
25+
"type" = "rds-metrics"
26+
}
1727
parameters = {
1828
region = "us-west-2"
1929
engine = "mariadb"
2030
engineVersion = "10.11"
2131
storageGB = 5
32+
instanceClass = "db.t3.micro"
2233
autoGeneratePassword = True
34+
publiclyAccessible = False
2335
passwordSecretRef = {
2436
name = "mariadbsecret"
2537
key = "password"
2638
}
2739
networkRef = {
28-
id = "configuration-aws-database"
40+
id = "configuration-aws-database-ai-e2e"
2941
}
3042
}
3143
}
3244
}
45+
# Postgres instance without AI scaling (baseline test)
3346
platformawsv1alpha1.SQLInstance{
3447
metadata = {
35-
name = "configuration-aws-database-postgres"
48+
name = "configuration-aws-database-ai-e2e-postgres"
49+
namespace = "default"
3650
}
3751
spec = {
52+
crossplane.compositionSelector.matchLabels = {
53+
"type" = "rds-metrics"
54+
}
3855
parameters = {
3956
region = "us-west-2"
4057
engine = "postgres"
4158
engineVersion = "13.18"
4259
storageGB = 5
60+
instanceClass = "db.t3.micro"
4361
autoGeneratePassword = True
62+
publiclyAccessible = False
4463
passwordSecretRef = {
4564
name = "psqlsecret"
4665
key = "password"
4766
}
4867
networkRef = {
49-
id = "configuration-aws-database"
68+
id = "configuration-aws-database-ai-e2e"
5069
}
5170
}
5271
}
@@ -55,12 +74,12 @@ _items = [
5574
apiVersion = "aws.platform.upbound.io/v1alpha1"
5675
kind = "Network"
5776
metadata = {
58-
name = "configuration-aws-database"
77+
name = "configuration-aws-database-ai-e2e"
5978
namespace = "default"
6079
}
6180
spec = {
6281
parameters = {
63-
id = "configuration-aws-database"
82+
id = "configuration-aws-database-ai-e2e"
6483
region = "us-west-2"
6584
}
6685
}
@@ -70,7 +89,10 @@ _items = [
7089
extraResources: [
7190
# Define the provider configuration
7291
awsv1beta1.ProviderConfig{
73-
metadata.name = "default"
92+
metadata = {
93+
name = "default"
94+
namespace = "default"
95+
}
7496
spec = {
7597
credentials = {
7698
source = "Upbound"
@@ -82,6 +104,17 @@ _items = [
82104
}
83105
}
84106
}
107+
# AWS credentials secret for function-rds-metrics (fake credentials for e2e test)
108+
corev1.Secret{
109+
metadata = {
110+
name = "aws-creds"
111+
namespace = "crossplane-system"
112+
}
113+
type = "Opaque"
114+
data = {
115+
credentials = "W2RlZmF1bHRdCmF3c19hY2Nlc3Nfa2V5X2lkID0gQUtJQUlPU0ZPRE5ON0VYQU1QTEUKYXdzX3NlY3JldF9hY2Nlc3Nfa2V5ID0gd0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQ=="
116+
}
117+
}
85118
]
86119
skipDelete: False
87120
timeoutSeconds: 4500

tests/test-credentials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v1
33
kind: Secret
44
metadata:
55
name: aws-creds
6-
namespace: database-team
6+
namespace: crossplane-system
77
type: Opaque
88
data:
99
credentials: W2RlZmF1bHRdCmF3c19hY2Nlc3Nfa2V5X2lkID0gQUtJQUlPU0ZPRE5ON0VYQU1QTEUKYXdzX3NlY3JldF9hY2Nlc3Nfa2V5ID0gd0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQ==

upbound.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
- apiVersion: pkg.crossplane.io/v1
2424
kind: Function
2525
package: xpkg.upbound.io/upbound/function-claude
26-
version: v0.3.0
26+
version: v0.4.0
2727
- apiVersion: pkg.crossplane.io/v1beta1
2828
kind: Function
2929
package: xpkg.upbound.io/upbound/function-rds-metrics

0 commit comments

Comments
 (0)