---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vpa-admission-controller
  namespace: freeleaps-infra-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: vpa-admission-controller
  template:
    metadata:
      labels:
        app: vpa-admission-controller
    spec:
      serviceAccountName: vpa-admission-controller
      securityContext:
        runAsNonRoot: true
        runAsUser: 65534 # nobody
      containers:
        - name: admission-controller
          image: registry.k8s.io/autoscaling/vpa-admission-controller:1.3.0
          imagePullPolicy: IfNotPresent
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          args: ["--v=4", "--stderrthreshold=info", "--reload-cert"]
          volumeMounts:
            - name: tls-certs
              mountPath: "/etc/tls-certs"
              readOnly: true
          resources:
            limits:
              cpu: 200m
              memory: 500Mi
            requests:
              cpu: 50m
              memory: 200Mi
          ports:
            - containerPort: 8000
            - name: prometheus
              containerPort: 8944
      volumes:
        - name: tls-certs
          secret:
            secretName: vpa-tls-certs
---
apiVersion: v1
kind: Service
metadata:
  name: vpa-webhook
  namespace: freeleaps-infra-system
spec:
  ports:
    - port: 443
      targetPort: 8000
  selector:
    app: vpa-admission-controller
