Kubernetes Classroom Series – 03/July/2021

Pod Affinity and AntiAffinity (Automated Placement)

  • Pod Affinitiy defines the expression where we can schedule the Pod depending on the other Pod i.e. try to run Pod B on the same node where Pod A is running
  • Pod Antiaffinity is try to run Pod B on the Node where Pod A is not running
  • Refer Here for the Pod Affinity Example

Taints and Tolerations

  • Node affinity is a property of Pod that allows them to choose nodes while taints and tolerations are opposite. They allow Nodes to control which Pods should or should not be scheduled.
  • A taint is characteristic of node, when it is present, it prevents Pods from scheduling onto to the node unless Pod has toleration for the taint.
  • By default master has a taint with effect NoSchedule
  • Tainted node
apiVersion: v1
kind: Node
metadata:
  name: master
spec:
  taints:
    - effect: NoSchedule
      key: node-role.kubernetes.io/master
  • Pod tolerating node taints
apiVersion: v1
kind: Pod
metadata:
  name: taint-tolerate-demo
spec:
  containers:
    - image: nginx
      name: tt-container
  tolerations:
    - effect: NoSchedule
      key: node-role.kubernetes.io/master
      operator: Exists

  • There are hard taints prevent schedulint on a node (effect=NoSchedule), soft taints try to avoid scheduling on a node (effect=PreferNoSchedule) and taints that can evict running Pods from a Node (effect=NoExecute)

Behaviroal Patterns

  • The following are popular behaviroal patterns
    • Batch Job
    • Periodic Job
    • Daemon Service
    • Singleton Service
    • Stateful Service
    • Service Discovery
    • Self Awarness

Batch Job

  • This Pattern is suited for managing isolate atomic units of work. It is based on Job abstraction which runs short-lived Pods reliably until completed on a distribute environment
  • Problem:
    • The different ways of creating Pods with Varying characteristics
      • Bare Pod
      • ReplicaSet
      • DaemonSet
    • A common characteristic aspect of these Pods is the fact that they represent long-running processes that are not meant to stop after some time. However in some cases there is need to perform predefined finite unit of work reliably and then shutdown the container.
  • Solution:
    • K8s has a Job resource.
    • Job is similar to Replica Set as it creates one or more Pods and ensures they run successfully. However, the difference is that once the expected number of Pods terminate successfully, the Job is considered complete and no additional Pods will be created.
    • Refer Here

Periodic Job

  • This pattern extends the Batch Job Pattern by adding a time dimension and allowing unit of work to be triggered by an event.
  • Problem:
    • We need to Perform some automated or business tasks which take finite time to run on a schedule
  • Solution:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube