Translate concepts/configuration/organize-cluster-access-kubeconfig into Japanese

This commit is contained in:
TAKAHASHI Shuuji
2021-05-09 10:05:59 +00:00
parent cb894d47f2
commit 47a137594b
2 changed files with 52 additions and 95 deletions
@@ -1,155 +1,112 @@
--- ---
title: Organizing Cluster Access Using kubeconfig Files title: kubeconfigファイルを使用してクラスターアクセスを組織する
content_type: concept content_type: concept
weight: 60 weight: 60
--- ---
<!-- overview --> <!-- overview -->
Use kubeconfig files to organize information about clusters, users, namespaces, and kubeconfigを使用すると、クラスターに、ユーザー、名前空間、認証の仕組みに関する情報を組織できます。`kubectl`コマンドラインツールはkubeconfigファイルを使用してクラスターを選択するために必要な情報を見つけ、クラスターのAPIサーバーと通信します。
authentication mechanisms. The `kubectl` command-line tool uses kubeconfig files to
find the information it needs to choose a cluster and communicate with the API server
of a cluster.
{{< note >}} {{< note >}}
A file that is used to configure access to clusters is called クラスターへのアクセスを設定するために使われるファイルは*kubeconfigファイル*と呼ばれます。これは設定ファイルを指すために使われる一般的な方法です。`kubeconfig`という名前を持つファイルが存在するという意味ではありません。
a *kubeconfig file*. This is a generic way of referring to configuration files.
It does not mean that there is a file named `kubeconfig`.
{{< /note >}} {{< /note >}}
By default, `kubectl` looks for a file named `config` in the `$HOME/.kube` directory. デフォルトでは、`kubectl``$HOME/.kube`ディレクトリ内にある`config`という名前のファイルを探します。`KUBECONFIG`環境変数を設定するか、[`--kubeconfig`](/docs/reference/generated/kubectl/kubectl/)フラグで指定することで、別のkubeconfigファイルを指定することもできます。
You can specify other kubeconfig files by setting the `KUBECONFIG` environment
variable or by setting the
[`--kubeconfig`](/docs/reference/generated/kubectl/kubectl/) flag.
For step-by-step instructions on creating and specifying kubeconfig files, see
[Configure Access to Multiple Clusters](/docs/tasks/access-application-cluster/configure-access-multiple-clusters).
kubeconfigファイルの作成と指定に関するステップバイステップの手順を知りたいときは、[複数のクラスターへのアクセスを設定する](/docs/tasks/access-application-cluster/configure-access-multiple-clusters)を参照してください。
<!-- body --> <!-- body -->
## Supporting multiple clusters, users, and authentication mechanisms ## 複数のクラスター、ユーザ、認証の仕組みのサポート
Suppose you have several clusters, and your users and components authenticate 複数のクラスターを持っていて、ユーザーやコンポーネントがさまざまな方法で認証を行う次のような状況を考えてみます。
in a variety of ways. For example:
- A running kubelet might authenticate using certificates. - 実行中のkubeletが証明書を使用して認証を行う可能性がある。
- A user might authenticate using tokens. - ユーザーがトークンを使用して認証を行う可能性がある。
- Administrators might have sets of certificates that they provide to individual users. - 管理者が個別のユーザに提供する複数の証明書を持っている可能性がある。
With kubeconfig files, you can organize your clusters, users, and namespaces. kubeconfigファイルを使用すると、クラスター、ユーザー、名前空間を組織化することができます。また、contextを定義することで、複数のクラスターや名前空間を素早く簡単に切り替えられます。
You can also define contexts to quickly and easily switch between
clusters and namespaces.
## Context ## Context
A *context* element in a kubeconfig file is used to group access parameters kubeconfigファイルの*context*要素は、アクセスパラメーターを使いやすい名前でグループ化するために使われます。各contextは3つのパラメータ、cluster、namespace、userを持ちます。デフォルトでは、`kubectl`コマンドラインツールはクラスターとの通信に*current context*のパラメーターを使用します。
under a convenient name. Each context has three parameters: cluster, namespace, and user.
By default, the `kubectl` command-line tool uses parameters from current contextを選択するには、以下のコマンドを使用します。
the *current context* to communicate with the cluster.
To choose the current context:
``` ```
kubectl config use-context kubectl config use-context
``` ```
## The KUBECONFIG environment variable ## KUBECONFIG環境変数
The `KUBECONFIG` environment variable holds a list of kubeconfig files. `KUBECONFIG`環境変数には、kubeconfigファイルのリストを指定できます。LinuxとMacでは、リストはコロン区切りです。Windowsでは、セミコロン区切りです。`KUBECONFIG`環境変数は必須ではありません。`KUBECONFIG`環境変数が存在しない場合は、`kubectl`はデフォルトのkubeconfigファイルである`$HOME/.kube/config`を使用します。
For Linux and Mac, the list is colon-delimited. For Windows, the list
is semicolon-delimited. The `KUBECONFIG` environment variable is not
required. If the `KUBECONFIG` environment variable doesn't exist,
`kubectl` uses the default kubeconfig file, `$HOME/.kube/config`.
If the `KUBECONFIG` environment variable does exist, `kubectl` uses `KUBECONFIG`環境変数が存在する場合は、`kubectl``KUBECONFIG`環境変数にリストされているファイルをマージした結果を有効な設定として使用します。
an effective configuration that is the result of merging the files
listed in the `KUBECONFIG` environment variable.
## Merging kubeconfig files ## kubeconfigファイルのマージ
To see your configuration, enter this command: 設定ファイルを確認するには、以下のコマンドを実行します。
```shell ```shell
kubectl config view kubectl config view
``` ```
As described previously, the output might be from a single kubeconfig file, 上で説明したように、出力は1つのkubeconfigファイルから作られる場合も、複数のkubeconfigファイルをマージした結果となる場合もあります。
or it might be the result of merging several kubeconfig files.
Here are the rules that `kubectl` uses when it merges kubeconfig files: `kubectl`がkubeconfigファイルをマージするときに使用するルールを以下に示します。
1. If the `--kubeconfig` flag is set, use only the specified file. Do not merge. 1. もし`--kubeconfig`フラグが設定されていた場合、指定したファイルだけが使用されます。マージは行いません。このフラグに指定できるのは1つのファイルだけです。
Only one instance of this flag is allowed.
Otherwise, if the `KUBECONFIG` environment variable is set, use it as a そうでない場合、`KUBECONFIG`環境変数が設定されていた場合には、それをマージするべきファイルのリストとして使用します。`KUBECONFIG`環境変数にリストされたファイルのマージは、次のようなルールに従って行われます。
list of files that should be merged.
Merge the files listed in the `KUBECONFIG` environment variable
according to these rules:
* Ignore empty filenames. * 空のファイルを無視する。
* Produce errors for files with content that cannot be deserialized. * デシリアライズできない内容のファイルに対してエラーを出す。
* The first file to set a particular value or map key wins. * 特定の値やmapのキーを設定する最初のファイルが勝つ。
* Never change the value or map key. * 値やmapのキーは決して変更しない。
Example: Preserve the context of the first file to set `current-context`. 例: 最初のファイルが指定した`current-context`を保持する。
Example: If two files specify a `red-user`, use only values from the first file's `red-user`. 例: 2つのファイルが`red-user`を指定した場合、1つ目のファイルの`red-user`だけを使用する。もし2つ目のファイルの`red-user`以下に競合しないエントリーがあったとしても、それらは破棄する。
Even if the second file has non-conflicting entries under `red-user`, discard them.
For an example of setting the `KUBECONFIG` environment variable, see `KUBECONFIG`環境変数を設定する例については、[KUBECONFIG環境変数を設定する](/ja/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable)を参照してください。
[Setting the KUBECONFIG environment variable](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable).
Otherwise, use the default kubeconfig file, `$HOME/.kube/config`, with no merging. それ以外の場合は、デフォルトのkubeconfigファイル`$HOME/.kube/config`をマージせずに使用します。
1. Determine the context to use based on the first hit in this chain: 1. 以下のチェーンで最初に見つかったものをもとにして、使用するcontextを決定する。
1. Use the `--context` command-line flag if it exists. 1. `--context`コマンドラインフラグが存在すれば、それを使用する。
1. Use the `current-context` from the merged kubeconfig files. 1. マージしたkubeconrfigファイルから`current-context`を使用する。
An empty context is allowed at this point. この時点では、空のcontextも許容されます。
1. Determine the cluster and user. At this point, there might or might not be a context. 1. クラスターとユーザーを決定する。この時点では、contextである場合もそうでない場合もあります。以下のチェーンで最初に見つかったものをもとにして、クラスターとユーザーを決定します。この手順はユーザーとクラスターについてそれぞれ1回ずつ、合わせて2回実行されます。
Determine the cluster and user based on the first hit in this chain,
which is run twice: once for user and once for cluster:
1. Use a command-line flag if it exists: `--user` or `--cluster`. 1. もし存在すれば、コマンドラインフラグ`--user`または`--cluster`を使用する。
1. If the context is non-empty, take the user or cluster from the context. 1. もしcontextが空でなければ、contextからユーザーまたはクラスターを取得する。
The user and cluster can be empty at this point. この時点では、ユーザーとクラスターは空である可能性があります。
1. Determine the actual cluster information to use. At this point, there might or 1. 使用する実際のクラスター情報を決定する。この時点では、クラスター情報は存在しない可能性があります。以下のチェーンで最初に見つかったものをもとにして、クラスター情報の各パーツをそれぞれを構築します。
might not be cluster information.
Build each piece of the cluster information based on this chain; the first hit wins:
1. Use command line flags if they exist: `--server`, `--certificate-authority`, `--insecure-skip-tls-verify`. 1. もし存在すれば、`--server``--certificate-authority``--insecure-skip-tls-verify`コマンドラインフラグを使用する。
1. If any cluster information attributes exist from the merged kubeconfig files, use them. 1. もしマージしたkubeconfigファイルにクラスター情報の属性が存在すれば、それを使用する。
1. If there is no server location, fail. 1. もしサーバーの場所が存在しなければ、マージは失敗する。
1. Determine the actual user information to use. Build user information using the same 1. 使用する実際のユーザー情報を決定する。クラスター情報の場合と同じルールを使用して、ユーザー情報を構築します。ただし、ユーザーごとに許可される認証方法は1つだけです。
rules as cluster information, except allow only one authentication
technique per user:
1. Use command line flags if they exist: `--client-certificate`, `--client-key`, `--username`, `--password`, `--token`. 1. もし存在すれば、`--client-certificate``--client-key``--username``--password``--token`コマンドラインフラグを使用する。
1. Use the `user` fields from the merged kubeconfig files. 1. マージしたkubeconfigファイルの`user`フィールドを使用する。
1. If there are two conflicting techniques, fail. 1. もし2つの競合する方法が存在する場合、マージは失敗する。
1. For any information still missing, use default values and potentially
prompt for authentication information.
## File references
File and path references in a kubeconfig file are relative to the location of the kubeconfig file.
File references on the command line are relative to the current working directory.
In `$HOME/.kube/config`, relative paths are stored relatively, and absolute paths
are stored absolutely.
1. もし何らかの情報がまだ不足していれば、デフォルトの値を使用し、認証情報については場合によってはプロンプトを表示する。
## ファイルリファレンス
kubeconfigファイル内のファイルとパスのリファレンスは、kubeconfigファイルの位置からの相対パスで指定します。コマンドライン上のファイルのリファレンスは、現在のワーキングディレクトリからの相対パスです。`$HOME/.kube/config`内では、相対パスは相対のまま、絶対パスは絶対のまま保存されます。
## {{% heading "whatsnext" %}} ## {{% heading "whatsnext" %}}
* [Configure Access to Multiple Clusters](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) * [複数のクラスターへのアクセスを設定する](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)
* [`kubectl config`](/docs/reference/generated/kubectl/kubectl-commands#config) * [`kubectl config`](/docs/reference/generated/kubectl/kubectl-commands#config)
@@ -232,7 +232,7 @@ contexts:
上記の設定ファイルは、`dev-ramp-up`というコンテキストを表します。 上記の設定ファイルは、`dev-ramp-up`というコンテキストを表します。
## KUBECONFIG環境変数を設定する ## KUBECONFIG環境変数を設定する {#set-the-kubeconfig-environment-variable}
`KUBECONFIG`という環境変数が存在するかを確認してください。もし存在する場合は、後で復元できるようにバックアップしてください。例えば: `KUBECONFIG`という環境変数が存在するかを確認してください。もし存在する場合は、後で復元できるようにバックアップしてください。例えば: