spinkube / spin-plugin-kube

A Spin plugin for interacting with Kubernetes.
Other
20 stars 5 forks source link

scaffolding with HPA autoscaler gets parsing error #73

Closed kate-goldenring closed 5 months ago

kate-goldenring commented 5 months ago
$spin kube scaffold --from ttl.sh/hello-spin:10h  --autoscaler hpa --cpu-limit 100m --memory-limit 128Mi --autoscaler-target-cpu-utilization 50 | kubectl apply -f -
spinapp.core.spinoperator.dev/hello-arun created
error: error parsing STDIN: error converting YAML to JSON: yaml: line 22: mapping values are not allowed in this context

The following app is scaffolded:

kind: SpinApp
metadata:
  name: hello-arun
spec:
  image: "ttl.sh/hello-arun:10h"
  executor: containerd-shim-spin
  enableAutoscaling: true
  resources:
    limits:
      cpu: 100m
      memory: 128Mi
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: hello-arun-autoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: hello-spin
  minReplicas: 2
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
  - type: Resource
    resource:
     name: memory
      target:
        type: Utilization
        averageUtilization: 60

This appears to be because target is indented from name in the memory resource. The update to the HPA resource works:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: hello-arun-autoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: hello-arun
  minReplicas: 2
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
  - type: Resource
    resource:
     name: memory
     target:
       type: Utilization
       averageUtilization: 60
bacongobbler commented 5 months ago

Thanks @kate-goldenring! Is this the same as https://github.com/spinkube/spin-plugin-kube/issues/68? If so we should probably cut a patch release with a fix.

kate-goldenring commented 5 months ago

Sorry i missed that @bacongobbler. Closing this