3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kubectl の config ファイルのパスを指定する

Posted at

デフォルトでは $HOME/.kube/config を読み込むようになっているが、以下の方法で指定できる。

  • --kubeconfig フラグ
  • 環境変数 KUBECONFIG
$ kubectl --kubeconfig=/path/to/kubeconfig config get-contexts
$ KUBECONFIG=/path/to/kubeconfig kubectl config get-contexts

優先順的には フラグ > 環境変数 > デフォルト という順番。
path.Join を使っているので separator (Linux/Mac においては :) で複数指定することもできるけどまぁ使わないですかね...

実装はこの辺に。
https://github.com/kubernetes/kubernetes/blob/v1.11.3/staging/src/k8s.io/client-go/tools/clientcmd/loader.go

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?