#--------------------------------------------------------
# Copyright IBM Corp. 2020. All rights reserved.
# US Government Users Restricted Rights - Use, duplication or disclosure
# restricted by GSA ADP Schedule Contract with IBM Corp.
#--------------------------------------------------------
#
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ibm-lsf-operator
  labels:
    app.kubernetes.io/name: "ibm-spectrum-lsf"
    app.kubernetes.io/managed-by: "lsfclusters.lsf.spectrumcomputing.ibm.com"
    app.kubernetes.io/instance: "lsf"
    release: "lsf"
    lsfversion: "10.1.0.9"
spec:
  replicas: 1
  selector:
    matchLabels:
      name: ibm-lsf-operator
  template:
    metadata:
      labels:
        name: ibm-lsf-operator
        app.kubernetes.io/name: "ibm-spectrum-lsf"
        app.kubernetes.io/managed-by: "lsfclusters.lsf.spectrumcomputing.ibm.com"
        app.kubernetes.io/instance: "lsf"
        release: "lsf"
        lsfversion: "10.1.0.9"
      annotations:
        productID: IBM LSF CE
        productName: IBM Spectrum LSF Community Edition
        productVersion: 10.1.0.9

    spec:
      serviceAccountName: ibm-lsf-operator
      hostIPC: false
      hostNetwork: false
      hostPID: false
      securityContext:
        runAsUser: 1001
        runAsNonRoot: true
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/arch
                operator: In
                values:
                - amd64
                - ppc64le

      containers:
        - name: ansible
          command:
          - /usr/local/bin/ao-logs
          - /tmp/ansible-operator/runner
          - stdout
          # Replace this with the built image name
          image: "ibmcom/lsfce-operator:1.0.1"
          imagePullPolicy: "Always"
          volumeMounts:
          - mountPath: /tmp/ansible-operator/runner
            name: runner
            readOnly: true
          env:
          - name: "ANSIBLE_VERBOSITY"
            value: "3"
          resources:
            limits:
              cpu: "1"
              memory: 1G
            requests:
              cpu: "100m"
              memory: 256M
          livenessProbe:
            exec:
              command:
                - ls
                - /tmp/ansible-operator/runner
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            exec:
              command:
                - ls
                - /tmp/ansible-operator/runner
            initialDelaySeconds: 10
            periodSeconds: 30

          securityContext:
            allowPrivilegeEscalation: true
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: false
        - name: operator
          # Replace this with the built image name
          image: "ibmcom/lsfce-operator:1.0.1"
          imagePullPolicy: "Always"
          volumeMounts:
          - mountPath: /tmp/ansible-operator/runner
            name: runner
          env:
            - name: WATCH_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "ibm-lsf-operator"
          resources:
            limits:
              cpu: "1"
              memory: 1G
            requests:
              cpu: "100m"
              memory: 256M
          securityContext:
            allowPrivilegeEscalation: true
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: false
          livenessProbe:
            exec:
              command:
                - ls
                - /tmp/ansible-operator/runner
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            exec:
              command:
                - ls
                - /tmp/ansible-operator/runner
            initialDelaySeconds: 10
            periodSeconds: 30
      volumes:
        - name: runner
          emptyDir: {}
