Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ jobs:
-schema-location default \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
done
- name: No chart version in the Pod templates, the checksum on the driver only, Service names from the release name
- name: No chart version in the Pod templates, the checksum on the driver only, Service names from the release name, the state volume, the claims
run: scripts/check-rendering.sh
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ B-CAS カードを 1 枚しか持っていなくても、別の機械のチュ

- Docker 25 以上と Docker Compose v2。CPU は amd64
- 録画用のディスク。地上波の録画は 1 時間あたり約 7 GB
- チューナー。Linux DVB で `/dev/dvb/adapterN` として見える PCIe・USB のカード、または USB チューナーの CECH-ZD1
- B-CAS カードとカードリーダー。ホストで pcscd を動かしておきます
- チューナー。Linux DVB で `/dev/dvb/adapterN` として見える PCIe・USB のカード、または USB チューナーの CECH-ZD1 か PIX-DT295
- B-CAS カードとカードリーダー。ホストで pcscd を動かしておきます。PIX-DT295 は本体のスロットに挿したカードを使います
- Intel の GPU か NVIDIA の GPU(任意)。NVIDIA は NVIDIA Container Toolkit とドライバ 530.41.03 以上が要ります。H.265 と AV1 のエンコード、ライブと再生の変換に使います

チューナーとカードが無い機械でも、擬似チューナーで画面を開くところまでは試せます。
Expand All @@ -29,7 +29,9 @@ mkdir -p /srv/tv/{db,recordings,encodes,keys}

`.env` にデータベースのパスワードと、データを置く 4 つのディレクトリを書きます。\
次に `driver/driver.json` をチューナーに合わせます。\
DVB と USB のサンプルが `driver/examples/` にあります。
DVB と USB のサンプルが `driver/examples/` にあります。\
USB のサンプルは CECH-ZD1 と PIX-DT295 のどちらにも使えます。\
PIX-DT295 は 1 台で地上波か衛星のどちらか一方を受信するので、`kind` に `terrestrial` か `satellite` を書きます。

```bash
cp driver/examples/driver-dvb.json driver/driver.json
Expand Down Expand Up @@ -69,11 +71,14 @@ docker compose logs app | grep 'Sign in as'
番組表の収集間隔や品質の閾値などの細かい設定は Carina の README にあります。\
変えるときは `compose.override.yml` を置き、`app` の `environment` に書きます。

driver は、チューナーと局の組み合わせごとの受信の記録をボリューム `driver-state` に保存します。\
同じ局を受信できるチューナーが複数空いているときは、記録の良いチューナーを使います。

## 更新

```bash
git fetch --tags
git checkout v0.6.0
git checkout v0.7.0
docker compose pull
docker compose stop app
docker compose up -d
Expand All @@ -93,16 +98,18 @@ tar -C "$(grep ^CARINA_KEYS_DIR= .env | cut -d= -f2)" -cf keys-$(date +%Y%m%d).t
## Helm

```bash
helm install carina oci://ghcr.io/newworldorg/charts/pyxis --version 0.6.0 -n tv --create-namespace -f values.yaml
helm install carina oci://ghcr.io/newworldorg/charts/pyxis --version 0.7.0 -n tv --create-namespace -f values.yaml
```

値の一覧と説明は `charts/pyxis/values.yaml` にあります。\
driver は特権コンテナなので、名前空間の Pod Security は `privileged` にしてください。
driver は特権コンテナなので、名前空間の Pod Security は `privileged` にしてください。\
driver の受信の記録は `persistence.state` のボリュームに保存し、既定は 100Mi の PVC です。

## バージョン

