* [Topics](/en/topics "Topics")
* [Containers](/en/topics/containers "Containers")
* Introduction to Kubernetes patterns
Introduction to Kubernetes patterns
===================================
Published  January 21, 2020•*4*-minute read
Copy URL
Jump to section
---------------
OverviewKubernetes patternsUse casesKubernetes for the enterprise
Overview
--------
A pattern describes a repeatable solution to a problem. Kubernetes patterns are design patterns for container-based applications and services.
[Kubernetes](/en/topics/containers/what-is-kubernetes) can help developers write [cloud-native apps](/en/topics/cloud-native-apps), and it provides a library of application programing interfaces (APIs) and tools for building applications.
However, Kubernetes doesn’t provide developers and architects with guidelines for how to use these pieces to build a complete system that meets business needs and goals.
Patterns are a way to reuse architectures. Instead of completely creating the architecture yourself, you can use existing Kubernetes patterns, which also ensure that things will work the way they’re supposed to.
When you are trying to deliver important business services on top of Kubernetes, learning through trial and error is too time-consuming, and can result in problems like downtime and disruption.
Think of a pattern like a blueprint; it shows you the way to solve a whole class of similar problems. A pattern is more than just step-by-step instructions for fixing one specific problem.
Using a pattern may result in somewhat different outcomes; they aren’t meant to provide an identical solution. Your system may look different from someone else who used the same pattern. However, both systems will share common characteristics.
By using Kubernetes patterns, developers can create cloud-native apps with Kubernetes as a runtime platform.
Types of Kubernetes patterns
----------------------------
Patterns are the tools needed by a Kubernetes developer, and they will show you how to build your system.
* **Foundational patterns** cover the core concepts of Kubernetes. These patterns are the underlying principles and practices for building container-based cloud-native applications.
* **Behavioral patterns** describe the patterns that sit on top of foundational patterns and add granularity to concepts for managing various types of container and platform interactions.
* **Structural patterns** are related to organizing containers within a Kubernetes pod.
* **Configuration patterns** are used for the various ways application configuration can be handled in Kubernetes. These patterns include the specific steps for connecting applications to their configuration.
* **Advanced patterns** include advanced concepts, such as how the platform itself can be extended or how to build container images directly within the cluster.
Recommended for you
A Platform Engineer's Perspective: Security Policy-as-Code with OpenShift and Ansible
-------------------------------------------------------------------------------------
[Watch the webinar](https://www.redhat.com/en/events/webinar/platform-os-ansible?percmp=RHCTG0250000455235)
Use cases for Kubernetes patterns
---------------------------------
#### Predictable demands patterns
Predictable demands patterns are foundational Kubernetes patterns. This type of pattern ensures that your apps comply with the fundamental principles of containerized apps so that they are ready to be automated using Kubernetes.
Predictable demands patterns explain why every container needs to declare the app resource requirements and runtime dependencies. Defining these requirements allows Kubernetes to choose the right place to deploy the app within your [cluster](/en/topics/containers/what-is-a-kubernetes-cluster).
Examples of what you can define using these patterns are runtime dependencies, resource profiles, pod priority, and project resources.
##### Example: Resource profiles
You will need to specify the resource requirements, such as CPU and memory, of a container in the form of a request and a limit. A request refers to the minimum amount of resources needed, while a limit refers to the maximum amount of resources a container can consume.
The requests amount is used by the scheduler when placing pods to nodes. The scheduler will only schedule a pod to a node that has enough capacity to accommodate it.
If resource requirements aren’t set, the container will be considered a lower priority and killed first if the node runs out of available resources.
### Configuration patterns
All applications require configuration, and although storing configurations in the source code is an easy option, it doesn’t give you the flexibility to adapt configuration without recreating the app image. External configuration allows you to adapt based on the environment.
Configuration patterns will help you to customize and adapt your apps with external configurations for different development, integration, and production environments.
##### Example: EnVar configuration
The EnVar configuration pattern works best for small sets of configuration variables, where universally supported environmental variables can be used to externalize configuration.
Externalizing the configuration of an app allows you to make changes to configuration even after the app has been built, compared with hardcoded configuration that would require a rebuild of the app.
Using environmental variables to externalize configuration works well because any operating system can define these variables and they are accessible by any programming language.
With environmental variables, hardcoded default values are typically defined during build and then overwritten during runtime.
In Kubernetes, variables can be set directly in the pod specification of a controller like [deployment](/en/topics/containers/what-is-kubernetes-deployment) or replica set. You can attach values directly to environmental variables, which can be managed separately from the pod definition.
You can also use a delegation to Kubernetes Secrets (for sensitive data) and ConfigMaps (for non-sensitive configuration).
### Advanced patterns
These patterns include complex topics and the newest pattern implementations. The controller, operator, elastic scale, and [image builder](/en/topics/linux/what-is-an-image-builder) patterns are all examples of advanced Kubernetes patterns.
##### Example: Elastic scale
The elastic scale pattern is used to scale an application horizontally, by adapting the number of pod replicas, vertically, by adapting resource requirements for pods, and can scale the cluster itself by changing the number of cluster nodes.
Although you can handle scale manually, the elastic scale pattern allows Kubernetes to scale automatically based on load.
With Kubernetes, you can change a container’s resources, the desired replicas for a service, or the number of nodes in the cluster. It can also monitor external load and capacity-related events, analyze the container state, and scale for desired performance.
Horizontal pod autoscaling allows you to define an app capacity that is not fixed, but that has enough capacity to handle a varying load. A horizontal pod autoscaler is used to scale pods.
In order to use the horizontal pod autoscaler, the metrics server, a cluster-wide aggregator of resource usage data, needs to be enabled, and a CPU resource limit needs to be defined. You can create a definition for the horizontal pod autoscaler from the command line.
The horizontal pod autoscaler controller continuously retrieves metrics about the pods that are related to scaling, based on the previously determined definition you set from the command line.
It also calculates the required number of replicas based on the current value and the desired value, and changes declared replicas to maintain the new desired state
Kubernetes for the enterprise
-----------------------------
[Red Hat® OpenShift®](/en/technologies/cloud-computing/openshift) is an enterprise-ready Kubernetes platform. It gives developers self-service environments for building, and full-stack automated operations on any infrastructure.
This video can't play due to privacy settings
To change your settings, select the "Cookie Preferences" link in the footer and opt in to "Advertising Cookies or try disabling adblockers."
Red Hat OpenShift includes all of the extra pieces of technology that makes Kubernetes powerful and viable for the enterprise, including: registry, networking, telemetry, security, automation, and services.
With Red Hat OpenShift, developers can make new containerized apps, host them, and deploy them in the cloud with the scalability, control, and orchestration that can turn a good idea into new business quickly and easily.
[Try Red Hat OpenShift](/en/technologies/cloud-computing/openshift/try-it)
Recommended for you
E-book
Hybrid cloud: Foundation for the next era of financial innovation
-----------------------------------------------------------------
Learn how Red Hat OpenShift can help financial institutions optimize their hybrid cloud strategy, ensuring consistency, resiliency, and security.
[Read the e-book](https://www.redhat.com/en/engage/hybrid-cloud-financial-innovation-ebook?percmp=RHCTG0250000455234)
Recommended for you
Red Hat OpenShift Development I: Introduction to Containers with Podman
-----------------------------------------------------------------------
A developer introduction to building and managing containers with Podman for deploying applications on Red Hat OpenShift.
[View course](https://www.redhat.com/en/services/training/do188-red-hat-open-shift-development-introduction-containers-with-podman?percmp=RHCTG0250000455236)
Keep reading
------------
### Containers vs. VMs: Similarities, differences, and combined approaches
Containers and virtual machines (VMs) are different approaches to packaging and isolating computing components. Here's how both approaches can work together.
[Read the article](/en/topics/containers/containers-vs-vms "article | containers vs vms")
### What is a Linux container?
Find out more about Linux containers, which are a set of 1 or more processes that are isolated from the rest of the system.
[Read the article](/en/topics/containers/whats-a-linux-container "article | what is a linux container?")
### What is container orchestration?
Container orchestration automates the deployment, management, scaling, and networking of containers.
[Read the article](/en/topics/containers/what-is-container-orchestration "article | what is container orchestration?")
Containers resources
--------------------
### Related content
* Case study
  [Zurich boosts agility and innovation with Red Hat Cloud Services](/en/resources/zurich-insurance-case-study)
* Case study
  [RTLZWEI hones competitive edge with Red Hat OpenShift AI](/en/resources/rtlzwei-case-study)
* Blog post
  [Ford's keyless strategy for managing 200+ Red Hat OpenShift clusters](/en/blog/fords-keyless-strategy-managing-200-red-hat-openshift-clusters)
* Blog post
  [F5 BIG-IP Virtual Edition is now validated for Red Hat OpenShift Virtualization](/en/blog/f5-big-ip-virtual-edition-now-validated-red-hat-openshift-virtualization)
### Related articles
* [What is CaaS?](/en/topics/cloud-computing/what-is-caas)
* [What is Podman?](/en/topics/containers/what-is-podman)
* [What is Podman Desktop?](/en/topics/containers/what-is-podman-desktop)
* [Containers vs. VMs: Similarities, differences, and combined approaches](/en/topics/containers/containers-vs-vms)
* [Edge computing with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/edge-computing)
* [What is a Linux container?](/en/topics/containers/whats-a-linux-container)
* [What is container orchestration?](/en/topics/containers/what-is-container-orchestration)
* [Stateful vs stateless applications](/en/topics/cloud-native-apps/stateful-vs-stateless)
* [What is Kubernetes?](/en/topics/containers/what-is-kubernetes)
* [Red Hat OpenShift on VMware](/en/technologies/cloud-computing/openshift/vmware)
* [What is KubeVirt?](/en/topics/virtualization/what-is-kubevirt)
* [Why use Red Hat Ansible Automation Platform with Red Hat OpenShift?](/en/technologies/cloud-computing/openshift/ansible-on-openshift)
* [What is the Kubernetes Java client?](/en/topics/cloud-computing/what-is-kubernetes-java-client)
* [What are hosted control planes?](/en/topics/containers/what-are-hosted-control-planes)
* [What is kubernetes security?](/en/topics/containers/kubernetes-security)
* [Red Hat OpenShift for developers](/en/technologies/cloud-computing/openshift/developers)
* [How Kubernetes can help AI/ML](/en/topics/cloud-computing/how-kubernetes-can-help-ai)
* [What is Kubeflow?](/en/topics/cloud-computing/what-is-kubeflow)
* [What are microservices?](/en/topics/microservices/what-are-microservices)
* [What is container security?](/en/topics/security/container-security)
* [OpenShift vs. OpenStack: What are the differences?](/en/technologies/cloud-computing/openshift/openshift-vs-openstack)
* [What are sandboxed containers](/en/topics/containers/sandboxed-containers)
* [What is Buildah?](/en/topics/containers/what-is-buildah)
* [Kubernetes vs OpenStack](/en/topics/openstack/kubernetes-vs-openstack)
* [What are validated patterns?](/en/topics/cloud-computing/what-are-validated-patterns)
* [Kubernetes on AWS: Self-Managed vs. Managed Applications Platforms](/en/topics/containers/kubernetes-on-aws)
* [What is an image builder?](/en/topics/linux/what-is-an-image-builder)
* [Red Hat OpenShift vs. OKD](/en/topics/containers/red-hat-openshift-okd)
* [Red Hat OpenShift vs. Kubernetes: What's the difference?](/en/technologies/cloud-computing/openshift/red-hat-openshift-kubernetes)
* [What is high availability and disaster recovery for containers?](/en/topics/containers/high-availability-containers)
* [Why run Apache Kafka on Kubernetes?](/en/topics/integration/why-run-apache-kafka-on-kubernetes)
* [Spring on Kubernetes with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/spring)
* [What is a golden image?](/en/topics/linux/what-is-a-golden-image)
* [What are Red Hat OpenShift cloud services?](/en/technologies/cloud-computing/openshift/what-are-red-hat-openshift-cloud-services)
* [VNF and CNF, what’s the difference?](/en/topics/cloud-native-apps/vnf-and-cnf-whats-the-difference)
* [What is a container registry?](/en/topics/cloud-native-apps/what-is-a-container-registry)
* [What is Skopeo?](/en/topics/containers/what-is-skopeo)
* [What are Red Hat OpenShift Operators?](/en/technologies/cloud-computing/openshift/what-are-openshift-operators)
* [Using Helm with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/helm)
* [Kubernetes security best practices](/en/topics/containers/kubernetes-security-best-practices)
* [Orchestrating Windows containers on Red Hat OpenShift](/en/technologies/cloud-computing/openshift/windows-containers-on-red-hat-openshift)
* [What is a Kubernetes operator?](/en/topics/containers/what-is-a-kubernetes-operator)
* [High performance computing with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/high-performance-computing)
* [Advantages of Kubernetes-native security](/en/topics/containers/advantages-of-kubernetes-native-security)
* [What is KubeLinter?](/en/topics/containers/what-is-kubelinter)
* [Intro to Kubernetes security](/en/topics/containers/intro-kubernetes-security)
* [Container and Kubernetes compliance considerations](/en/topics/containers/compliance)
* [How microservices support IT integration in healthcare](/en/topics/microservices/microservices-in-healthcare)
* [Kubernetes cluster management](/en/technologies/cloud-computing/openshift/kubernetes-cluster-management)
* [Red Hat OpenShift on IBM IT infrastructure](/en/technologies/cloud-computing/openshift/what-is-red-hat-openshift-on-IBM-IT-infrastructure)
* [Red Hat OpenShift for business leaders](/en/technologies/cloud-computing/openshift/business-leaders)
* [How to deploy Red Hat OpenShift](/en/technologies/cloud-computing/openshift/deploy-red-hat-openshift)
* [Cost management for Kubernetes on Red Hat OpenShift](/en/technologies/cloud-computing/openshift/cost-management)
* [What is enterprise Kubernetes?](/en/topics/containers/what-is-enterprise-kubernetes)
* [What makes Red Hat OpenShift the right choice for IT operations?](/en/technologies/cloud-computing/openshift/it-operations)
* [What makes Red Hat OpenShift the right choice for SAP?](/en/technologies/cloud-computing/openshift/sap)
* [Why choose Red Hat for Kubernetes?](/en/topics/containers/why-choose-red-hat-kubernetes)
* [Kubernetes-native Java development with Quarkus](/en/technologies/cloud-computing/openshift/quarkus)
* [What is Kubernetes role-based access control (RBAC)](/en/topics/containers/what-kubernetes-role-based-access-control-rbac)
* [What is containerization?](/en/topics/cloud-native-apps/what-is-containerization)
* [What was CoreOS and CoreOS container Linux](/en/technologies/cloud-computing/openshift/what-was-coreos)
* [Learning Kubernetes basics](/en/topics/containers/learning-kubernetes-tutorial)
* [What is service-oriented architecture?](/en/topics/cloud-native-apps/what-is-service-oriented-architecture)
* [What is the Kubernetes API?](/en/topics/containers/what-is-the-kubernetes-api)
* [What is Kubernetes cluster management?](/en/topics/containers/what-is-kubernetes-cluster-management)
* [What is a Kubernetes deployment?](/en/topics/containers/what-is-kubernetes-deployment)
* [Why choose the Red Hat build of Quarkus?](/en/topics/cloud-native-apps/why-choose-red-hat-quarkus)
* [Introduction to Kubernetes architecture](/en/topics/containers/kubernetes-architecture)
* [What is a Kubernetes cluster?](/en/topics/containers/what-is-a-kubernetes-cluster)
* [What is Quarkus?](/en/topics/cloud-native-apps/what-is-quarkus)
* [What is Jaeger?](/en/topics/microservices/what-is-jaeger)
* [What is container-native virtualization?](/en/topics/containers/what-is-container-native-virtualization)
* [What is Clair?](/en/topics/containers/what-is-clair)
* [What is Knative?](/en/topics/microservices/what-is-knative)
* [What is etcd?](/en/topics/containers/what-is-etcd)
* [Why choose Red Hat for microservices?](/en/topics/microservices/why-choose-red-hat-microservices)
* [Why choose Red Hat for containers?](/en/topics/containers/why-choose-red-hat-containers)
* [What is Docker?](/en/topics/containers/what-is-docker)
* [What is a Kubernetes pod?](/en/topics/containers/what-is-kubernetes-pod)
[More about this topic](/en/topics/containers "More about this topic")