如何在Kubernetes Dashboard中使用标签筛选或选择Pod?
Awesome question! I’ve done this countless times, so let me break down exactly how to replicate that kubectl get pods -l environment=production,tier=frontend behavior in the Kubernetes Dashboard.
步骤1:进入Pod列表页面
First up, log into your Kubernetes Dashboard. On the left-hand navigation menu, find and click Pods (it’s usually nested under the Workloads section) to pull up the full list of your cluster’s Pods.
步骤2:执行标签筛选(两种方式可选)
At the top of the Pod list page, you’ll see a search/filter bar with a magnifying glass icon. Here are two ways to get the exact filter you want:
方式一:直接用kubectl风格的标签语法
Just type the same label selector you use in kubectl directly into the filter bar:
environment=production,tier=frontend
Hit enter, and the page will instantly filter to show only Pods that have both the environment=production and tier=frontend labels—exactly matching your kubectl command’s output.
方式二:可视化筛选器(更适合新手)
If you prefer clicking over typing, use the Dashboard’s built-in visual filter tool:
- Click the Add filter button (looks like a plus sign) next to the search bar
- From the dropdown, select Label as the filter type
- In the first input field, enter
environment; in the second, enterproduction, then click "Add" - Repeat the process: add another label filter for
tierequalsfrontend - The list will automatically update to show only Pods that meet both label criteria
Bonus: Advanced label filtering
You can also use more complex kubectl-compatible selector syntax in the filter bar if you need it:
- Filter Pods with
environmentset to eitherproductionorstaging:environment in (production,staging) - Show all Pods that have a
tierlabel (any value):tier - Exclude Pods with an
environmentlabel:!environment
内容的提问来源于stack exchange,提问作者wesnica

