Skip to content

k8spatterns/examples

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

Kubernetes Patterns

Kubernetes Patterns - Examples

Creative Commons License

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 April 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 summarised 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.

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 categorised 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

Our sample random generator deals with hard requirements on ConfigMap and PersistentVolumeClaims and resource limits.

Declarative Deployment

Rolling and fixed update of the random generator Deployment from version 1.0 to 2.0.

Health Probe

Liveness, Readiness and Startup probes for the random generator and an example how to readiness gates.

Managed Lifecycle

postStart and preStop hooks are demonstrated with the random generator application.

Automated Placement

These examples demonstrate a node selector, pod and node affinity, taint, and tolerations.

Behavioral Patterns

Batch Job

Generate thousands of random numbers into a file with a batch job

Periodic Job

Reuses the link: behavioral/BatchJob/README.adoc[Batch Job] example, but runs it periodically at a configured schedule

Daemon Service

Sample maintenance script for maintenance jobs on every node of a cluster

Singleton Service

Example of a PodDisruptionBudget for controlling voluntary disruptions

Stateless Service

Example for a stateless service deployed with a ReplicaSet

Stateful Service

StatefulSet example for our random-generator

Service Discovery

Various ways how to access our random-generator REST service

Self Awareness

Using the Downward API for setting environment variables and mounting resource fields as files with the random-generator service.

Structural Patterns

Init Container

Initialize an HTTP server’s HTML source from a remote git repository [*]

Sidecar

Git polling example for a sidecar [*]

Adapter

Adapter for exporting timing information from the sample random-generator application in a Prometheus format [*]

Ambassador

Ambassador for moving on the log of the random-generator [*]

Configuration Patterns

EnvVar Configuration

A simple example of how to use environment variables literally and from ConfigMaps and Secrets for our random-generator service. [*]

Configuration Resource

Example of how to configure the random-generator Spring Boot application with a ConfigMap [*]

Immutable Configuration

[*] Several examples show how to use immutable configuration containers for application configuration. This directory includes examples of the simple Docker case and Kubernetes.

Configuration Template

This example shows how to use a template configuration standalone.xml, which is processed with a template processed and filled with data from ConfigMap before a Wildfly server is started. [*]

Security Patterns

Process Containment

Example of how you can restrict the privileges of containers when running in Kubernetes.

Network Segmentation

This example shows you how you can restrict network access to Pods via Network Policies and how to control HTTP traffic with Istio’s Authentication Policies.

Secure Configuration

Examples show various techniques for storing configuration data securely in a Kubernetes Cluster. [*]

Access Control

Example for Kubernetes' RBAC access control subsystem for controlling the access to the Kubernetes API server. [*]

Advanced Patterns

Controller

A simple, pure 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

Operator based on the ConfigMap watch controller and introduces a CRD ConfigWatcher, which connects a ConfigMap with a set of Pods to restart in case of a config change. [*]

Elastic Scale

Horizontal and vertical scaling examples with the random-generator service [*]

Image Builder

These examples demonstrate the setup of a chained build on OpenShift and use Knative build for doing builds within the cluster. [*]


1. Examples marked with an "*" are still in progress to be updated. We expect to be finished until the end of April 2023

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