mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
added serviceAccountName to field selectors
This commit is contained in:
parent
337dfe0a9c
commit
4ba7fd5f3c
@ -162,6 +162,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
"spec.nodeName",
|
||||
"spec.restartPolicy",
|
||||
"spec.schedulerName",
|
||||
"spec.serviceAccountName",
|
||||
"status.phase",
|
||||
"status.podIP",
|
||||
"status.nominatedNodeName":
|
||||
|
@ -237,10 +237,11 @@ func PodToSelectableFields(pod *api.Pod) fields.Set {
|
||||
// amount of allocations needed to create the fields.Set. If you add any
|
||||
// field here or the number of object-meta related fields changes, this should
|
||||
// be adjusted.
|
||||
podSpecificFieldsSet := make(fields.Set, 8)
|
||||
podSpecificFieldsSet := make(fields.Set, 9)
|
||||
podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName
|
||||
podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy)
|
||||
podSpecificFieldsSet["spec.schedulerName"] = string(pod.Spec.SchedulerName)
|
||||
podSpecificFieldsSet["spec.serviceAccountName"] = string(pod.Spec.ServiceAccountName)
|
||||
podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase)
|
||||
podSpecificFieldsSet["status.podIP"] = string(pod.Status.PodIP)
|
||||
podSpecificFieldsSet["status.nominatedNodeName"] = string(pod.Status.NominatedNodeName)
|
||||
|
@ -86,6 +86,20 @@ func TestMatchPod(t *testing.T) {
|
||||
fieldSelector: fields.ParseSelectorOrDie("spec.schedulerName=scheduler2"),
|
||||
expectMatch: false,
|
||||
},
|
||||
{
|
||||
in: &api.Pod{
|
||||
Spec: api.PodSpec{ServiceAccountName: "serviceAccount1"},
|
||||
},
|
||||
fieldSelector: fields.ParseSelectorOrDie("spec.serviceAccountName=serviceAccount1"),
|
||||
expectMatch: true,
|
||||
},
|
||||
{
|
||||
in: &api.Pod{
|
||||
Spec: api.PodSpec{SchedulerName: "serviceAccount1"},
|
||||
},
|
||||
fieldSelector: fields.ParseSelectorOrDie("spec.serviceAccountName=serviceAccount2"),
|
||||
expectMatch: false,
|
||||
},
|
||||
{
|
||||
in: &api.Pod{
|
||||
Status: api.PodStatus{Phase: api.PodRunning},
|
||||
|
Loading…
Reference in New Issue
Block a user