当前位置:网站首页>[kubernetes guide ⑤] label quick start
[kubernetes guide ⑤] label quick start
2022-06-12 23:11:00 【Bulst】
Label Quick start
Label
Label yes kubernetes An important concept in the system . Its function is to add identification on resources , Used to distinguish and select them .
Label Characteristics :
- One Label Will key/value The form of key-value pairs is attached to various objects , Such as Node、Pod、Service wait
- A resource object can be defined in any number of Label , The same Label It can also be added to any number of resource objects
- Label It is usually determined when the resource object is defined , Of course, you can also add or delete objects dynamically after they are created
Can pass Label Realize multi-dimensional grouping of resources , In order to be flexible 、 Easy resource allocation 、 Dispatch 、 To configure 、 Deployment and other management work .
Some commonly used Label Examples are as follows :
- Version label :“version”:“release”, “version”:“stable”…
- Environment label :“environment”:“dev”,“environment”:“test”,“environment”:“pro”
- Architecture Tags :“tier”:“frontend”,“tier”:“backend”
After the label is defined , Also consider the choice of labels , This is going to use Label Selector, namely :
Label Used to define the identity of a resource object
Label Selector Used to query and filter resource objects with certain tags
There are currently two Label Selector:
Based on equality Label Selector
name = slave: Choose all that contain Label in key="name" And value="slave" The object of
env != production: Select all, including Label Medium key="env" And value It's not equal to "production" The object of
Set based Label Selector
name in (master, slave): Choose all that contain Label Medium key="name" And value="master" or "slave" The object of
name not in (frontend): Choose all that contain Label Medium key="name" And value It's not equal to "frontend" The object of
The selection criteria of the tag can use multiple , There will be multiple Label Selector Are combined , Use a comma "," Just separate . for example :
name=slave,env!=production
name not in (frontend),env!=production
Command mode
# by pod Resource tagging
[[email protected] ~]# kubectl label pod nginx-pod version=1.0 -n dev
pod/nginx-pod labeled
# by pod Resource update tag
[[email protected] ~]# kubectl label pod nginx-pod version=2.0 -n dev --overwrite
pod/nginx-pod labeled
# View tab
[[email protected] ~]# kubectl get pod nginx-pod -n dev --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-pod 1/1 Running 0 10m version=2.0
# Screening tags
[[email protected] ~]# kubectl get pod -n dev -l version=2.0 --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-pod 1/1 Running 0 17m version=2.0
[[email protected] ~]# kubectl get pod -n dev -l version!=2.0 --show-labels
No resources found in dev namespace.
# Remove the label
[[email protected] ~]# kubectl label pod nginx-pod version- -n dev
pod/nginx-pod labeled
Configuration mode
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: dev
labels:
version: "3.0"
env: "test"
spec:
containers:
- image: nginx:latest
name: pod
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
Then you can execute the corresponding update command :kubectl apply -f pod-nginx.yaml
《 Core technology series column summary 》
- 《Java Is the core technology 》
- 《 Middleware core technology 》
- 《 Core technology of microservice 》
- 《 Cloud native core technology 》
- 《 Common business implementation set 》
- 《 Let's go to Dachang series 》
- 《 Open source project o s s a》
need Interview questions of Dachang 、 resume template 、 e-book 、 Learning materials Etc 【 official account 】 reply 「 1024 」 that will do .
边栏推荐
- 应用最广泛的动态路由协议:OSPF
- Zabbix的功能介绍和常用术语
- 细数攻防演练中十大关键防守点
- Lua conditional statement
- Embedded pipeline out of the box
- lua 日期时间
- LeetCode —— 26. Remove duplicates from an ordered array
- Mysql case when then函数使用
- Shardingsphere-proxy-5.0.0 deployment table implementation (I)
- Market trend report, technical innovation and market forecast of Chinese stump crusher
猜你喜欢

C language: how to give an alias to a global variable?

Hostvars in ansible
C语言:如何给全局变量起一个别名?

Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
![LeetCode 890 查找和替换模式[map] HERODING的LeetCode之路](/img/a2/186439a6d50339ca7f299a46633345.png)
LeetCode 890 查找和替换模式[map] HERODING的LeetCode之路

Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle

Qrcodejs2 QR code generation JS

Unprecedented analysis of Milvus source code architecture

The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"

LeetCode 146. LRU cache
随机推荐
Redis实现短信验证码登录
The annual salary of 500000 is one line, and the annual salary of 1million is another line
Dix points de défense clés dans les exercices d'attaque et de défense détaillés
Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation
Embedded pipeline out of the box
What you must know about cloud computing
【LeetCode】300. Longest ascending subsequence
lua 条件语句
iShot
Use of map() function in JS
设计消息队列存储消息数据的 MySQL 表格
China embolic coil market trend report, technical innovation and market forecast
OpenCV源代码编译
〖Kubernetes指南⑤〗Label快速入门
Analysis report on production and marketing demand and investment forecast of China's Melamine Industry from 2022 to 2028
Matters of parent-child class construction method in inheritance
The most widely used dynamic routing protocol: OSPF
Avoid using asp Net core 3.0 to inject services for startup classes
PHP deletes data of the same item in a two-dimensional array
Gradient accumulation in pytorch [during the experiment, due to the limitation of GPU video memory, the batch\u size can no longer be increased. To solve this problem, the gradient accumulation method