Feat: Support search pods by pod ip (#5921)
feat: support search pods by pod ip Signed-off-by: wenhaozhou <wenhaozhou@yunify.com>
This commit is contained in:
@@ -36,6 +36,7 @@ const (
|
||||
fieldServiceName = "serviceName"
|
||||
fieldPhase = "phase"
|
||||
fieldStatus = "status"
|
||||
fieldPodIP = "podIP"
|
||||
|
||||
statusTypeWaitting = "Waiting"
|
||||
statusTypeRunning = "Running"
|
||||
@@ -103,11 +104,22 @@ func (p *podsGetter) filter(object runtime.Object, filter query.Filter) bool {
|
||||
return statusType == string(filter.Value)
|
||||
case fieldPhase:
|
||||
return string(pod.Status.Phase) == string(filter.Value)
|
||||
case fieldPodIP:
|
||||
return p.podWithIP(pod, string(filter.Value))
|
||||
default:
|
||||
return v1alpha3.DefaultObjectMetaFilter(pod.ObjectMeta, filter)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *podsGetter) podWithIP(item *corev1.Pod, ipAddress string) bool {
|
||||
for _, ip := range item.Status.PodIPs {
|
||||
if strings.Contains(ip.String(), ipAddress) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *podsGetter) podBindPVC(item *corev1.Pod, pvcName string) bool {
|
||||
for _, v := range item.Spec.Volumes {
|
||||
if v.VolumeSource.PersistentVolumeClaim != nil &&
|
||||
|
||||
Reference in New Issue
Block a user