Notes

检查 K8s Pod

December 13, 2021

SSH K8S Pods 命令

1
k exec --stdin --tty <pod-name> -- /bin/bash

Double Dash

Double Dash 之后的参数不作为 option,而视为 positional parameter

1
grep -- --hello data.txt

上述命令中,grep 将匹配 –hello,而不是将其作为 option

Single Dash

1
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -

bash 末尾的 Dash 会让 bash 读取 stdin,即前面 curl 的输出内容。

参考资料

  1. https://www.codegrepper.com/code-examples/shell/kubectl+ssh+into+pod

  2. https://www.baeldung.com/linux/double-dash-in-shell-commands

  3. https://superuser.com/questions/1388584/what-does-the-last-hyphen-mean-in-options-of-bash