Commit 0df3f0ef authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #50091 from dixudx/fieldSelector_podIP

Automatic merge from submit-queue (batch tested with PRs 50091, 50231, 50238, 50236, 50243) add fieldSelector podIP **What this PR does / why we need it**: Currently the `fieldSelector` for `Pod` only support `metadata.name`, `metadata.namespace`, `spec.nodeName`, `spec.restartPolicy` and `status.phase`. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50075 **Special notes for your reviewer**: /cc @wojtek-t @caesarxuchao @justinsb @LiliC **Release note**: ```release-note add fieldSelector podIP ```
parents dbc81feb c6cafa57
......@@ -200,6 +200,7 @@ func PodToSelectableFields(pod *api.Pod) fields.Set {
podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName
podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy)
podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase)
podSpecificFieldsSet["status.podIP"] = string(pod.Status.PodIP)
return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true)
}
......
......@@ -82,6 +82,20 @@ func TestMatchPod(t *testing.T) {
fieldSelector: fields.ParseSelectorOrDie("status.phase=Pending"),
expectMatch: false,
},
{
in: &api.Pod{
Status: api.PodStatus{PodIP: "1.2.3.4"},
},
fieldSelector: fields.ParseSelectorOrDie("status.podIP=1.2.3.4"),
expectMatch: true,
},
{
in: &api.Pod{
Status: api.PodStatus{PodIP: "1.2.3.4"},
},
fieldSelector: fields.ParseSelectorOrDie("status.podIP=4.3.2.1"),
expectMatch: false,
},
}
for _, testCase := range testCases {
m := MatchPod(labels.Everything(), testCase.fieldSelector)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment