Skip to content

Commit

Permalink
Translate concepts/configuration/organize-cluster-access-kubeconfig i…
Browse files Browse the repository at this point in the history
…nto Japanese
  • Loading branch information
shuuji3 committed May 24, 2021
1 parent cb894d4 commit 47a1375
Show file tree
Hide file tree
Showing 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
weight: 60
---

<!-- overview -->

Use kubeconfig files to organize information about clusters, users, namespaces, and
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.
kubeconfigを使用すると、クラスターに、ユーザー、名前空間、認証の仕組みに関する情報を組織できます。`kubectl`コマンドラインツールはkubeconfigファイルを使用してクラスターを選択するために必要な情報を見つけ、クラスターのAPIサーバーと通信します。

{{< note >}}
A file that is used to configure access to clusters is called
a *kubeconfig file*. This is a generic way of referring to configuration files.
It does not mean that there is a file named `kubeconfig`.
クラスターへのアクセスを設定するために使われるファイルは*kubeconfigファイル*と呼ばれます。これは設定ファイルを指すために使われる一般的な方法です。`kubeconfig`という名前を持つファイルが存在するという意味ではありません。
{{< /note >}}

By default, `kubectl` looks for a file named `config` in the `$HOME/.kube` directory.
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).


デフォルトでは、`kubectl``$HOME/.kube`ディレクトリ内にある`config`という名前のファイルを探します。`KUBECONFIG`環境変数を設定するか、[`--kubeconfig`](/docs/reference/generated/kubectl/kubectl/)フラグで指定することで、別のkubeconfigファイルを指定することもできます。

kubeconfigファイルの作成と指定に関するステップバイステップの手順を知りたいときは、[複数のクラスターへのアクセスを設定する](/docs/tasks/access-application-cluster/configure-access-multiple-clusters)を参照してください。

<!-- 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.
- A user might authenticate using tokens.
- Administrators might have sets of certificates that they provide to individual users.
- 実行中のkubeletが証明書を使用して認証を行う可能性がある。
- ユーザーがトークンを使用して認証を行う可能性がある。
- 管理者が個別のユーザに提供する複数の証明書を持っている可能性がある。

With kubeconfig files, you can organize your clusters, users, and namespaces.
You can also define contexts to quickly and easily switch between
clusters and namespaces.
kubeconfigファイルを使用すると、クラスター、ユーザー、名前空間を組織化することができます。また、contextを定義することで、複数のクラスターや名前空間を素早く簡単に切り替えられます。

## Context

A *context* element in a kubeconfig file is used to group access parameters
under a convenient name. Each context has three parameters: cluster, namespace, and user.
By default, the `kubectl` command-line tool uses parameters from
the *current context* to communicate with the cluster.
kubeconfigファイルの*context*要素は、アクセスパラメーターを使いやすい名前でグループ化するために使われます。各contextは3つのパラメータ、cluster、namespace、userを持ちます。デフォルトでは、`kubectl`コマンドラインツールはクラスターとの通信に*current context*のパラメーターを使用します。

current contextを選択するには、以下のコマンドを使用します。

To choose the current context:
```
kubectl config use-context
```

## The KUBECONFIG environment variable
## KUBECONFIG環境変数

