# This YAML file shows how to deploy the snapshot controller

# The snapshot controller implements the control loop for CSI snapshot functionality.
# It should be installed as part of the base Kubernetes distribution in an appropriate
# namespace for components implementing base system functionality. For installing with
# Vanilla Kubernetes, kube-system makes sense for the namespace.

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: snapshot-controller
  namespace: {{ snapshot_controller_namespace }}
spec:
  replicas: {{ snapshot_controller_replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/name: snapshot-controller
  # The snapshot controller won't be marked as ready if the v1 CRDs are unavailable.
  # The flag --retry-crd-interval-max is used to determine how long the controller
  # will wait for the CRDs to become available before exiting. The default is 30 seconds
  # so minReadySeconds should be set slightly higher than the flag value.
  minReadySeconds: 35
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: snapshot-controller
    spec:
      serviceAccountName: snapshot-controller
      containers:
        - name: snapshot-controller
          image: {{ snapshot_controller_image_repo }}:{{ snapshot_controller_image_tag }}
          imagePullPolicy: {{ k8s_image_pull_policy }}
          args:
            - "--v=5"
            - "--leader-election={{ 'true' if snapshot_controller_replicas > 1 else 'false' }}"
