feat: k8s デプロイ用マニフェストとイメージビルドスクリプトを追加 - #31
Open
mhaya wants to merge 1 commit into
Open
Conversation
weko-k8s の web デプロイ (deploy/weko/manifest_template/deploy-web.yaml + scripts/make_weko_manifests.sh + scripts/deploy_weko.sh) の流儀に揃えて、 k8s 上で動かすためのテンプレートと運用スクリプトを追加する。 - deploy/jcgroups/manifest_template: __PLACEHOLDER__ 入りのマニフェスト。 nginx / web / worker を 1 Pod 3 コンテナに同居させ、hostAliases で nginx イメージに焼き込まれた upstream `web:5050` を 127.0.0.1 に向ける - deploy/middleware: 検証用の単一インスタンス PostgreSQL / Redis / RabbitMQ - scripts/build_images.sh: アプリ / nginx イメージのビルド。Nuxt の serverName は ビルド時に静的 SPA へ展開されるため、--build-arg SERVER_NAME で FQDN を注入する - scripts/make_jcgroups_manifests.sh: params.env からマニフェストと server.config.toml / shibboleth2.xml / 証明書を生成する。設定ファイルは テンプレートを複製せずリポジトリ本体を唯一の正として環境依存の値だけ上書きし、 [develop] を除去して置換結果を assert する - scripts/deploy_jcgroups.sh / delete_jcgroups.sh: 生成物の適用と削除 ミドルウェアは JAIRO Cloud 共通クラスタ (pgpool.weko3pg / weko-sentinel-service.weko3re / weko-rabbitmq.weko3ra) を使う前提を既定とし、 Redis は Sentinel 接続と DB 番号の明示に対応する。共有 Redis では DB 番号が 機関ごとに払い出し済みのため、リポジトリ既定値 (0/1/2) の暗黙利用を禁止する。 nginx/Dockerfile には SERVER_NAME の build-arg を追加した。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
JAIRO Cloud Groups Manager を k8s 上で動かすためのイメージビルド手順とマニフェストを追加します。構成・命名・スクリプトの流儀は
weko-k8sの web デプロイ (deploy/weko/manifest_template/deploy-web.yaml+scripts/make_weko_manifests.sh+scripts/deploy_weko.sh) に揃えました。ミドルウェア (PostgreSQL / Redis / RabbitMQ) は JAIRO Cloud 共通クラスタを使う前提 を既定にしています。
構成
nginx / web / worker を 1 Pod に同居させています。
nginx/shibd/shibauthorizer/shibresponderは Unix ドメインソケットで通信するため、そもそも同居が必須upstream api_server { server web:5050; }が焼き込まれているので、hostAliasesでwebを127.0.0.1に向ける。これにより nginx が起動時に解決した ClusterIP をキャッシュし続ける問題 (Pod 入れ替え後の 502) を回避できる追加したもの
k8s/deploy/jcgroups/manifest_template/__PLACEHOLDER__入りのマニフェスト (deploy-web / service / ingress / configmap / secret / volume-pv / volume-pvc / job-db-init / namespace)k8s/deploy/jcgroups/params.env.examplek8s/deploy/middleware/k8s/scripts/build_images.shk8s/scripts/make_jcgroups_manifests.shk8s/scripts/deploy_jcgroups.sh/delete_jcgroups.shk8s/README.mdnginx/DockerfileにARG SERVER_NAMEを追加しました。Nuxt のserverName(configs/app.config.ts) はビルド時に静的 SPA へインライン展開されるため実行時に差し替えられず、FQDN ごとにイメージをビルドし直す必要があります。build_images.shは--build-arg SERVER_NAMEで注入し、生成物を grep して実際に入ったかを確認します。.gitignoreにparams.envを追加しました (secret_key/ DB パスワードが入るため)。設定ファイルの生成方針
server.config.tomlとshibboleth2.xmlはテンプレートを複製せず、リポジトリのconfigs/server.config.toml/nginx/shibboleth2.xmlを唯一の正として環境依存の値だけを上書きします (設定項目が増えても追従漏れが起きないようにするため)。生成時に[develop]セクションを丸ごと落とし、置換結果を assert します。共通ミドルウェアを使う上での注意
databases 40000)、DB 番号は機関ごとに払い出し済みです。RedisSentinelCacheのときはREDIS_DB_APP_CACHE/_ACCOUNT_STORE/_RESULT_BACKENDの明示を必須にし、リポジトリ既定値 (0/1/2) の暗黙利用を禁止しています (未指定・重複はスクリプトが停止)REDIS_DB_GROUP_CACHEは 4 固定。WEKO のGROUP_INFO_REDIS_DB = 4と揃える必要があり、ここが WEKO との唯一の実行時結合点ですflask db initが作りますmake_rabbitmq_vhost.shと同じ流儀で専用 vhost を作ります手順は
k8s/README.mdに記載しています。検証
kind (k8s v1.34) で実デプロイして確認しました。
共通構成
kubectl apply --dry-run=server --validate=strict通過GET /200 /GET /_nuxt/*.js200 /GET /api/auth/check401 (nginx → hostAliases → uwsgi) /GET /api/dev/accounts404 /GET /Shibboleth.sso/Metadata200runAsUser: 1000)delete_jcgroups.sh→deploy_jcgroups.sh --skip-db-initで既存 DB を保持して再デプロイ共通ミドルウェア構成 (Service 名 / Namespace / Sentinel / headless Service /
databases 40000を kind 上に模擬)flask db initでjcgroupsDB (owner=jcgroups) と 4 テーブル生成amqp://invenio:**@weko-rabbitmq.weko3ra:5672/jcgroupsへ接続app_cache=db100/account_store=db101/group_cache=db4が実際に使われることを Redis 側の keyspace で確認未検証: mAP Core への到達を要する機能、Shibboleth 実 IdP との SAML 認証、Ingress コントローラ経由の疎通 (kind では Service への port-forward で確認)、NFS RWX PVC での複数レプリカ運用、実際の共通クラスタ (pgpool の md5 認証・Sentinel 複数台でのフェイルオーバ) への接続
補足
CI (
.github/workflows/ci.yml) はsrc/**tests/**pyproject.tomluv.lockの変更でのみ起動するため、この PR ではチェックが走りません。🤖 Generated with Claude Code