> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agens.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Helm でインストール

> Agens セルフホスト版を Kubernetes にインストールします。

## 1. 変数を設定する

`CHART_REF` と `REGISTRY_HOST` は、Agens から提供される配布情報を設定します。

```bash theme={null}
CHART_REF="oci://<registry>/<chart>"
CHART_VERSION="1.0.0"
KEY_FILE="./registry-reader.json"
NAMESPACE="agens"
REGISTRY_HOST="<registry-host>"
```

## 2. chart registry にログインする

```bash theme={null}
helm registry login \
  -u _json_key \
  --password-stdin "${REGISTRY_HOST}" < "${KEY_FILE}"
```

## 3. namespace を作成する

```bash theme={null}
kubectl create namespace "${NAMESPACE}" --dry-run=client -o yaml | kubectl apply -f -
```

## 4. imagePullSecret を作成する

```bash theme={null}
kubectl -n "${NAMESPACE}" create secret docker-registry agens-regcred \
  --docker-server="${REGISTRY_HOST}" \
  --docker-username=_json_key \
  --docker-password="$(cat "${KEY_FILE}")" \
  --dry-run=client -o yaml | kubectl apply -f -
```

## 5. 上書き values を作成する

配布された `values.yaml` は Agens のデフォルト設定です。そのまま使い、環境ごとの差分だけを `your-values.yaml` に書きます。

`values.yaml` には実際のシークレット値を入れないでください。DB パスワードや OAuth client secret などは Kubernetes Secret として作成し、`your-values.yaml` から参照します。

```yaml theme={null}
global:
  domain: agens.example.com
  imagePullSecrets:
    - name: agens-regcred
  artifactRegistry:
    location: "<provided-location>"
    projectId: "<provided-project-id>"
    repository: "<provided-repository>"

auth:
  appSecret: "replace-with-random-secret"
  encryptionKey: "replace-with-random-secret"

database:
  postgres:
    password: "replace-with-random-secret"

selfhost:
  allowSignupAfterSetup: false

rustfs:
  accessKey: "replace-with-random-secret"
  secretKey: "replace-with-random-secret"
  ingress:
    host: "storage.agens.example.com"

web:
  publicUrl: "https://app.agens.example.com"
  ingress:
    host: "app.agens.example.com"

server:
  publicUrl: "https://api.agens.example.com"
  ingress:
    host: "api.agens.example.com"

storage:
  s3:
    publicEndpoint: "https://storage.agens.example.com"
```

## 6. デプロイする

```bash theme={null}
helm upgrade --install agens \
  "${CHART_REF}" \
  --version "${CHART_VERSION}" \
  -n "${NAMESPACE}" \
  --create-namespace \
  --timeout 15m \
  -f values.yaml \
  -f your-values.yaml
```

`-f values.yaml -f your-values.yaml` の順で指定します。後に指定した `your-values.yaml` が配布デフォルトを上書きします。

## 7. 確認する

```bash theme={null}
kubectl -n "${NAMESPACE}" get pods
kubectl -n "${NAMESPACE}" get jobs
kubectl -n "${NAMESPACE}" wait --for=condition=complete job/agens-bootstrap --timeout=10m
kubectl -n "${NAMESPACE}" logs job/agens-bootstrap --tail=200
```

期待する状態:

* `agens-web` が running
* `agens-server` が running
* `agens-jobs-worker` が running
* `agens-bootstrap` が completed

## 8. ライセンスキーを登録する

初回ログイン後、Agens UI のライセンス画面で発行済みライセンスキーを登録します。
