これは何
KubernetesのNodeのTaintsだけをバーッと見たいけど現時点では良いコマンドが無いので、jq
でkubectl describe node
から整形する。
WindowsのPowerShellで実現したい。
全体
- PowerShellで
chocolatey
をインストールする -
chocolatey
でjq
をインストールする -
kubectl describe node
の結果をjq
で整形する
PowerShellでchocolatey
をインストールする
PowerShellを管理者として実行
省略
公式サイトに従いchocolatey
をインストールする
公式
https://chocolatey.org/install
Step2のindividualを参照
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Restricted
「Restricted
が返ってきた場合」の手順もあるので、従う
PS C:\WINDOWS\system32> Set-ExecutionPolicy AllSigned
PS C:\WINDOWS\system32> Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
これでインストール完了
動作確認
PS C:\WINDOWS\system32> choco
Chocolatey v0.10.15
Please run 'choco -?' or 'choco <command> -?' for help menu.
chocolatey
でjq
をインストールする
公式サイトに従いjq
をインストールする
公式
https://stedolan.github.io/jq/download/
PS C:\WINDOWS\system32> chocolatey install jq
動作確認
PS C:\WINDOWS\system32> jq
jq - commandline JSON processor [version 1.6]
Usage: C:\ProgramData\chocolatey\lib\jq\tools\jq.exe [options] <jq filter> [file...]
C:\ProgramData\chocolatey\lib\jq\tools\jq.exe [options] --args <jq filter> [strings...]
C:\ProgramData\chocolatey\lib\jq\tools\jq.exe [options] --jsonargs <jq filter> [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.
The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq
Example:
$ echo '{"foo": 0}' | jq .
{
"foo": 0
}
For a listing of options, use C:\ProgramData\chocolatey\lib\jq\tools\jq.exe --help.
kubectl describe node
の結果をjq
で整形する
とりあえず各NodeのNode名とTaintsを表示してみる。
PS C:\WINDOWS\system32> kubectl get nodes -o json | jq ".items[]|{name:.metadata.name, taints:.spec.taints}"
{
"name": "ip-10-0-1-174.us-east-2.compute.internal",
"taints": null
}
{
"name": "ip-10-0-54-134.us-east-2.compute.internal",
"taints": [
{
"effect": "NoSchedule",
"key": "dedicated",
"value": "groupName"
}
]
}
{
"name": "ip-10-0-91-149.us-east-2.compute.internal",
"taints": null
}
おわり
taintsを取得するコマンドはなぜ無いのだろう。