AIGC标识 Kubernetes 里主要的资源文件类型和控制器及他们的作用

Here is a comprehensive list of the main Kubernetes resource types (YAML files) and controllers, organized by their function.

🧩 Workload Resources (What to Run)
These resources define the type of application or task you want to deploy. Kubernetes provides several built-in workload resources to manage your containers.

Resource (Kind) | Purpose & Key Characteristics
Pod: The smallest and most basic deployable object. It represents a set of one or more running containers.
Deployment: Manages stateless applications where any Pod is interchangeable. It provides declarative updates, rollbacks, and scaling. Behind the scenes, it manages ReplicaSet objects.
ReplicaSet: Ensures a specified number of identical Pods are running at any given time. It is primarily managed by Deployment objects.
StatefulSet: Used for stateful applications, such as databases. It provides stable, unique network identifiers and persistent storage for each Pod.
DaemonSet: Ensures that a single copy of a Pod runs on every (or a specific subset of) node in the cluster. This is often used for node-level tasks like logging or networking agents.
Job: Creates one or more Pods that run a task to completion and then stop. It's ideal for one-off batch jobs.
CronJob: Manages Jobs that run on a time-based schedule, like a cron job on a Linux system.

🧠 Controllers (The "Why" and "How")
Controllers are the core control loops that make Kubernetes self-healing and declarative. They are not resources you define in a YAML file; instead, they are the internal processes that watch the state of your cluster and take action to make the current state match the desired state you defined in a YAML file.

A controller's job is to constantly observe and reconcile.

Think of it like a thermostat: you set a desired temperature (your YAML file), and the thermostat (controller) continuously checks the room's temperature and turns the heat on or off to match your setting.

The main built-in controllers are part of the kube-controller-manager running on the control plane. These include:
Deployment Controller: Responsible for managing the lifecycle of Deployment objects, including creating and updating ReplicaSets to perform rolling updates.
ReplicaSet Controller: Ensures the correct number of Pods are running for a ReplicaSet object.
Job Controller: Creates and manages Pods for Job objects to ensure they run to completion.
StatefulSet Controller: Manages the unique identities and storage of Pods in a StatefulSet.
DaemonSet Controller: Ensures a Pod is scheduled on every eligible node as defined by a DaemonSet.
Node Controller: Monitors the health of nodes and responds when a node goes down.
Endpoints Controller: Populates the Endpoints object, which is the list of IP addresses that a Service routes traffic to.
Service Account & Token Controllers: Create default service accounts and API access tokens for new namespaces.

image

💾 Configuration & Storage Resources
These resources provide configuration data and persistent storage for your applications.

Resource (Kind) | Purpose
ConfigMap: Stores non-confidential configuration data in key-value pairs, which can be consumed by Pods.
Secret: Similar to a ConfigMap, but specifically designed to store sensitive information, like passwords or API keys, in an encoded format.
PersistentVolumeClaim (PVC): A request for storage by a user. It consumes a PersistentVolume resource.
PersistentVolume (PV): A piece of storage in the cluster that has been provisioned by an administrator.

🌐 Discovery & Load Balancing Resources
These resources define how to expose your applications to internal or external traffic.

Resource (Kind)| Purpose
Service: An abstract way to expose an application running on a set of Pods as a network service.
Ingress: Manages external access to services in a cluster, typically HTTP/HTTPS. It can provide load balancing, SSL termination, and name-based virtual hosting.

🏷️ Metadata Resources
These resources are used to manage the behavior of other resources.

Resource (Kind)| Purpose
HorizontalPodAutoscaler (HPA): Automatically scales the number of Pods in a Deployment, StatefulSet, or ReplicaSet based on observed CPU utilization or other metrics.
LimitRange: Provides constraints on the resource consumption (CPU and memory) for Pods or containers in a namespace.

✨ Advanced Workload Concepts
For more complex scheduling requirements, Kubernetes also has alpha-stage (not fully stable) resources:

Workload: A policy template that defines the scheduling requirements for a group of Pods, such as gang scheduling (all-or-nothing) for distributed machine learning jobs. Workload controllers, like the Job controller, then create runtime objects from these templates.

PodGroup: A runtime object that carries the scheduling policy (e.g., gang or basic) for a group of Pods. It is often created automatically from a Workload template by a controller.

These resources are part of the Kubernetes API and are defined using YAML, representing the desired state of your cluster.

posted @ 2026-07-17 23:39  玛芮娜要强大  阅读(2)  评论(0)    收藏  举报