由控制器生成的Pod都有一个metadata.ownerReferences
,该字段用于标识该Pod从属于哪一个ReplicaSet。
用如下配置生成一个RS资源:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: nginx
image: nginx
|
使用如下指令进行查看(我实际上使用的是VSCode的插件):
1
2
3
4
|
kubectl get pods frontend-ndlm6 -o yaml
kubectl get pods frontend-ndlm6 -o yaml | grep ownerReferences
|
相关输出如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
metadata:
labels:
tier: frontend
name: frontend-24c4l
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: frontend
uid: 3bdf82b0-7cb0-401f-9294-00d1b969720d
resourceVersion: "8089"
uid: 3e675a1b-2d2c-4a1a-a4d2-ab8daacb6a5c
|