4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

参考

4
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?