Concept Local primitive Distributed primitive Behavior encapsulation Class Container image Behavior instance Object Container Unit of reuse .jar Container image Composition Class A contains Class B Sidecar pattern Inheritance Class A extends Class B A container’s  FROM  parent image Deployment unit .jar / .war / .ear Pod Buildtime/Runtime isolation Module, Package, Class Namespace, Pod, container Initialization preconditions Constructor Init container Postinitialization trigger Init-method postStart Predestroy trigger Destroy-method preStop Cleanup procedure finalize() , shutdown hook Defer container a Asynchronous & parallel execution ThreadPoolExecutor ,  ForkJoinPool Job Periodic task Timer ,  ScheduledExecutorService CronJob Background task Daemon thread DaemonSet Configuration management System.getenv() ,  Properties ConfigMap, Secret Table 1-1. Local and distributed primitives $^{a}$ Defer (or de-init) containers are not yet implemented, but there is a proposal on the way to include this feature in future versions of Kubernetes. We discuss lifecycle hooks in Chapter 5,  Managed Lifecycle . The in-process primitives and the distributed primitives have commonalities, but they are not directly comparable and replaceable. They operate at different abstrac‐ tion levels and have different preconditions and guarantees. Some primitives are sup‐ posed to be used together. For example, we still have to use classes to create objects and put them into container images. However, some other primitives such as Cron‐ Job in Kubernetes can replace the  ExecutorService  behavior in Java completely. Next, let’s see a few distributed abstractions and primitives from Kubernetes that are especially interesting for application developers. Containers  are the building blocks for Kubernetes-based cloud-native applications. If we make a comparison with OOP and Java, container images are like classes, and containers are like objects. The same way we can extend classes to reuse and alter behavior, we can have container images that extend other container images to reuse and alter behavior. The same way we can do object composition and use functionality, we can do container compositions by putting containers into a Pod and using collab‐ orating containers. If we continue the comparison, Kubernetes would be like the JVM but spread over multiple hosts, and would be responsible for running and managing the containers. 4  |  Chapter 1: Introduction Containers