apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: dashboard-internal-dashboard
  namespace: cozy-dashboard
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: dashboard-internal-dashboard
  updatePolicy:
    updateMode: "Auto"
  resourcePolicy:
    containerPolicies:
    - containerName: dashboard
      controlledResources: ["cpu", "memory"]
      minAllowed:
        cpu: 50m
        memory: 64Mi
      maxAllowed:
        cpu: 500m
        memory: 512Mi
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: dashboard-internal-kubeappsapis
  namespace: cozy-dashboard
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: dashboard-internal-kubeappsapis
  updatePolicy:
    updateMode: "Auto"
  resourcePolicy:
    containerPolicies:
      - containerName: kubeappsapis
        controlledResources: ["cpu", "memory"]
        minAllowed:
          cpu: 50m
          memory: 100Mi
        maxAllowed:
          cpu: 1000m
          memory: 1Gi
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: dashboard-vpa
  namespace: cozy-dashboard
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: dashboard
  updatePolicy:
    updateMode: "Auto"
  resourcePolicy:
    containerPolicies:
    - containerName: nginx
      controlledResources: ["cpu", "memory"]
      minAllowed:
        cpu: "50m"
        memory: "64Mi"
      maxAllowed:
        cpu: "500m"
        memory: "512Mi"
    {{- $dashboardKCconfig := lookup "v1" "ConfigMap" "cozy-dashboard" "kubeapps-auth-config" }}
    {{- $dashboardKCValues := dig "data" "values.yaml" "" $dashboardKCconfig }}
    {{- if $dashboardKCValues }}
    - containerName: auth-proxy
      controlledResources: ["cpu", "memory"]
      minAllowed:
        cpu: "50m"
        memory: "64Mi"
      maxAllowed:
        cpu: "500m"
        memory: "512Mi"
    {{- end }}
