public_html
public_html

Reputation: 349

Backup Kubernetes Node

I use 1 master 2 workers Kubernetes Cluster. master and 1. worker: at location a 2. worker: at location b.

Location a and b is very far from each other.

I want to run the pods at location a, but if a down it is created at location b.

I want to create a pod in the worst scenario at location b.

How can I do this in Kubernetes?

Upvotes: 1

Views: 136

Answers (1)

Wytrzymały Wiktor
Wytrzymały Wiktor

Reputation: 13858

This is a community wiki answer.

As @Burak mentioned in his comment:

What you're looking for is node affinity:

– it allows you to constrain which nodes your pod is eligible to be scheduled on, based on labels on the node.

Node affinity is specified as field nodeAffinity of field affinity in the PodSpec.

Here’s an example of a pod that uses node affinity:

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/e2e-az-name
            operator: In
            values:
            - e2e-az1
            - e2e-az2
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        preference:
          matchExpressions:
          - key: another-node-label-key
            operator: In
            values:
            - another-node-label-value
  containers:
  - name: with-node-affinity
    image: k8s.gcr.io/pause:2.0

You can find all the necessary details in the linked documentation.

Please let me know if that helped.

Upvotes: 1

Related Questions