---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tiny-tools
  # not going to specify namespace, so that 'default' is implied
  # it can be overridden at command line if necessary
  # kubectl apply -f tiny-tools-per-node.yaml -n kube-system
  #namespace: default
spec:
  selector:
    matchLabels:
      app: tiny-tools

  # can scale across all nodes later
  # kubectl scale --replicas=$(kubectl get nodes | tail -n+2 | wc -l) deployment/tiny-tools
  replicas: 1

  template:
    metadata:
      labels:
        app: tiny-tools
      annotations:
        # to avoid istio sidecar auto-injection (if applicable)
        sidecar.istio.io/inject: "false"
    spec:
      affinity:
        # anti-affinity baed on node name
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - tiny-tools
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: tiny-tools
        # https://github.com/giantswarm/tiny-tools
        # https://hub.docker.com/r/giantswarm/tiny-tools/
        image: giantswarm/tiny-tools:3.12
        args:
        - /bin/sh
        - -c
        - touch /tmp/healthy; date; cho "initializing..."; sleep 30d
        livenessProbe:
          exec: 
            command:
            - cat
            - /tmp/healthy
          initialDelaySeconds: 5
          periodSeconds: 10
        readinessProbe:
          exec: 
            command:
            - cat
            - /tmp/healthy
          initialDelaySeconds: 5
          periodSeconds: 10
      # this is the only supported value for 'Deployment'
      restartPolicy: Always
