|
1 | 1 | ---
|
2 |
| -title: Organizing Cluster Access Using kubeconfig Files |
| 2 | +title: kubeconfigファイルを使用してクラスターアクセスを組織する |
3 | 3 | content_type: concept
|
4 | 4 | weight: 60
|
5 | 5 | ---
|
6 | 6 |
|
7 | 7 | <!-- overview -->
|
8 | 8 |
|
9 |
| -Use kubeconfig files to organize information about clusters, users, namespaces, and |
10 |
| -authentication mechanisms. The `kubectl` command-line tool uses kubeconfig files to |
11 |
| -find the information it needs to choose a cluster and communicate with the API server |
12 |
| -of a cluster. |
| 9 | +kubeconfigを使用すると、クラスターに、ユーザー、名前空間、認証の仕組みに関する情報を組織できます。`kubectl`コマンドラインツールはkubeconfigファイルを使用してクラスターを選択するために必要な情報を見つけ、クラスターのAPIサーバーと通信します。 |
13 | 10 |
|
14 | 11 | {{< note >}}
|
15 |
| -A file that is used to configure access to clusters is called |
16 |
| -a *kubeconfig file*. This is a generic way of referring to configuration files. |
17 |
| -It does not mean that there is a file named `kubeconfig`. |
| 12 | +クラスターへのアクセスを設定するために使われるファイルは*kubeconfigファイル*と呼ばれます。これは設定ファイルを指すために使われる一般的な方法です。`kubeconfig`という名前を持つファイルが存在するという意味ではありません。 |
18 | 13 | {{< /note >}}
|
19 | 14 |
|
20 |
| -By default, `kubectl` looks for a file named `config` in the `$HOME/.kube` directory. |
21 |
| -You can specify other kubeconfig files by setting the `KUBECONFIG` environment |
22 |
| -variable or by setting the |
23 |
| -[`--kubeconfig`](/docs/reference/generated/kubectl/kubectl/) flag. |
24 |
| - |
25 |
| -For step-by-step instructions on creating and specifying kubeconfig files, see |
26 |
| -[Configure Access to Multiple Clusters](/docs/tasks/access-application-cluster/configure-access-multiple-clusters). |
27 |
| - |
28 |
| - |
| 15 | +デフォルトでは、`kubectl`は`$HOME/.kube`ディレクトリ内にある`config`という名前のファイルを探します。`KUBECONFIG`環境変数を設定するか、[`--kubeconfig`](/docs/reference/generated/kubectl/kubectl/)フラグで指定することで、別のkubeconfigファイルを指定することもできます。 |
29 | 16 |
|
| 17 | +kubeconfigファイルの作成と指定に関するステップバイステップの手順を知りたいときは、[複数のクラスターへのアクセスを設定する](/docs/tasks/access-application-cluster/configure-access-multiple-clusters)を参照してください。 |
30 | 18 |
|
31 | 19 | <!-- body -->
|
32 | 20 |
|
33 |
| -## Supporting multiple clusters, users, and authentication mechanisms |
| 21 | +## 複数のクラスター、ユーザ、認証の仕組みのサポート |
34 | 22 |
|
35 |
| -Suppose you have several clusters, and your users and components authenticate |
36 |
| -in a variety of ways. For example: |
| 23 | +複数のクラスターを持っていて、ユーザーやコンポーネントがさまざまな方法で認証を行う次のような状況を考えてみます。 |
37 | 24 |
|
38 |
| -- A running kubelet might authenticate using certificates. |
39 |
| -- A user might authenticate using tokens. |
40 |
| -- Administrators might have sets of certificates that they provide to individual users. |
| 25 | +- 実行中のkubeletが証明書を使用して認証を行う可能性がある。 |
| 26 | +- ユーザーがトークンを使用して認証を行う可能性がある。 |
| 27 | +- 管理者が個別のユーザに提供する複数の証明書を持っている可能性がある。 |
41 | 28 |
|
42 |
| -With kubeconfig files, you can organize your clusters, users, and namespaces. |
43 |
| -You can also define contexts to quickly and easily switch between |
44 |
| -clusters and namespaces. |
| 29 | +kubeconfigファイルを使用すると、クラスター、ユーザー、名前空間を組織化することができます。また、contextを定義することで、複数のクラスターや名前空間を素早く簡単に切り替えられます。 |
45 | 30 |
|
46 | 31 | ## Context
|
47 | 32 |
|
48 |
| -A *context* element in a kubeconfig file is used to group access parameters |
49 |
| -under a convenient name. Each context has three parameters: cluster, namespace, and user. |
50 |
| -By default, the `kubectl` command-line tool uses parameters from |
51 |
| -the *current context* to communicate with the cluster. |
| 33 | +kubeconfigファイルの*context*要素は、アクセスパラメーターを使いやすい名前でグループ化するために使われます。各contextは3つのパラメータ、cluster、namespace、userを持ちます。デフォルトでは、`kubectl`コマンドラインツールはクラスターとの通信に*current context*のパラメーターを使用します。 |
| 34 | + |
| 35 | +current contextを選択するには、以下のコマンドを使用します。 |
52 | 36 |
|
53 |
| -To choose the current context: |
54 | 37 | ```
|
55 | 38 | kubectl config use-context
|
56 | 39 | ```
|
57 | 40 |
|
58 |
| -## The KUBECONFIG environment variable |
| 41 | +## KUBECONFIG環境変数 |
59 | 42 |
|
60 |
| -The `KUBECONFIG` environment variable holds a list of kubeconfig files. |
61 |
| -For Linux and Mac, the list is colon-delimited. For Windows, the list |
62 |
| -is semicolon-delimited. The `KUBECONFIG` environment variable is not |
63 |
| -required. If the `KUBECONFIG` environment variable doesn't exist, |
64 |
| -`kubectl` uses the default kubeconfig file, `$HOME/.kube/config`. |
| 43 | +`KUBECONFIG`環境変数には、kubeconfigファイルのリストを指定できます。LinuxとMacでは、リストはコロン区切りです。Windowsでは、セミコロン区切りです。`KUBECONFIG`環境変数は必須ではありません。`KUBECONFIG`環境変数が存在しない場合は、`kubectl`はデフォルトのkubeconfigファイルである`$HOME/.kube/config`を使用します。 |
65 | 44 |
|
66 |
| -If the `KUBECONFIG` environment variable does exist, `kubectl` uses |
67 |
| -an effective configuration that is the result of merging the files |
68 |
| -listed in the `KUBECONFIG` environment variable. |
| 45 | +`KUBECONFIG`環境変数が存在する場合は、`kubectl`は`KUBECONFIG`環境変数にリストされているファイルをマージした結果を有効な設定として使用します。 |
69 | 46 |
|
70 |
| -## Merging kubeconfig files |
| 47 | +## kubeconfigファイルのマージ |
71 | 48 |
|
72 |
| -To see your configuration, enter this command: |
| 49 | +設定ファイルを確認するには、以下のコマンドを実行します。 |
73 | 50 |
|
74 | 51 | ```shell
|
75 | 52 | kubectl config view
|
76 | 53 | ```
|
77 | 54 |
|
78 |
| -As described previously, the output might be from a single kubeconfig file, |
79 |
| -or it might be the result of merging several kubeconfig files. |
80 |
| - |
81 |
| -Here are the rules that `kubectl` uses when it merges kubeconfig files: |
82 |
| - |
83 |
| -1. If the `--kubeconfig` flag is set, use only the specified file. Do not merge. |
84 |
| - Only one instance of this flag is allowed. |
85 |
| - |
86 |
| - Otherwise, if the `KUBECONFIG` environment variable is set, use it as a |
87 |
| - list of files that should be merged. |
88 |
| - Merge the files listed in the `KUBECONFIG` environment variable |
89 |
| - according to these rules: |
| 55 | +上で説明したように、出力は1つのkubeconfigファイルから作られる場合も、複数のkubeconfigファイルをマージした結果となる場合もあります。 |
90 | 56 |
|
91 |
| - * Ignore empty filenames. |
92 |
| - * Produce errors for files with content that cannot be deserialized. |
93 |
| - * The first file to set a particular value or map key wins. |
94 |
| - * Never change the value or map key. |
95 |
| - Example: Preserve the context of the first file to set `current-context`. |
96 |
| - Example: If two files specify a `red-user`, use only values from the first file's `red-user`. |
97 |
| - Even if the second file has non-conflicting entries under `red-user`, discard them. |
| 57 | +`kubectl`がkubeconfigファイルをマージするときに使用するルールを以下に示します。 |
98 | 58 |
|
99 |
| - For an example of setting the `KUBECONFIG` environment variable, see |
100 |
| - [Setting the KUBECONFIG environment variable](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable). |
| 59 | +1. もし`--kubeconfig`フラグが設定されていた場合、指定したファイルだけが使用されます。マージは行いません。このフラグに指定できるのは1つのファイルだけです。 |
101 | 60 |
|
102 |
| - Otherwise, use the default kubeconfig file, `$HOME/.kube/config`, with no merging. |
| 61 | + そうでない場合、`KUBECONFIG`環境変数が設定されていた場合には、それをマージするべきファイルのリストとして使用します。`KUBECONFIG`環境変数にリストされたファイルのマージは、次のようなルールに従って行われます。 |
103 | 62 |
|
104 |
| -1. Determine the context to use based on the first hit in this chain: |
| 63 | + * 空のファイルを無視する。 |
| 64 | + * デシリアライズできない内容のファイルに対してエラーを出す。 |
| 65 | + * 特定の値やmapのキーを設定する最初のファイルが勝つ。 |
| 66 | + * 値やmapのキーは決して変更しない。 |
| 67 | + 例: 最初のファイルが指定した`current-context`を保持する。 |
| 68 | + 例: 2つのファイルが`red-user`を指定した場合、1つ目のファイルの`red-user`だけを使用する。もし2つ目のファイルの`red-user`以下に競合しないエントリーがあったとしても、それらは破棄する。 |
105 | 69 |
|
106 |
| - 1. Use the `--context` command-line flag if it exists. |
107 |
| - 1. Use the `current-context` from the merged kubeconfig files. |
| 70 | + `KUBECONFIG`環境変数を設定する例については、[KUBECONFIG環境変数を設定する](/ja/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable)を参照してください。 |
108 | 71 |
|
109 |
| - An empty context is allowed at this point. |
| 72 | + それ以外の場合は、デフォルトのkubeconfigファイル`$HOME/.kube/config`をマージせずに使用します。 |
110 | 73 |
|
111 |
| -1. Determine the cluster and user. At this point, there might or might not be a context. |
112 |
| - Determine the cluster and user based on the first hit in this chain, |
113 |
| - which is run twice: once for user and once for cluster: |
| 74 | +1. 以下のチェーンで最初に見つかったものをもとにして、使用するcontextを決定する。 |
114 | 75 |
|
115 |
| - 1. Use a command-line flag if it exists: `--user` or `--cluster`. |
116 |
| - 1. If the context is non-empty, take the user or cluster from the context. |
| 76 | + 1. `--context`コマンドラインフラグが存在すれば、それを使用する。 |
| 77 | + 1. マージしたkubeconrfigファイルから`current-context`を使用する。 |
117 | 78 |
|
118 |
| - The user and cluster can be empty at this point. |
| 79 | + この時点では、空のcontextも許容されます。 |
119 | 80 |
|
120 |
| -1. Determine the actual cluster information to use. At this point, there might or |
121 |
| - might not be cluster information. |
122 |
| - Build each piece of the cluster information based on this chain; the first hit wins: |
| 81 | +1. クラスターとユーザーを決定する。この時点では、contextである場合もそうでない場合もあります。以下のチェーンで最初に見つかったものをもとにして、クラスターとユーザーを決定します。この手順はユーザーとクラスターについてそれぞれ1回ずつ、合わせて2回実行されます。 |
123 | 82 |
|
124 |
| - 1. Use command line flags if they exist: `--server`, `--certificate-authority`, `--insecure-skip-tls-verify`. |
125 |
| - 1. If any cluster information attributes exist from the merged kubeconfig files, use them. |
126 |
| - 1. If there is no server location, fail. |
| 83 | + 1. もし存在すれば、コマンドラインフラグ`--user`または`--cluster`を使用する。 |
| 84 | + 1. もしcontextが空でなければ、contextからユーザーまたはクラスターを取得する。 |
127 | 85 |
|
128 |
| -1. Determine the actual user information to use. Build user information using the same |
129 |
| - rules as cluster information, except allow only one authentication |
130 |
| - technique per user: |
| 86 | + この時点では、ユーザーとクラスターは空である可能性があります。 |
131 | 87 |
|
132 |
| - 1. Use command line flags if they exist: `--client-certificate`, `--client-key`, `--username`, `--password`, `--token`. |
133 |
| - 1. Use the `user` fields from the merged kubeconfig files. |
134 |
| - 1. If there are two conflicting techniques, fail. |
| 88 | +1. 使用する実際のクラスター情報を決定する。この時点では、クラスター情報は存在しない可能性があります。以下のチェーンで最初に見つかったものをもとにして、クラスター情報の各パーツをそれぞれを構築します。 |
135 | 89 |
|
136 |
| -1. For any information still missing, use default values and potentially |
137 |
| - prompt for authentication information. |
| 90 | + 1. もし存在すれば、`--server`、`--certificate-authority`、`--insecure-skip-tls-verify`コマンドラインフラグを使用する。 |
| 91 | + 1. もしマージしたkubeconfigファイルにクラスター情報の属性が存在すれば、それを使用する。 |
| 92 | + 1. もしサーバーの場所が存在しなければ、マージは失敗する。 |
138 | 93 |
|
139 |
| -## File references |
| 94 | +1. 使用する実際のユーザー情報を決定する。クラスター情報の場合と同じルールを使用して、ユーザー情報を構築します。ただし、ユーザーごとに許可される認証方法は1つだけです。 |
140 | 95 |
|
141 |
| -File and path references in a kubeconfig file are relative to the location of the kubeconfig file. |
142 |
| -File references on the command line are relative to the current working directory. |
143 |
| -In `$HOME/.kube/config`, relative paths are stored relatively, and absolute paths |
144 |
| -are stored absolutely. |
| 96 | + 1. もし存在すれば、`--client-certificate`、`--client-key`、`--username`、`--password`、`--token`コマンドラインフラグを使用する。 |
| 97 | + 1. マージしたkubeconfigファイルの`user`フィールドを使用する。 |
| 98 | + 1. もし2つの競合する方法が存在する場合、マージは失敗する。 |
145 | 99 |
|
| 100 | +1. もし何らかの情報がまだ不足していれば、デフォルトの値を使用し、認証情報については場合によってはプロンプトを表示する。 |
146 | 101 |
|
| 102 | +## ファイルリファレンス |
147 | 103 |
|
| 104 | +kubeconfigファイル内のファイルとパスのリファレンスは、kubeconfigファイルの位置からの相対パスで指定します。コマンドライン上のファイルのリファレンスは、現在のワーキングディレクトリからの相対パスです。`$HOME/.kube/config`内では、相対パスは相対のまま、絶対パスは絶対のまま保存されます。 |
148 | 105 |
|
149 | 106 | ## {{% heading "whatsnext" %}}
|
150 | 107 |
|
151 | 108 |
|
152 |
| -* [Configure Access to Multiple Clusters](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) |
| 109 | +* [複数のクラスターへのアクセスを設定する](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) |
153 | 110 | * [`kubectl config`](/docs/reference/generated/kubectl/kubectl-commands#config)
|
154 | 111 |
|
155 | 112 |
|
|
0 commit comments