News & Events
K8s Design Pattern Mini Series – Behavioral Patterns
- February 12, 2023
- Posted by: Narendra
- Category: K8s Design Patterns Technology
Introduction
The management platform assures the Pods’ lifecycle in these ways. A Pod may be run indefinitely as a batch job or at regular intervals, both of which depend on the workload. This component might function as a daemon or a singleton. When running a Pod, getting the necessary assurances depends on using the correct life-cycle management primitive.
- Batch job patterns
- Stateful Service patterns
- Service Discovery patterns
- Periodic job
- Daemon Service
- Self Awareness
Batch Job Patterns
Batch job patterns define the atomic unit of work.. This pattern works well in a distributed setting when small, independent tasks need to be coordinated.
Click here for batch job pattern
Stateful Service Patterns
Stateful Service explains how to use Kubernetes to make and manage distributed stateful applications. For these kinds of apps to work, they need features like persistent identity, networking, storage, and knowing the order of things. The StatefulSet primitive gives these building blocks strong guarantees that are perfect for managing applications that keep track of state.
Click here for stateful service
Service Discovery Pattern
Service Discovery tells clients how to find and connect to the instances that provide application services. Kubernetes has a number of ways to do this, depending on whether the service consumers and service providers are on or off the cluster.
click here for Service Discovery example
Periodic Job Pattern
Periodic job pattern is used to run a piece of work when an event or a certain time comes up. The cronjob primitive is used to set up jobs that run at regular intervals. You can think of a cronjob as one line in a unix crontab. Kubernetes cronjob is different from Unix cron in that it is highly available and can run based on both time and events. This method is useful when an application needs to do something specific, like send a file or check on another service.
Daemon Service Pattern
Daemons are processes that run programmes automatically and in the background. Running a daemonset on each node to collect cluster logs is an example of how a daemonset may be used to gain insight into a Kubernetes cluster or application, both of which are dispersed by their very nature.
Self Awareness Pattern
Kubernetes apps can use the self-awareness notion, which is implemented as a downward API, to learn more about themselves. It makes it easy to insert metadata and perform introspection on Kubernetes apps. The pod’s environment variables (such POD IP) and files can be used by the containers and the cluster to access the pod’s metadata.
When you consider that Kubernetes is inherently dispersed, the capacity of an application to be aware of its own surroundings becomes extremely potent.