| Pyxis | Carina | Puppis | Vela | PostgreSQL | Caddy |
| --- | --- | --- | --- | --- | --- |
| 0.7.0 | v2.1.0 | v0.4.0 | v1.4.0 | 18.6(Debian) | 2.11.7 |
| 0.6.0 | v2.1.0 | v0.3.0 | v1.4.0 | 18.6(Debian) | 2.11.7 |
| 0.5.0 | v2.0.0 | v0.2.0 | v1.3.0 | 18.6(Debian) | 2.11.7 |
| 0.4.0 | v2.0.0 | v0.1.1 | v1.2.0 | 18.6(Debian) | 2.11.7 |
Expand Down
6 changes: 3 additions & 3 deletions charts/pyxis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pyxis
description: A recording server for Japanese digital broadcasting, with Puppis, Carina and Vela pinned to a verified set of image versions
type: application
version: 0.6.0
appVersion: 0.6.0
version: 0.7.0
appVersion: 0.7.0
kubeVersion: ">=1.25.0-0"
home: https://github.com/NewWorldOrg/Pyxis
sources:
Expand All @@ -20,6 +20,6 @@ keywords:
annotations:
# このバージョンで固定するイメージの組み合わせ。compose.yml と values.yaml の image と同じ値にする
images/carina-app: ghcr.io/newworldorg/carina:v2.1.0
images/puppis-driver: ghcr.io/newworldorg/puppis:v0.3.0
images/puppis-driver: ghcr.io/newworldorg/puppis:v0.4.0
images/vela: ghcr.io/newworldorg/vela:v1.4.0
images/postgres: postgres:18.6-trixie
2 changes: 1 addition & 1 deletion charts/pyxis/ci/driver-only-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# driver だけを別の機械で動かす構成。ホストのネットワークでカードを貸し、app・Vela・データベース・Ingress は作らない
# driver だけを別の機械で動かす構成。ホストのネットワークでカードを貸し、app・Vela・データベース・Ingress は作らない。受信の記録のボリュームは既定の PVC のまま
driver:
hostNetwork: true
config:
Expand Down
4 changes: 3 additions & 1 deletion charts/pyxis/ci/external-db-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 外部のデータベースを使う構成。同梱のデータベースを作らず、接続文字列を Secret から読む。GPU は hostPath、サムネイルと字幕は emptyDir
# 外部のデータベースを使う構成。同梱のデータベースを作らず、接続文字列を Secret から読む。GPU は hostPath、サムネイルと字幕と受信の記録は emptyDir
postgres:
enabled: false
externalDatabase:
Expand Down Expand Up @@ -30,3 +30,5 @@ persistence:
type: emptyDir
captions:
type: emptyDir
state:
type: emptyDir
4 changes: 4 additions & 0 deletions charts/pyxis/ci/ingressroute-gpu-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ persistence:
type: hostPath
hostPath:
path: /srv/pyxis/postgres
state:
type: hostPath
hostPath:
path: /srv/pyxis/driver-state
2 changes: 2 additions & 0 deletions charts/pyxis/ci/kind-sizes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ persistence:
size: 64Mi
db:
size: 1Gi
state:
size: 64Mi
6 changes: 6 additions & 0 deletions charts/pyxis/templates/driver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
env:
- name: PUPPIS_DRIVER_CONFIG
value: /etc/puppis/driver.json
- name: PUPPIS_DRIVER_STATE
value: /var/lib/puppis
securityContext:
privileged: true
volumeMounts:
Expand All @@ -46,6 +48,8 @@ spec:
mountPath: /run/carina
- name: recordings
mountPath: /srv/recordings
- name: state
mountPath: /var/lib/puppis
{{- if $driver.pcscd.enabled }}
- name: pcscd
mountPath: /run/pcscd
Expand Down Expand Up @@ -75,6 +79,8 @@ spec:
type: DirectoryOrCreate
- name: recordings
{{- include "pyxis.volumeSource" (dict "root" . "name" "recordings") | trim | nindent 10 }}
- name: state
{{- include "pyxis.volumeSource" (dict "root" . "name" "state") | trim | nindent 10 }}
{{- if $driver.pcscd.enabled }}
- name: pcscd
hostPath:
Expand Down
1 change: 1 addition & 0 deletions charts/pyxis/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"captions" .Values.app.enabled
"keys" .Values.app.enabled
"db" .Values.postgres.enabled
"state" .Values.driver.enabled
}}
{{- range $name, $needed := $needs }}
{{- $spec := index $.Values.persistence $name }}
Expand Down
5 changes: 3 additions & 2 deletions charts/pyxis/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,15 @@
"persistence": {
"type": "object",
"additionalProperties": false,
"required": ["recordings", "encodes", "thumbnails", "captions", "keys", "db"],
"required": ["recordings", "encodes", "thumbnails", "captions", "keys", "db", "state"],
"properties": {
"recordings": { "$ref": "#/$defs/storage" },
"encodes": { "$ref": "#/$defs/storage" },
"thumbnails": { "$ref": "#/$defs/storageOrEmptyDir" },
"captions": { "$ref": "#/$defs/storageOrEmptyDir" },
"keys": { "$ref": "#/$defs/storage" },
"db": { "$ref": "#/$defs/storage" }
"db": { "$ref": "#/$defs/storage" },
"state": { "$ref": "#/$defs/storageOrEmptyDir" }
}
}
},
Expand Down
21 changes: 19 additions & 2 deletions charts/pyxis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ driver:
# driver のイメージ
repository: ghcr.io/newworldorg/puppis
# driver のイメージのタグ。compose.yml と同じバージョンにする
tag: v0.3.0
tag: v0.4.0
# イメージの pull ポリシー
pullPolicy: IfNotPresent
# driver.json の内容をそのまま書く。socketGroupId はチャートが carina.gid の値を設定し、socketPath は既定 (/run/carina/driver.sock) のままにする
Expand Down Expand Up @@ -170,7 +170,7 @@ route:
# IngressRoute の tls。{} なら Traefik の既定の証明書、null なら http
tls: {}

