Skip to content

Examples for "Kubernetes Patterns - Reusable Elements for Designing Cloud Native Applications", Second Edition

License

Notifications You must be signed in to change notification settings

k8spatterns/examples

Repository files navigation

Kubernetes Patterns

Kubernetes Patterns - Examples

Creative Commons License Link Check

This GitHub project contains the examples from Kubernetes Patterns - Reusable Elements for Designing Cloud Native Applications, Second Edition book by Bilgin Ibryam and Roland Huß

Important
Most of the examples have been updated for this second edition of the book and examples have been added for the new chapters. However, we are not fully finished yet with updating everything. You can follow the status on the example roadmap. We expect to be finished at the end of May 2023. Every pattern that has not yet been updated is listed below with an [*]. Thanks for your patience, and we hope you enjoy the book!
Note
All the examples that we have updated have been checked on minikube or kind with Kubernetes 1.26. If you run in any issues, please open a issue on this repository, we will take as soon as possible.

Installation instructions for the example prerequisites are summarized in INSTALL. By default, you need access to a vanilla Kubernetes installation, like Minikube. However, if add-ons are required, the example description explains this additional requirement.

All of these examples have been tested on Minikube on a macOS with ARM architecture (M1), but they should work on any Kubernetes installation. Be sure to explore the provided example resources, as they contain a wealth of comments and clarifications about the concepts explained in each pattern.

For feedback, issues, or questions in general, please use the issue tracker to open cases. Also, we love contributions like spelling fixes, bug fixes, and improvements;…​ Please open pull requests; we are happy to review them!

Patterns

All examples are categorized according to the Book’s patterns category. Each example is contained in a different directory per pattern and is self-contained. [1]

Foundational Patterns

Predictable Demands

Explore our sample random generator with strict requirements on ConfigMap and PersistentVolumeClaims as well as resource limits.

Declarative Deployment

Learn about rolling and fixed updates for the random generator Deployment from version 1.0 to 2.0.

Health Probe

Discover Liveness, Readiness, and Startup probes for the random generator, along with an example of using readiness gates.

Managed Lifecycle

Examine the implementation of postStart and preStop hooks for the random generator application.

Automated Placement

Dive into examples demonstrating node selector, pod and node affinity, taints, and tolerations.

Behavioral Patterns

Batch Job

Create thousands of random numbers in a file using a batch job.

Periodic Job

Employ the Batch Job example to run periodic jobs according to a predefined schedule.

Daemon Service

Investigate a sample maintenance script for executing maintenance tasks on every node in a cluster.

Singleton Service

Delve into a PodDisruptionBudget example for managing voluntary disruptions.

Stateless Service

Examine a stateless service deployed with a ReplicaSet.

Stateful Service

Explore a StatefulSet example featuring our random-generator.

Service Discovery

Uncover various ways to access our random-generator REST service.

Self Awareness

Utilize the Downward API to set environment variables and mount resource fields as files within the random-generator service.

Structural Patterns

Init Container

Initialize an HTTP server’s HTML source by fetching it from a remote git repository.

Sidecar

Inspect a git polling example implemented as a sidecar.

Adapter

Examine an adapter that exports timing information from the sample random-generator application in a Prometheus-compatible format.

Ambassador

Investigate an ambassador for processing the log of the random-generator.

Configuration Patterns

EnvVar Configuration

Learn how to use environment variables, both literal and sourced from ConfigMaps and Secrets, for our random-generator service.

Configuration Resource

Discover how to configure the random-generator Spring Boot application using a ConfigMap.

Immutable Configuration

Review examples that demonstrate using immutable configuration containers for application configuration in Docker and Kubernetes.

Configuration Template

See how a template configuration standalone.xml is processed using a template processor and filled with data from ConfigMap before starting a Wildfly server.

Security Patterns

Process Containment

Explore how to restrict container privileges when running in Kubernetes.

Network Segmentation

Learn how to limit network access to Pods using Network Policies and control HTTP traffic with Istio’s Authentication Policies.

Secure Configuration [*]

Examine various techniques for securely storing configuration data in a Kubernetes Cluster.

Access Control [*]

Discover Kubernetes' RBAC access control subsystem for managing access to the Kubernetes API server.

Advanced Patterns

Controller

A simple shell-based controller watches ConfigMap resources for changes and restarts Pods using a label selector provided as an annotation. An additional example controller exposes an Ingress route when it detects an exposeService label attached to the service.

Operator

Explore an operator based on the ConfigMap watch controller, introducing a CRD ConfigWatcher that connects a ConfigMap with a set of Pods to restart in case of a config change.

Elastic Scale [*]

Investigate horizontal and vertical scaling examples with the random-generator service.

Image Builder [*]

Examine examples demonstrating the setup of a chained build on OpenShift and using Knative build for performing builds within the cluster.


1. Examples marked with an "*" are still in progress to be updated.

About

Examples for "Kubernetes Patterns - Reusable Elements for Designing Cloud Native Applications", Second Edition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published