LoginSignup
2
1

kubectlのlabel selectorが意外と便利

Posted at

label selectorとは

こんな感じで特定のラベルを持つリソースをフィルターするヤツ。

kubectl get pods -l environment=develop
kubectl get node -l 'pool in (apl, ingress)'

等価ベース

=, ==, !=が使える。

environment = production
tier != frontend

集合ベース

めっちゃ便利。

  • キーがenvironmentで値がproduction or qaのリソース
environment in (production, qa)
  • キーがtierで値がではないfrontend or backendのリソース、もしくはキーがtierのラベルを持たないすべてのリソース
tier notin (frontend, backend)
  • キーがpartitionのラベルを持つすべてのリソース
partition
  • キーがpartitionのラベルを持たないすべてのリソース
!partition

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1