HAOJX

判断某个rs是否从属于某个deployment

字数统计: 56阅读时长: 1 min
2021/11/13 Share

例子

1
2
3
4
5
6
7
8
9
10
11
12
func IsCurrentRsBydep(dep *appsv1.Deployment,rs *appsv1.ReplicaSet) bool{
if rs.ObjectMeta.Annotations["deployment.kubernetes.io/revision"]!=dep.ObjectMeta.Annotations["deployment.kubernetes.io/revision"]{
return false
}

for _, ref:= range rs.OwnerReferences{
if rs.Kind=="Deployment" && rs.Name==dep.Name{
return true
}
}
return false
}
CATALOG