Replicas in kubernetes between nodes

0

I am currently deploying from my local machine in kubernetes with the following commands

docker push  xxxdev.azurecr.io/xxxxoapi:latest 
kubectl run xxxxapi --image=xxxxdev.azurecr.io/travelexpensesparametroapi:latest --replicas=2 --labels app=apixxx

kubectl expose  deployments xxxxxoapi  --port=80 --name=servicio-xxxx --type=NodePort

The previous commands only replicate in the same way, how can I replicate between different nodes in order that if a node should die the pods within the other deployments keep responding?

    
asked by Felix David Hernandez Aldana 02.08.2018 в 15:42
source

1 answer

1

You have to add anti-affinity between your pod's example:

 affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            -
              labelSelector:
                matchExpressions:
                  -
                    key: app
                    operator: In
                    values:
                      - apixxx
              topologyKey: kubernetes.io/hostname
    
answered by 09.12.2018 в 18:01