# 
# Copyright 2021 Google LLC
#
# 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
#
#      https://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: node-labeling
  labels:
    app: node-labeling
spec:
  selector:
    matchLabels:
      app: node-labeling
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: node-labeling
        app: node-labeling
    spec:
      serviceAccountName: node-labeling-robot
      automountServiceAccountToken: true
      volumes:
      - name: files
        configMap:
          name: node-labeling-files
      initContainers:
      - image: python:3.8
        name: node-labeling
        command: ["/bin/bash"]
        args: ["-c", "pip3 install -r /etc/node-labeling-app/requirements.txt; python3 /etc/node-labeling-app/main.py --name workload"]
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        volumeMounts:
        - name: files
          mountPath: /etc/node-labeling-app
      containers:
      - image: "gcr.io/google-containers/pause:2.0"
        name: pause
