---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: eno-controller
  labels:
    app: eno-controller
spec:
  strategy:
    type: RollingUpdate
  replicas: 2
  selector:
    matchLabels:
      app: eno-controller
  template:
    metadata:
      labels:
        app: eno-controller
      annotations:
        prometheus.io/port: "8080"
        prometheus.io/path: /metrics
        prometheus.io/scrape: "true"
    spec:
      serviceAccountName: eno
      containers:
      - name: eno-controller
        image: $REGISTRY/eno-controller:$TAG
        args:
        - --executor-image=$REGISTRY/eno-controller:$TAG
        - --leader-election
        - --leader-election-id=controller
        - --synthesizer-pod-service-account=eno
        resources:
          requests:
            cpu: 50m
            memory: 42Mi
          limits:
            cpu: 250m
            memory: 42Mi
        env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: GOMAXPROCS 
            value: "1"
          - name: GOMEMLIMIT
            valueFrom:
              resourceFieldRef:
                resource: limits.memory
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
            scheme: HTTP

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: eno-reconciler
  labels:
    app: eno-reconciler
spec:
  strategy:
    type: RollingUpdate
  replicas: 2
  selector:
    matchLabels:
      app: eno-reconciler
  template:
    metadata:
      labels:
        app: eno-reconciler
      annotations:
        prometheus.io/port: "8080"
        prometheus.io/path: /metrics
        prometheus.io/scrape: "true"
    spec:
      serviceAccountName: eno
      containers:
      - name: eno-reconciler
        image: $REGISTRY/eno-reconciler:$TAG
        args:
        - --leader-election
        - --leader-election-id=reconciler
        env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: GOMAXPROCS 
            value: "1"
          - name: GOMEMLIMIT
            valueFrom:
              resourceFieldRef:
                resource: limits.memory
        resources:
          requests:
            cpu: 50m
            memory: 64Mi
          limits:
            cpu: 1
            memory: 256Mi
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
            scheme: HTTP

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: eno

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: eno-cluster-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: eno
  namespace: default
