<p>In my application, I have a rest server which locally interacts with a database via the command line (it's a long story).  Anyway, the database is mounted in a local ssd on the node.  I can guarantee that only pods of that type will by scheduled in the node pool, as I have tainted the nodes and added tolerances to my pods.</p>

<p>What I want to know is, how can I prevent kubernetes from scheduling multiple instances of my pod on a single node?  I want to avoid this as I want my pod to be able to consume as much CPU as possible, and I also don't want multiple pods to interact via the local ssd.</p>

<p>How do I prevent scheduling of more than one pod of my type onto the node?  I was thinking daemon sets at first, but I think down the line, I want to set my node pool to auto scale, that way when I have n nodes in my pool, and I request n+1 replicas, the node pool automatically scales up.</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/" rel="nofollow noreferrer"><code>Daemonsets</code></a> in combination with <a href="https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#running-pods-on-only-some-nodes" rel="nofollow noreferrer"><code>nodeSelector</code> or <code>affinity</code></a>. Alternatively you could configure <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#never-co-located-in-the-same-node" rel="nofollow noreferrer"><code>podAntiAffinity</code></a> on your <code>Pod</code>s, for example:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: rest-server
spec:
  selector:
    matchLabels:
      app: rest-server
  replicas: 3
  template:
    metadata:
      labels:
        app: rest-server
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - rest-server
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: rest-server
        image: nginx:1.12-alpine
</code></pre>
