0

bellow works fine, k8s runs one pod each node, but issue when one of nodes fails, k8s creates 2 pods in a node. Is it possible only one pod in a node?

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: testpod
spec:
  replicas: 3
  selector:
    matchLabels:
      app: testpod
  serviceName: "srv"
  template:
    metadata:
      labels:
        app: testpod
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: "app"
                    operator: In
                    values:
                    - testpod
              topologyKey: "kubernetes.io/hostname"
      containers:
akahhor
  • 101
  • 6
  • If you want to run one pod on each node in cluster, you may use DaemonSet, which was created exactly for this purpose. What is your end goal here? To have a pod on each node in cluster, or to have, for example, 3 pods on 5 nodes, but no more that 2 pods on each node? – Andrew Apr 06 '21 at 14:15
  • is it possible in daemonset make pod name static like StatefulSet ? example: podname-0, podname-1 – akahhor Apr 07 '21 at 04:39
  • do you have cluster autoscalar setup to scale up new nodes when one of them goes down? if not, do you have more than the replica number of nodes so that the scheduler does have nodes to schedule new pods on in case one of the nodes get deleted? – Krishna Chaurasia Apr 07 '21 at 04:48

0 Answers0