#  Copyright 2018 U.C. Berkeley RISE Lab
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: function-nodes
  labels:
    role: function
spec:
  selector:
    matchLabels:
      role: function
  template:
    metadata:
      labels:
        role: function
    spec:
      nodeSelector:
        role: function
      restartPolicy: Always
      volumes:
      - name: ipc
        hostPath:
          path: /tmp
      hostNetwork: true
      hostIPC: true
      containers:
      - name: function-1
        image: fluentproject/executor
        imagePullPolicy: Always
        env:
        - name: ROUTE_ADDR
          value: ROUTE_ADDR_DUMMY
        - name: MGMT_IP
          value: MGMT_IP_DUMMY
        - name: SCHED_IPS
          value: SCHED_IPS_DUMMY
        - name: THREAD_ID
          value: "0"
        - name: SYSTEM_FUNC
          value: none
        volumeMounts:
        - mountPath: /requests
          name: ipc
      - name: function-2
        image: fluentproject/executor
        imagePullPolicy: Always
        env:
        - name: ROUTE_ADDR
          value: ROUTE_ADDR_DUMMY
        - name: MGMT_IP
          value: MGMT_IP_DUMMY
        - name: SCHED_IPS
          value: SCHED_IPS_DUMMY
        - name: THREAD_ID
          value: "1"
        - name: SYSTEM_FUNC
          value: none
        volumeMounts:
        - mountPath: /requests
          name: ipc
      - name: function-3
        image: fluentproject/executor
        imagePullPolicy: Always
        env:
        - name: ROUTE_ADDR
          value: ROUTE_ADDR_DUMMY
        - name: MGMT_IP
          value: MGMT_IP_DUMMY
        - name: SCHED_IPS
          value: SCHED_IPS_DUMMY
        - name: THREAD_ID
          value: "2"
        - name: SYSTEM_FUNC
          value: none
        volumeMounts:
        - mountPath: /requests
          name: ipc
      - name: cache-container
        image: fluentproject/cache
        imagePullPolicy: Always
        env:
        - name: ROUTE_ADDR
          value: ROUTE_ADDR_DUMMY
        - name: MGMT_IP
          value: MGMT_IP_DUMMY
        volumeMounts:
        - mountPath: /requests
          name: ipc
