- Getting Started with Kubernetes
- Jonathan Baier Jesse White
- 475字
- 2021-06-10 19:47:07
Labels
Labels give us another level of categorization, which becomes very helpful in terms of everyday operations and management. Similar to tags, labels can be used as the basis of service discovery as well as a useful grouping tool for day-to-day operations and management tasks. Labels are attached to Kubernetes objects and are simple key-value pairs. You will see them on pods, replication controllers, replica sets, services, and so on. Labels themselves and the keys/values inside of them are based on a constrained set of variables, so that queries against them can be evaluated efficiently using optimized algorithms and data structures.
The label indicates to Kubernetes which resources to work with for a variety of operations. Think of it as a filtering option. It is important to note that labels are meant to be meaningful and usable to the operators and application developers, but do not imply any semantic definitions to the cluster. Labels are used for organization and selection of subsets of objects, and can be added to objects at creation time and/or modified at any time during cluster operations. Labels are leveraged for management purposes, an example of which is when you want to know all of the backing containers for a particular service, you can normally get them via the labels on the container which correspond to the service at hand. With this type of management, you often end up with multiple labels on an object.
Kubernetes cluster management is often a cross-cutting operation, involving scaling up of different resources and services, management of multiple storage devices and dozens of nodes and is therefore a highly multi-dimensional operation.
Labels allow horizontal, vertical, and diagonal encapsulation of Kubernetes objects. You'll often see labels such as the following:
- environment: dev, environment: integration, environment: staging, environment: UAT, environment: production
- tier: web, tier: stateless, tier: stateful, tier: protected
- tenancy: org1, tenancy: org2
Once you've mastered labels, you can use selectors to identify a novel group of objects based on a particular set of label combination. There are currently equality-based and set-based selectors. Equality-based selectors allow operators to filter by keys/value pairs, and in order to select(or) an object, it must match all specified constraints. This kind of selector is often used to choose a particular node, perhaps to run against particularly speedy storage. Set-based selectors are more complex, and allow the operator to filter keys according to a specific value. This kind of selector is often used to determine where a object belongs, such as a tier, tenancy zone, or environment.
In short, an object may have many labels attached to it, but a selector can provide uniqueness to an object or set of objects.
We will take a look at labels in more depth later in this chapter, but first we will explore the remaining three constructs: services, replication controllers, and replica sets.
- 反饋系統:多學科視角(原書第2版)
- 并行數據挖掘及性能優化:關聯規則與數據相關性分析
- Visual Basic從初學到精通
- 網絡組建與互聯
- 工業機器人操作與編程
- Microsoft System Center Confi guration Manager
- 從零開始學C++
- Working with Linux:Quick Hacks for the Command Line
- 電氣控制與PLC原理及應用(歐姆龍機型)
- 空間機器人
- TensorFlow Deep Learning Projects
- Natural Language Processing and Computational Linguistics
- Hands-On Business Intelligence with Qlik Sense
- EDA技術及其創新實踐(Verilog HDL版)
- Microsoft 365 Mobility and Security:Exam Guide MS-101