Skip to content

Commit

Permalink
fix indentation issue
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Fisher <[email protected]>
  • Loading branch information
bacongobbler committed Apr 1, 2024
1 parent df2f2c3 commit 4c08097
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ spec:
averageUtilization: {{ .TargetCpuUtilizationPercentage }}
- type: Resource
resource:
name: memory
name: memory
target:
type: Utilization
averageUtilization: {{ .TargetMemoryUtilizationPercentage }}
Expand All @@ -132,20 +132,20 @@ metadata:
name: {{ .Name }}-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
kind: Deployment
name: {{ .Name }}
minReplicaCount: {{ .Replicas }}
maxReplicaCount: {{ .MaxReplicas }}
triggers:
- type: cpu
metricType: Utilization
metadata:
value: "{{ .TargetCpuUtilizationPercentage }}"
- type: memory
metricType: Utilization
metadata:
value: "{{ .TargetMemoryUtilizationPercentage }}"
- type: cpu
metricType: Utilization
metadata:
value: "{{ .TargetCpuUtilizationPercentage }}"
- type: memory
metricType: Utilization
metadata:
value: "{{ .TargetMemoryUtilizationPercentage }}"
{{- end }}
{{- end }}
`
Expand Down
30 changes: 30 additions & 0 deletions pkg/cmd/scaffold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,36 @@ func TestScaffoldOutput(t *testing.T) {
},
expected: "multiple_image_secrets.yml",
},
{
name: "HPA autoscaler support",
opts: ScaffoldOptions{
from: "ghcr.io/foo/example-app:v0.1.0",
executor: "containerd-shim-spin",
autoscaler: "hpa",
cpuLimit: "100m",
memoryLimit: "128Mi",
replicas: 2,
maxReplicas: 3,
targetCpuUtilizationPercentage: 60,
targetMemoryUtilizationPercentage: 60,
},
expected: "hpa_autoscaler.yml",
},
{
name: "KEDA autoscaler support",
opts: ScaffoldOptions{
from: "ghcr.io/foo/example-app:v0.1.0",
executor: "containerd-shim-spin",
autoscaler: "keda",
cpuLimit: "100m",
memoryLimit: "128Mi",
replicas: 2,
maxReplicas: 3,
targetCpuUtilizationPercentage: 60,
targetMemoryUtilizationPercentage: 60,
},
expected: "keda_autoscaler.yml",
},
}

for _, tc := range testcases {
Expand Down
37 changes: 37 additions & 0 deletions pkg/cmd/testdata/hpa_autoscaler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: core.spinoperator.dev/v1alpha1
kind: SpinApp
metadata:
name: example-app
spec:
image: "ghcr.io/foo/example-app:v0.1.0"
executor: containerd-shim-spin
enableAutoscaling: true
resources:
limits:
cpu: 100m
memory: 128Mi
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-app-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: example-app
minReplicas: 2
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 60
33 changes: 33 additions & 0 deletions pkg/cmd/testdata/keda_autoscaler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: core.spinoperator.dev/v1alpha1
kind: SpinApp
metadata:
name: example-app
spec:
image: "ghcr.io/foo/example-app:v0.1.0"
executor: containerd-shim-spin
enableAutoscaling: true
resources:
limits:
cpu: 100m
memory: 128Mi
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: example-app-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: example-app
minReplicaCount: 2
maxReplicaCount: 3
triggers:
- type: cpu
metricType: Utilization
metadata:
value: "60"
- type: memory
metricType: Utilization
metadata:
value: "60"

0 comments on commit 4c08097

Please sign in to comment.