mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
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 ```
This commit is contained in:
commit
0df3f0ef3e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user