Foreword
For most backend developers and even non-backend developers, Kubernetes (hereinafter referred to as K8s) is an indispensable technology in the current cloud-native era. Meanwhile, for programmers of this era, League of Legends (hereinafter referred to as LoL) is a game that has accompanied the growth of many people, including me.
In my work experience, I often find that when team members need to use K8s, they lack the necessary basic understanding of it. However, I noticed that we can always find common ground when talking about LoL. That got me thinking: since K8s has a rather steep learning curve, can we use LoL to help everyone understand what K8s is?
Purpose
The purpose of this article series is to help you better understand, get started with, and master K8s by drawing parallels with LoL.
Core Design Philosophy
Every product has its core design philosophy. For LoL, at its heart, it is a game where the core goal is "to destroy the opponent's base through various means". Whether you focus on minion wave management, eliminating enemy champions, or controlling neutral objectives, everything you do serves this ultimate purpose: destroying the enemy's base.
Similarly, the core design philosophy of K8s is to better manage containers (the concept of containers is beyond the scope of this article and can be researched independently). Whether we create a Deployment, Service, or StatefulSet, our ultimate goal is to manage containers and ensure the smooth operation of the applications packaged within them.
LoL Champions - K8s Containers
A LoL match revolves around the 10 champions selected by the two teams. Different champions have distinct roles: some are Ability Power (AP) mages, others are Attack Damage (AD) carries; some excel at dealing damage, while others specialize in support.
Likewise, a K8s cluster operates around the containers running within it. As described in the official K8s documentation, it is a container orchestration platform. Containers hosting different services require different orchestration strategies: some need persistent data storage, while others only handle stateless requests; some need to expose ports to the outside world, while others operate entirely within the cluster.
LoL Champion Roles - K8s Workload Resources
In LoL, once you have selected your champion, you need to assign it a specific role: top lane, mid lane, bot lane, jungle, or support. Different game scenarios call for different champion roles. For example, a support champion like Janna cannot replace Lee Sin for jungling, and a bruiser like Garen cannot substitute for an ADC like Miss Fortune to deal sustained damage in the late game.
The same logic applies to K8s. Once you have your application images, you need to configure appropriate Workload Resources for them. Workload Resources in K8s are core concepts used to manage the deployment, scaling, and operation of applications. These resources help users define the desired state of applications and automatically reconcile differences between the actual state and the desired state. Below are several key workload resources and their applicable scenarios:
๐ Deployment
Function: Manages a replica set of Pods for stateless applications, supporting declarative updates, rolling upgrades, and rollbacks.
Core Features:
-
Rolling Updates: Controls the update pace using
maxUnavailable(maximum number of unavailable Pods) andmaxSurge(maximum number of extra Pods). - Self-healing: Automatically replaces failed Pods to ensure the desired number of replicas is maintained.
- Version Control: Retains historical versions (10 by default) and supports one-click rollbacks.
Applicable Scenarios:
- Stateless applications such as web services and API gateways.
- Services requiring frequent updates or dynamic scaling (e.g., microservice backends).
๐งฉ StatefulSet
Function: Designed specifically for stateful applications, providing stable network identities and persistent storage.
Core Features:
-
Stable Identities: Pod names are fixed (e.g.,
web-0,web-1), and DNS records are persistent (<pod-name>.<service-name>.svc). -
Persistent Storage: Dynamically creates independent Persistent Volumes (PVs) for each Pod via
volumeClaimTemplates, decoupling data from the Pod lifecycle. -
Ordered Operations: Creates Pods sequentially (
0โ1โ2) and deletes them in reverse order (2โ1โ0); replaces Pods in reverse index order during rolling updates.
Applicable Scenarios:
- Database clusters (MySQL, PostgreSQL) and message queues (Kafka, RabbitMQ).
- Distributed storage systems (Elasticsearch, Cassandra).
Notes:
- Must be paired with a Headless Service (
ClusterIP: None) for DNS resolution. - It is recommended to set the PV reclaim policy to
Retainto prevent accidental data deletion.
๐ก DaemonSet
Function: Ensures that exactly one Pod replica runs on each node (or specified nodes), used for node-level daemons.
Core Features:
- Full Node Coverage: Automatically creates Pods when new nodes join the cluster and deletes them when nodes are removed.
-
Flexible Scheduling: Controls deployment scope using
nodeSelectoror taints and tolerations. - Resource Optimization: Supports resource request/limit configurations to avoid excessive resource consumption on nodes.
Applicable Scenarios:
- Log collection tools (Fluentd, Logstash) and monitoring agents (Prometheus Node Exporter).
- Network plugins (Calico, Flannel) and security scanning tools (Clair).
โก Job
Function: Manages one-time tasks, ensuring that a specified number of Pods run to completion successfully before terminating.
Core Features:
-
Fault Tolerance: Supports retry on failure (number of retries controlled by
backoffLimit). -
Parallelism Control: Sets the number of concurrent Pods via
parallelism.
Applicable Scenarios:
- Batch processing jobs (e.g., data migration) and AI training tasks.
โฑ๏ธ CronJob
Function: A time-scheduled Job controller for executing periodic tasks.
Core Features:
-
Cron Expressions: Flexibly defines task execution times (e.g.,
0 * * * *for hourly execution). - Job Inheritance: Inherits all features of Jobs (e.g., retries, parallelism control).
Applicable Scenarios:
- Scheduled backups, periodic report generation, and resource cleanup tasks.
๐ Workload Resources Comparison Table
| Resource Type | Core Function | Key Features | Typical Scenarios |
|---|---|---|---|
| Deployment | Stateless application management | Rolling updates, auto-scaling, version rollback | Web services, API gateways |
| StatefulSet | Stateful application management | Stable network identities, persistent storage, ordered operations | Database clusters, message queues |
| DaemonSet | Node-level daemon management | Full node coverage, taint toleration, auto-scaling | Log collection, network plugins |
| Job | One-time task execution | Retry on failure, parallelism control | Batch processing, data migration |
| CronJob | Periodic task execution | Time scheduling, Job feature inheritance | Scheduled backups, report generation |
โ Summary:
- Use
Deploymentfor stateless services, andStatefulSet+PVCfor stateful services.- Use
DaemonSetfor node-level tasks (e.g., monitoring), andJob/CronJobfor batch/periodic tasks.- In production environments, combine with resource requests/limits (
resources.requests/limits) to avoid resource contention.
LoL Items - K8s Resource Configurations
In LoL, after selecting your champion and confirming its role, you need to build different items during the match to maximize the champion's effectiveness in that role. For example, ADCs need items like Last Whisper to penetrate the armor of frontline tanks, while tanks rely on items like Randuin's Omen to resist critical strikes.
Similarly, in K8s, once you have your application and configured its workload, you need additional resource configurations to unlock the application's full potential. For instance, if you have an online note-taking application configured with a StatefulSet, you will further need to set up a PVC to enable persistent note storage, and a Service to expose its interfaces outside the cluster. What are the common configurations?
๐น Service
Function: Provides a stable access entry for Pods, enabling service discovery and load balancing.
Types and Scenarios:
- ClusterIP: Internal service communication within the cluster (default type).
- NodePort: Exposes services via node IP + port (suitable for temporary testing).
- LoadBalancer: Production-grade external access in cloud environments (automatically provisions a cloud load balancer).
๐น ConfigMap
Function: Stores non-sensitive configuration data (environment variables, configuration files), decoupling applications from their configurations.
Scenarios:
- Injecting environment variables (e.g., debug switches).
- Mounting configuration files (e.g., Nginx configurations).
- Supports hot updates (automatic synchronization when mounted as a Volume).
๐น Secret
Function: Manages sensitive data (passwords, TLS certificates), stored as Base64-encoded strings.
Types and Scenarios:
- Opaque: Custom sensitive data (e.g., database passwords).
- kubernetes.io/tls: HTTPS certificates (used for Ingress).
- dockerconfigjson: Authentication credentials for private image registries.
๐น Ingress
Function: Manages external HTTP/S traffic routing, supporting domain/path rules and SSL termination.
Core Components:
- Ingress Controller (e.g., Nginx, Traefik) handles traffic routing.
-
Rules: Forward traffic to different Services based on domain names or paths (e.g.,
/apiโ backend service).
๐น PVC (PersistentVolumeClaim)
Function: Declares persistent storage requirements, abstracting underlying storage details.
Scenarios:
- Database persistence (e.g., MySQL data volumes).
- Shared storage (multi-Pod read/write via NFS).
- Dynamic provisioning: Automatically creates PVs through
StorageClass.
๐ Core Comparison Table
| Configuration Object | Core Function | Typical Scenarios |
|---|---|---|
| Service | Service discovery & load balancing | Microservice communication, external traffic access |
| ConfigMap | Non-sensitive configuration management | Application parameters, environment variable injection |
| Secret | Sensitive data storage | Passwords, TLS certificates, API keys |
| Ingress | HTTP/S traffic routing | Multi-domain management, HTTPS termination |
| PVC | Persistent storage declaration | Database storage, log persistence |
โ One-sentence Summary:
- Use
Service/Ingressfor network access,ConfigMap/Secretfor configuration separation, andPVCfor data persistence.- For production environments, the preferred combination is:
LoadBalancer + Ingress + TLS Secret + PVC.
Conclusion
After gaining proficiency in both LoL and K8s, I actually find that LoL is much harder to master. With dozens of champions, each with unique mechanics and abilities, LoL has a far steeper learning curve than K8s. So, if you can get the hang of LoL, mastering K8s will definitely be a piece of cake!




Top comments (0)