# An example of using the node-stuffing-scheduler
apiVersion: apps/v1
kind: Deployment
metadata:
  name: alpine-stuffing
  labels:
    app: alpine-stuffing
spec:
  replicas: 20
  selector:
    matchLabels:
      app: alpine-stuffing
  template:
    metadata:
      labels:
        app: alpine-stuffing
    spec:
      # Use the 'node-stuffing-scheduler' scheduler
      schedulerName: node-stuffing-scheduler
      containers:
        - image: alpine:3.15.0
          command: ["/bin/sh"]
          args: ["-c", "while true; do sleep 5;done"]
          name: alpine
          resources:
            # Cpu request must be specified, as this will determine how many pods can be scheduled on a single node.
            # If not specified, the pods will be scheduled until the maximum pods per node limit is reached (110 by default)
            requests:
              cpu: 1
              memory: 500m
      affinity:        
        podAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          # This 'preferred' affinity will schedule pods on the node where the same app is already running, thus filling the node
          # until cpu/memory resources are exhausted.
          # Weight *must* be 100 to ensure priority over least cpu-allocated node selection
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - alpine-stuffing
              topologyKey: kubernetes.io/hostname