The `KUBECONFIG` environment variable holds a list of kubeconfig files.
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`.
`KUBECONFIG`環境変数には、kubeconfigファイルのリストを指定できます。LinuxとMacでは、リストはコロン区切りです。Windowsでは、セミコロン区切りです。`KUBECONFIG`環境変数は必須ではありません。`KUBECONFIG`環境変数が存在しない場合は、`kubectl`はデフォルトのkubeconfigファイルである`$HOME/.kube/config`を使用します。

If the `KUBECONFIG` environment variable does exist, `kubectl` uses
an effective configuration that is the result of merging the files
listed in the `KUBECONFIG` environment variable.
`KUBECONFIG`環境変数が存在する場合は、`kubectl``KUBECONFIG`環境変数にリストされているファイルをマージした結果を有効な設定として使用します。

## Merging kubeconfig files
## kubeconfigファイルのマージ

To see your configuration, enter this command:
設定ファイルを確認するには、以下のコマンドを実行します。

```shell
kubectl config view
```

As described previously, the output might be from a single kubeconfig file,
or it might be the result of merging several kubeconfig files.

Here are the rules that `kubectl` uses when it merges kubeconfig files:

1. If the `--kubeconfig` flag is set, use only the specified file. Do not merge.
Only one instance of this flag is allowed.

Otherwise, if the `KUBECONFIG` environment variable is set, use it as a
list of files that should be merged.
Merge the files listed in the `KUBECONFIG` environment variable
according to these rules:
上で説明したように、出力は1つのkubeconfigファイルから作られる場合も、複数のkubeconfigファイルをマージした結果となる場合もあります。

* 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.
* Never change the value or map key.
Example: Preserve the context of the first file to set `current-context`.
Example: If two files specify a `red-user`, use only values from the first file's `red-user`.
Even if the second file has non-conflicting entries under `red-user`, discard them.
`kubectl`がkubeconfigファイルをマージするときに使用するルールを以下に示します。

For an example of setting the `KUBECONFIG` environment variable, see
[Setting the KUBECONFIG environment variable](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable).
1. もし`--kubeconfig`フラグが設定されていた場合、指定したファイルだけが使用されます。マージは行いません。このフラグに指定できるのは1つのファイルだけです。

Otherwise, use the default kubeconfig file, `$HOME/.kube/config`, with no merging.
そうでない場合、`KUBECONFIG`環境変数が設定されていた場合には、それをマージするべきファイルのリストとして使用します。`KUBECONFIG`環境変数にリストされたファイルのマージは、次のようなルールに従って行われます。

1. Determine the context to use based on the first hit in this chain:
* 空のファイルを無視する。
* デシリアライズできない内容のファイルに対してエラーを出す。
* 特定の値やmapのキーを設定する最初のファイルが勝つ。
* 値やmapのキーは決して変更しない。
例: 最初のファイルが指定した`current-context`を保持する。
例: 2つのファイルが`red-user`を指定した場合、1つ目のファイルの`red-user`だけを使用する。もし2つ目のファイルの`red-user`以下に競合しないエントリーがあったとしても、それらは破棄する。

1. Use the `--context` command-line flag if it exists.
1. Use the `current-context` from the merged kubeconfig files.
`KUBECONFIG`環境変数を設定する例については、[KUBECONFIG環境変数を設定する](/ja/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable)を参照してください。

An empty context is allowed at this point.
それ以外の場合は、デフォルトのkubeconfigファイル`$HOME/.kube/config`をマージせずに使用します。

1. Determine the cluster and user. At this point, there might or might not be a context.
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. 以下のチェーンで最初に見つかったものをもとにして、使用するcontextを決定する。

1. Use a command-line flag if it exists: `--user` or `--cluster`.
1. If the context is non-empty, take the user or cluster from the context.
1. `--context`コマンドラインフラグが存在すれば、それを使用する。
1. マージしたkubeconrfigファイルから`current-context`を使用する。

The user and cluster can be empty at this point.
この時点では、空のcontextも許容されます。

1. Determine the actual cluster information to use. At this point, there might or
might not be cluster information.
Build each piece of the cluster information based on this chain; the first hit wins:
1. クラスターとユーザーを決定する。この時点では、contextである場合もそうでない場合もあります。以下のチェーンで最初に見つかったものをもとにして、クラスターとユーザーを決定します。この手順はユーザーとクラスターについてそれぞれ1回ずつ、合わせて2回実行されます。

1. Use command line flags if they exist: `--server`, `--certificate-authority`, `--insecure-skip-tls-verify`.
1. If any cluster information attributes exist from the merged kubeconfig files, use them.
1. If there is no server location, fail.
1. もし存在すれば、コマンドラインフラグ`--user`または`--cluster`を使用する。
1. もしcontextが空でなければ、contextからユーザーまたはクラスターを取得する。

1. Determine the actual user information to use. Build user information using the same
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. Use the `user` fields from the merged kubeconfig files.
1. If there are two conflicting techniques, fail.
1. 使用する実際のクラスター情報を決定する。この時点では、クラスター情報は存在しない可能性があります。以下のチェーンで最初に見つかったものをもとにして、クラスター情報の各パーツをそれぞれを構築します。

1. For any information still missing, use default values and potentially
prompt for authentication information.
1. もし存在すれば、`--server``--certificate-authority``--insecure-skip-tls-verify`コマンドラインフラグを使用する。
1. もしマージしたkubeconfigファイルにクラスター情報の属性が存在すれば、それを使用する。
1. もしサーバーの場所が存在しなければ、マージは失敗する。

## File references
1. 使用する実際のユーザー情報を決定する。クラスター情報の場合と同じルールを使用して、ユーザー情報を構築します。ただし、ユーザーごとに許可される認証方法は1つだけです。

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. もし存在すれば、`--client-certificate``--client-key``--username``--password``--token`コマンドラインフラグを使用する。
1. マージしたkubeconfigファイルの`user`フィールドを使用する。
1. もし2つの競合する方法が存在する場合、マージは失敗する。

1. もし何らかの情報がまだ不足していれば、デフォルトの値を使用し、認証情報については場合によってはプロンプトを表示する。

## ファイルリファレンス

kubeconfigファイル内のファイルとパスのリファレンスは、kubeconfigファイルの位置からの相対パスで指定します。コマンドライン上のファイルのリファレンスは、現在のワーキングディレクトリからの相対パスです。`$HOME/.kube/config`内では、相対パスは相対のまま、絶対パスは絶対のまま保存されます。

## {{% 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)


Expand Down
Expand Up @@ -232,7 +232,7 @@ contexts:

上記の設定ファイルは、`dev-ramp-up`というコンテキストを表します。

## KUBECONFIG環境変数を設定する
## KUBECONFIG環境変数を設定する {#set-the-kubeconfig-environment-variable}

`KUBECONFIG`という環境変数が存在するかを確認してください。もし存在する場合は、後で復元できるようにバックアップしてください。例えば:

Expand Down

0 comments on commit 47a1375

Please sign in to comment.