---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tf-controller
  namespace: flux-system
  labels:
    control-plane: tf-controller
spec:
  selector:
    matchLabels:
      control-plane: tf-controller
  replicas: 1
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: manager
      labels:
        control-plane: tf-controller
    spec:
      terminationGracePeriodSeconds: 10
      serviceAccountName: tf-controller
      securityContext:
        fsGroup: 1337
      containers:
      - name: manager
        image: chanwit/tf-controller
        command:
        - /sbin/tini
        - --
        - tf-controller
        args:
        - --watch-all-namespaces
        - --log-level=info
        - --log-encoding=json
        - --enable-leader-election
        - --concurrent=1
        ports:
        - containerPort: 8080
          name: http-prom
        - containerPort: 9440
          name: healthz
          protocol: TCP
        env:
        - name: RUNTIME_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
        readinessProbe:
          httpGet:
            path: /readyz
            port: healthz
        livenessProbe:
          httpGet:
            path: /healthz
            port: healthz
        # TODO(user): Configure the resources accordingly based on the project requirements.
        # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
          requests:
            cpu: 200m
            memory: 64Mi
        volumeMounts:
          - name: temp
            mountPath: /tmp
      volumes:
        - name: temp
          emptyDir: {}
