Practical K8s Examples for Beginners and Pros Alike

Logan Jul 13, 2026

In the dynamic world of containerization, Kubernetes (k8s) has emerged as a powerful platform for automating deployment, scaling, and management of containerized applications. With its extensive features and capabilities, k8s offers a rich ecosystem of examples and use cases. Let's delve into some practical examples to illustrate the versatility of Kubernetes.

K8s: Deployments vs StatefulSets vs DaemonSets
K8s: Deployments vs StatefulSets vs DaemonSets

Before we explore specific examples, it's crucial to understand the core concepts of k8s. At its heart, Kubernetes is built around the idea of Pods, which are the smallest and simplest deployable units in the Kubernetes system. A Pod represents a single instance of a running process in your cluster. It's essential to grasp Pods to understand how the other Kubernetes objects function.

K8s raise StatefulSet volume size with low impact
K8s raise StatefulSet volume size with low impact

Deploying Applications with Kubernetes

Kubernetes allows you to deploy various types of applications, from simple web apps to complex, multi-service architectures. Let's discuss two primary methods of application deployment in k8s: Deployment and StatefulSet.

a poster with the words kpi examples for 10 teams
a poster with the words kpi examples for 10 teams

The Deployment controller provides declarative updates for Pods and ReplicaSets. It's ideal for stateless applications, as it ensures that the desired number of Pod replicas are running. On the other hand, StatefulSet is designed to run stateful applications, maintaining a sticky identity for each Pod, making it perfect for databases and other stateful services.

Deploying a Simple Web Application using Deployment

a whiteboard with some writing on it that is written in red and blue ink
a whiteboard with some writing on it that is written in red and blue ink

Let's consider a basic Node.js application hosted on a Linux server. To deploy this application using Kubernetes, you would first need to create a Docker image of the application and push it to a container registry. Then, you can define a Deployment configuration:

apiVersion: apps/v1 kind: Deployment metadata: name: my-web-app spec: replicas: 3 selector: matchLabels: app: my-web-app template: metadata: labels: app: my-web-app spec: containers: - name: my-web-app image: myregistry/my-web-app:1.0 ports: - containerPort: 8080

The above Deployment configuration ensures that three replicas of the 'my-web-app' container are running at all times on available nodes in the cluster.

Tips for 8th grade 💗 🏫
Tips for 8th grade 💗 🏫

Deploying a Stateful Application using StatefulSet

Now let's consider a PostgreSQL database, which is a stateful application. To deploy it using StatefulSet, you would follow these steps. First, create a PersistentVolume (PV) and PersistentVolumeClaim (PVC) for storing data, then define a StatefulSet configuration:

apiVersion: apps/v1 kind: StatefulSet metadata: name: my-postgres spec: replicas: 1 serviceName: "my-postgres" selector: matchLabels: app: my-postgres template: metadata: labels: app: my-postgres spec: volumes: - name: my-pv-storage persistentVolumeClaim: claimName: my-pv-claim containers: - name: my-postgres image: postgres:latest env: - name: PGDATA value: "/var/lib/postgresql/data" ports: - containerPort: 5432 volumeMounts: - name: my-pv-storage mountPath: "/var/lib/postgresql/data"

Master the Cloud: Kubernetes Architecture 🐳☁️
Master the Cloud: Kubernetes Architecture 🐳☁️

In this example, the StatefulSet ensures that the PostgreSQL data directory ('/var/lib/postgresql/data') is stored on the PersistentVolume, maintaining state even if the Pod is restarted or rescheduled.

Managing Services and Networking with Kubernetes

Key Performance Indicators (KPIs) | RingCentral UK Blog
Key Performance Indicators (KPIs) | RingCentral UK Blog
k8s examples
k8s examples
Everything you need to know about Objectives and Key Results (OKRs)
Everything you need to know about Objectives and Key Results (OKRs)
Foods Rich In K2, Vegetables With Vitamin D, Healthy Vitamin K2 Sources, Vitamin D Vegetables, Vitamin K2 Foods, K2 Vitamin Food, K2 Foods Vitamin, Vitamin K2 Sources, Benefits Of K2 Vitamin
Foods Rich In K2, Vegetables With Vitamin D, Healthy Vitamin K2 Sources, Vitamin D Vegetables, Vitamin K2 Foods, K2 Vitamin Food, K2 Foods Vitamin, Vitamin K2 Sources, Benefits Of K2 Vitamin
a poster describing the different types of terms and their corresponding roles in an organization
a poster describing the different types of terms and their corresponding roles in an organization
a large poster with diagrams on it and some words in the bottom right hand corner
a large poster with diagrams on it and some words in the bottom right hand corner
8th grade tips
8th grade tips
Types of Forces Explained | Class 8 Science Notes | US Tuition | Easy Physics Concepts
Types of Forces Explained | Class 8 Science Notes | US Tuition | Easy Physics Concepts
a poster with the words hybridd kernel and an image of a laptop on it
a poster with the words hybridd kernel and an image of a laptop on it
k8s examples
k8s examples
the information sheet for itp's information technology system is shown in green and white
the information sheet for itp's information technology system is shown in green and white
Kaizen means | Kaizen definition | Kaizen Process | Objectives & Examples
Kaizen means | Kaizen definition | Kaizen Process | Objectives & Examples
an info sheet with the words and symbols for each type of language, including japanese characters
an info sheet with the words and symbols for each type of language, including japanese characters
the key principals of systems design are shown in blue and white, with text below it
the key principals of systems design are shown in blue and white, with text below it
a yellow piece of paper with the words learn written on it and an image of two numbers
a yellow piece of paper with the words learn written on it and an image of two numbers
Kv Cache, Visually for creators
Kv Cache, Visually for creators
C++20 / C++23 Range Views
C++20 / C++23 Range Views
Kaizen
Kaizen
Why Kubernetes? Key Business Benefits, Use Cases, and Design Advantages
Why Kubernetes? Key Business Benefits, Use Cases, and Design Advantages
Tips for 8th grade
Tips for 8th grade

Kubernetes Services facilitate networking between Pods and provide stable network identities for them. They enable load balancing, connection pooling, and more. Let's explore Kubernetes Services and Ingress for managing application traffic.

Services allow network access to a set of Pods based on labels, while Ingress serves as the entry point for external traffic into the cluster. It routes traffic to the appropriate Services based on rules defined in an Ingress resource.

Exposing a Deployment using Service

To expose the previously deployed 'my-web-app' Deployment, you can create a Service using the same label selector:

apiVersion: v1 kind: Service metadata: name: my-web-app-service spec: selector: app: my-web-app ports: - protocol: TCP port: 80 targetPort: 8080 type: LoadBalancer

This Service exposes the 'my-web-app' Deployment on port 80 and uses a LoadBalancer service type, allowing external network access via a cloud provider's load balancer.

Routing External Traffic using Ingress

To route external traffic to the 'my-web-app' Service and other Services in the cluster, you can configure an Ingress resource:

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress spec: rules: - host: my.example.com http: paths: - pathType: Prefix path: "/" backend: service: name: my-web-app-service port: number: 80

This Ingress resource routes traffic to the 'my-web-app-service' when the host 'my.example.com' is accessed.

Kubernetes, with its vast ecosystem of tools and plugins, offers countless more examples and use cases. Whether you're containerizing an application, running a machine learning model, or orchestrating a complex microservices architecture, Kubernetes provides the flexibility and power to meet your needs. Embrace the journey of exploration and discovery in the k8s world, and watch your applications soar.