# ボリュームごとに type を pvc、existingClaim、hostPath から選ぶ。thumbnails と captions は emptyDir も選べる
# ボリュームごとに type を pvc、existingClaim、hostPath から選ぶ。thumbnails、captions、state は emptyDir も選べる
persistence:
recordings:
# 録画。driver が書き込み、app は読み取り専用でマウントする
Expand Down Expand Up @@ -274,3 +274,20 @@ persistence:
path: ""
# hostPath のときの type
type: Directory
state:
# チューナーと局の組み合わせごとの受信の記録。driver が書き込む。emptyDir なら Pod と一緒に消え、driver が測り直す
type: pvc
# pvc のときのサイズ
size: 100Mi
# pvc のときの storageClassName。空なら既定、"-" なら無し
storageClass: ""
# pvc のときの accessModes
accessModes:
- ReadWriteOnce
# existingClaim のときの PVC の名前
existingClaim: ""
hostPath:
# hostPath のときのホスト側のパス
path: ""
# hostPath のときの type
type: Directory
6 changes: 5 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:
condition: service_started

driver:
image: ghcr.io/newworldorg/puppis:v0.3.0
image: ghcr.io/newworldorg/puppis:v0.4.0
logging: *logging
# 停止を要求されたときは終了コード 0、それ以外は 70 で終了するので on-failure は使わない
restart: unless-stopped
Expand All @@ -101,8 +101,11 @@ services:
stop_grace_period: 7h
environment:
PUPPIS_DRIVER_CONFIG: /etc/puppis/driver.json
# driver がチューナーと局の組み合わせごとの受信の記録を保存するディレクトリ。指定しないと記録は再起動で消える
PUPPIS_DRIVER_STATE: /var/lib/puppis
volumes:
- ./driver/driver.json:/etc/puppis/driver.json:ro
- driver-state:/var/lib/puppis
- driver-run:/run/carina
- ${CARINA_RECORDINGS_DIR:?}:/srv/recordings
healthcheck:
Expand Down Expand Up @@ -160,6 +163,7 @@ networks:

volumes:
driver-run:
driver-state:
thumbnails:
captions:
caddy-data:
Expand Down
2 changes: 1 addition & 1 deletion examples/tuner-usb.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# USB の地上デジタルチューナー (CECH-ZD1) を driver に渡す。
# USB チューナー (CECH-ZD1 と PIX-DT295) を driver に渡す。
# 挿し直すとデバイスノードの番号が変わる。devices で渡すとコンテナを作成したときのデバイスノードしか見えないので、
# /dev/bus/usb をマウントし、USB デバイス (メジャー番号 189) へのアクセスを device cgroup で許可する
services:
Expand Down
30 changes: 29 additions & 1 deletion scripts/check-rendering.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
# チャートのレンダリング結果が満たすべき条件を、ci/default-values.yaml でレンダリングした結果に対して確かめる。
# Pod のテンプレートにチャートのバージョン (helm.sh/chart) を入れない。ConfigMap の checksum は driver の Pod にだけ付ける。
# リリース名 carina でレンダリングすると Service が carina-app・carina-db・carina-vela になる
# リリース名 carina でレンダリングすると Service が carina-app・carina-db・carina-vela になる。
# driver の PUPPIS_DRIVER_STATE は state のボリュームのマウント先と同じパスを指す。
# Pod が参照する PVC は、ci/default-values.yaml でも driver だけの ci/driver-only-values.yaml でも、すべてチャートが作る
set -euo pipefail

cd "$(dirname "$0")/.."
Expand Down Expand Up @@ -58,5 +60,31 @@ if [ "$services" != 'carina-app carina-db carina-vela ' ]; then
status=1
fi

# PUPPIS_DRIVER_STATE がボリュームの無いパスを指すと、driver は受信の記録を保存できず、エラーにもならない
state_env=$(printf '%s\n' "$rendered" | awk '/^ *- name: PUPPIS_DRIVER_STATE$/ { getline; print $2 }')
state_mount=$(printf '%s\n' "$rendered" | awk '/^ *- name: state$/ { getline; if ($1 == "mountPath:") print $2 }')
if [ -z "$state_env" ] || [ "$state_env" != "$state_mount" ]; then
echo "driver の PUPPIS_DRIVER_STATE (${state_env:-無し}) が state のボリュームのマウント先 (${state_mount:-無し}) と違う" >&2
status=1
fi

claims_not_made() {
awk '
/^---/ { kind = ""; name = "" }
/^kind: / { kind = $2 }
/^ name: / && name == "" { name = $2; if (kind == "PersistentVolumeClaim") made[name] = 1 }
/^ *claimName: / { wanted[$2] = 1 }
END { for (claim in wanted) if (!(claim in made)) print claim }
' | sort | tr '\n' ' '
}
driver_only=$(helm template carina charts/pyxis -f charts/pyxis/ci/driver-only-values.yaml)
for output in "$rendered" "$driver_only"; do
missing=$(printf '%s\n' "$output" | claims_not_made)
if [ -n "$missing" ]; then
echo "Pod が参照する PVC をチャートが作っていない: $missing" >&2
status=1
fi
done

[ "$status" = 0 ] && echo 'レンダリング結果は条件をすべて満たしている'
exit "$status"
Loading