Running two kubernetes pods on differents nodes Running two kubernetes pods on differents nodes kubernetes kubernetes

Running two kubernetes pods on differents nodes


Seems like it can be done with Interpod Affinity you can see :

apiVersion: apps/v1kind: Deploymentmetadata:  name: web-serverspec:  selector:    matchLabels:      app: testApp-front  replicas: 3  template:    metadata:      labels:        app: testApp-front    spec:      affinity:        podAntiAffinity:          requiredDuringSchedulingIgnoredDuringExecution:          - labelSelector:              matchExpressions:              - key: app                operator: In                values:                - testApp-front            topologyKey: "kubernetes.io/hostname"        podAffinity:          requiredDuringSchedulingIgnoredDuringExecution:          - labelSelector:              matchExpressions:              - key: app                operator: In                values:                - store            topologyKey: "kubernetes.io/hostname"      containers:      - name: web-testApp-front        image: nginx:1.12-alpine

you can see the full example here


I think you need the concept of pod anti-affinity. This is within one cluster to take care that pods do not reside on one worker-node. https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity


very simple you can use deamon set to run every pod in diffrent node or as the others said you can use pod anti-affinity