diff --git a/shell/edit/service.vue b/shell/edit/service.vue index cf750f80e6..5f38a08ced 100644 --- a/shell/edit/service.vue +++ b/shell/edit/service.vue @@ -198,7 +198,8 @@ export default { }, watch: { - 'value.spec.selector': 'updateMatchingPods', + 'value.metadata.namespace': 'updateMatchingPods', + 'value.spec.selector': 'updateMatchingPods', 'value.spec.sessionAffinity'(val) { if (val === 'ClientIP') { this.value.spec.sessionAffinityConfig = { clientIP: { timeoutSeconds: null } }; @@ -240,21 +241,22 @@ export default { methods: { updateMatchingPods: throttle(function() { - const { allPods, value: { spec: { selector = { } } } } = this; + const { value: { spec: { selector = { } } } } = this; + const allInNamespace = this.allPods.filter(pod => pod.metadata.namespace === this.value?.metadata?.namespace); if (isEmpty(selector)) { this.matchingPods = { matched: 0, - total: allPods.length, + total: allInNamespace.length, none: true, sample: null, }; } else { - const match = matching(allPods, selector); + const match = matching(allInNamespace, selector); this.matchingPods = { matched: match.length, - total: allPods.length, + total: allInNamespace.length, none: match.length === 0, sample: match[0] ? match[0].nameDisplay : null, };