Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

デフォルトでは $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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした