# Cluster autoscaler - Crossplane-managed to prevent marketplace overwriting config
# Main pool (fc94): fixed at 3 nodes
# High-compute pool (cc28): scales 0-5 based on demand
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
  name: cluster-autoscaler-deployment
  namespace: crossplane-system
spec:
  providerConfigRef:
    name: kubernetes-provider
  forProvider:
    manifest:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: cluster-autoscaler
        namespace: kube-system
        labels:
          app: cluster-autoscaler
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: cluster-autoscaler
        template:
          metadata:
            labels:
              app: cluster-autoscaler
          spec:
            serviceAccountName: cluster-autoscaler
            containers:
            - name: cluster-autoscaler
              image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.28.1
              command:
              - ./cluster-autoscaler
              - --v=4
              - --stderrthreshold=info
              - --cloud-provider=civo
              - --nodes=3:3:1b886eac-942e-40bf-8f70-7a5496f2fd3b
              - --nodes=0:1:high-compute
              - --skip-nodes-with-local-storage=false
              - --skip-nodes-with-system-pods=false
              - --scale-down-unneeded-time=5m
              - --scale-down-delay-after-add=5m
              env:
              - name: CIVO_API_URL
                valueFrom:
                  secretKeyRef:
                    key: api-url
                    name: civo-api-access
              - name: CIVO_API_KEY
                valueFrom:
                  secretKeyRef:
                    key: api-key
                    name: civo-api-access
              - name: CIVO_CLUSTER_ID
                valueFrom:
                  secretKeyRef:
                    key: cluster-id
                    name: civo-api-access
              - name: CIVO_REGION
                valueFrom:
                  secretKeyRef:
                    key: region
                    name: civo-api-access
              resources:
                requests:
                  cpu: 100m
                  memory: 300Mi
                limits:
                  cpu: 100m
                  memory: 300Mi
