# Copyright (c) 2020-2021 Nordix Foundation.
#
# 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: kube-smp-affinity-amd64
  namespace: kube-system
  labels:
    tier: node
    app: smpaffinity
spec:
  selector:
    matchLabels:
      name: smp-affinity
  template:
    metadata:
      labels:
        name: smp-affinity
        tier: node
        app: smpaffinity
    spec:
      nodeSelector:
        beta.kubernetes.io/arch: amd64
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      serviceAccountName: irq-smp-balance-sa
      initContainers:
      - name: irq-daemon-init
        image: smp-affinity
        command: ['cp', '/irqsmpdaemon', '/host/usr/bin/irqsmpdaemon']
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: smpbin
          mountPath: /host/usr/bin
      containers:
      - name: kube-smpaffinity
        image: smp-affinity
        imagePullPolicy: IfNotPresent
        command:
          - smpaffinity
        env:
          - name: WORKER_NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
        volumeMounts:
        - name: cpustate
          mountPath: /host/var/lib/kubelet/
          readOnly: true
        - name: hostirq
          mountPath:  /host/proc/irq/
        - name: irqbalanceconf
          mountPath:  /host/etc/sysconfig/
      volumes:
        - name: cpustate
          hostPath:
            path: /var/lib/kubelet/
        - name: hostirq
          hostPath:
            path: /proc/irq/
        - name: irqbalanceconf
          hostPath:
            path: /etc/sysconfig/
        - name: smpbin
          hostPath:
            path: /usr/bin/
