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
14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .env に写して、この機械に合わせて書く。.env はコミットしない。
# .env にコピーして、この機械に合わせて書き換える。.env はコミットしない。

# データベースのパスワード。空のままでは起動しない。`;` は使えない
POSTGRES_PASSWORD=
Expand All @@ -12,24 +12,24 @@ CARINA_RECORDINGS_DIR=
# エンコード済みファイルを書くホスト側のディレクトリ。ライブラリと一緒に増える
CARINA_ENCODES_DIR=

# OIDC の client secret を暗号化する鍵を置くホスト側のディレクトリ。データベースとは別に残す
# OIDC の client secret や通知の送り先を暗号化する鍵 (ASP.NET Core Data Protection) と、Web Push の署名に使う鍵を置くホスト側のディレクトリ。データベースとは別にバックアップする
CARINA_KEYS_DIR=

# ブラウザからこのサーバに届くアドレス (https://tv.example.com など)。ID プロバイダに登録する redirect URI の元になる
# ブラウザから見たこのサーバのアドレス (https://tv.example.com など)。ID プロバイダに登録する redirect URI の元になる
CARINA_PUBLIC_ORIGIN=

# Caddy が開くサイトのアドレス。公開のドメイン (tv.example.com) なら https で開き証明書を取る。LAN だけなら :80 のまま
# Caddy が待ち受けるサイトのアドレス。公開のドメイン (tv.example.com) なら証明書を取得して https で待ち受ける。LAN だけなら :80 のまま
PYXIS_SITE_ADDRESS=:80

# ホスト側で開く http と https のポート。80 と 443 がほかに使われているなら別の番号にする
PYXIS_HTTP_PORT=80
PYXIS_HTTPS_PORT=443

# 録画をあとからエンコードするときの変換器。Software、Vaapi、Nvenc のどれか (GPU を渡したとき)
# 録画をあとからエンコードするときのエンコーダー。Software、Vaapi、Nvenc のどれか (Vaapi と Nvenc は GPU を渡したとき)
CARINA_ENCODINGS_PREFER=Software

# ライブと録画再生をその場で変換するときの変換器。Software、Vaapi、Nvenc のどれか (GPU を渡したとき)
# ライブと録画再生をリアルタイムでトランスコードするときのエンコーダー。Software、Vaapi、Nvenc のどれか (Vaapi と Nvenc は GPU を渡したとき)
CARINA_TRANSCODING_PREFER=Software

# VAAPI で使う GPU の描画ノード
# VAAPI で使う GPU の render ノード
CARINA_RENDER_NODE=/dev/dri/renderD128
2 changes: 1 addition & 1 deletion .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ rules:
truthy:
check-keys: false

# Helm のテンプレートは描く前の YAML ではない
# Helm のテンプレートはレンダリングするまで YAML として解釈できない
ignore:
- charts/pyxis/templates/
4 changes: 2 additions & 2 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 同じオリジンで /api/* を app に、それ以外を vela に振り分ける。
# PYXIS_SITE_ADDRESS に公開のドメインを書くと Caddy が証明書を取って https で開き、:80 なら http で開く。
# PYXIS_SITE_ADDRESS に公開のドメインを書くと Caddy が証明書を取得して https で待ち受け、:80 なら http で待ち受ける。
# アクセスログは取らない (外部プレイヤーの URL はパスに再生用のトークンを含む)。
{$PYXIS_SITE_ADDRESS} {
handle /api/* {
# SSE (/api/events) を溜めない。WebSocket (/api/live/ws) と Range はそのまま通る
# SSE (/api/events) をバッファリングしない。WebSocket (/api/live/ws) と Range はそのまま通る
reverse_proxy app:8080 {
flush_interval -1
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ B-CAS カードを 1 枚しか持っていなくても、別の機械のチュ
- B-CAS カードとカードリーダー。ホストで pcscd を動かしておきます
- Intel の GPU か NVIDIA の GPU(任意)。NVIDIA は NVIDIA Container Toolkit とドライバ 530.41.03 以上が要ります。H.265 と AV1 のエンコード、ライブと再生の変換に使います

チューナーとカードが無い機械でも、合成チューナーで画面を開くところまでは試せます。
チューナーとカードが無い機械でも、擬似チューナーで画面を開くところまでは試せます。

## 動かす

Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ keywords:
- carina
- vela
annotations:
# この版が固定するイメージの組。compose.yml と values.yaml の image と同じ値にする
# このバージョンで固定するイメージの組み合わせ。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/vela: ghcr.io/newworldorg/vela:v1.4.0
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 既定の形。合成のチューナー、同梱のデータベース、GPU なし、標準の Ingress
# 既定の構成。テスト用の擬似チューナー (fake)、同梱のデータベース、GPU なし、標準の Ingress
postgres:
auth:
password: check
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・画面・DB・前段は作らない
# driver だけを別の機械で動かす構成。ホストのネットワークでカードを貸し、app・Vela・データベース・Ingress は作らない
driver:
hostNetwork: true
config:
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/ci/external-db-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 外のデータベース。同梱の DB を作らず、接続文字列を Secret から読む。GPU は hostPath、サムネイルと字幕は emptyDir
# 外部のデータベースを使う構成。同梱のデータベースを作らず、接続文字列を Secret から読む。GPU は hostPath、サムネイルと字幕は emptyDir
postgres:
enabled: false
externalDatabase:
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/ci/ingressroute-gpu-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Traefik の IngressRoute と Intel の device plugin。DVB のチューナーと pcscd を渡し、置き場は hostPath
# Traefik の IngressRoute と Intel の device plugin。DVB のチューナーと pcscd を渡し、ボリュームはすべて hostPath
nodeSelector:
kubernetes.io/hostname: node-1
driver:
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/ci/kind-sizes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kind での起動の試験で default-values.yaml に重ねる値。名前を *-values.yaml にしないのは、chart の job が単体で lint と描画をする組と区別するため。置き場を小さくし、そのほかは既定のまま
# kind での起動テストで default-values.yaml に重ねる値。ファイル名を *-values.yaml にしないのは、chart の job が単体で lint とレンダリングをする values ファイルと区別するため。ボリュームのサイズを小さくし、そのほかは既定のまま
persistence:
recordings:
size: 1Gi
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/ci/nvidia-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NVIDIA の GPU を RuntimeClass と device plugin で渡し、エンコードを Nvenc にする
# NVIDIA の GPU を RuntimeClass と device plugin で渡し、エンコーダーを Nvenc にする
app:
encodingsPrefer: Nvenc
transcodingPrefer: Nvenc
Expand Down
12 changes: 6 additions & 6 deletions charts/pyxis/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{{ .Release.Name }} を名前空間 {{ .Release.Namespace }} に入れた。
{{ .Release.Name }} を名前空間 {{ .Release.Namespace }} にインストールした。
{{- if .Values.driver.enabled }}

driver は特権で動く。名前空間の Pod Security が privileged でないと driver は上がらない。
driver は特権コンテナで動く。名前空間の Pod Security が privileged でないと driver の Pod は起動しない。

kubectl label namespace {{ .Release.Namespace }} pod-security.kubernetes.io/enforce=privileged
{{- end }}
{{- if and .Values.driver.enabled .Values.app.enabled (not .Values.nodeSelector) (not .Values.driver.nodeSelector) (not .Values.app.nodeSelector) }}

nodeSelector が無い。ノードが複数のクラスタでは driver と app が別のノードに載り、ソケットでつながらない。
値の nodeSelector に、チューナーのあるノードを書く。
nodeSelector が指定されていない。ノードが複数のクラスタでは、driver と app が別のノードにスケジュールされるとソケットで接続できない。
values の nodeSelector に、チューナーのあるノードを指定する。
{{- end }}
{{- if .Values.app.enabled }}

最初の起動で app がローカルアカウントを作り、ユーザー名とパスワードをログに 1 度だけ書く。
初回の起動で app がローカルアカウントを作り、ユーザー名とパスワードをログに 1 回だけ出力する。

kubectl -n {{ .Release.Namespace }} logs deploy/{{ include "pyxis.partName" (dict "root" . "part" "app") }} -c app | grep 'Sign in as'
{{- end }}
{{- if and .Values.vela.enabled (ne .Values.route.kind "none") }}

ブラウザで {{ if .Values.route.host }}https://{{ .Values.route.host }}/{{ else }}前段のアドレス{{ end }} を開く。
ブラウザで {{ if .Values.route.host }}https://{{ .Values.route.host }}/{{ else }}Ingress コントローラのアドレス{{ end }} を開く。
{{- end }}
13 changes: 5 additions & 8 deletions charts/pyxis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{/*
部品の名前。リリース名に部品の名前をつなぐ (carina-driver、carina-app、carina-db、carina-vela)
コンポーネントのリソース名。リリース名にコンポーネントの名前をつなぐ (carina-driver、carina-app、carina-db、carina-vela)
*/}}
{{- define "pyxis.partName" -}}
{{- printf "%s-%s" .root.Release.Name .part | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
資源の metadata に付けるラベル。チャートの版はここにだけ入れ、Pod のテンプレートには入れない
リソースの metadata に付けるラベル。チャートのバージョンはここにだけ入れ、Pod のテンプレートには入れない
*/}}
{{- define "pyxis.labels" -}}
helm.sh/chart: {{ printf "%s-%s" .root.Chart.Name .root.Chart.Version | replace "+" "_" }}
Expand All @@ -25,7 +25,7 @@ app.kubernetes.io/component: {{ .part }}
{{- end -}}

{{/*
部品の nodeSelector。部品のものがあればそれを、無ければ共通のものを使う
コンポーネントの nodeSelector。コンポーネントに指定があればそれを、無ければ共通のものを使う
*/}}
{{- define "pyxis.nodeSelector" -}}
{{- $selector := .own | default .root.Values.nodeSelector -}}
Expand All @@ -35,9 +35,6 @@ nodeSelector:
{{- end }}
{{- end -}}

{{/*
Pod の imagePullSecrets
*/}}
{{- define "pyxis.imagePullSecrets" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -48,7 +45,7 @@ imagePullSecrets:
{{- end -}}

{{/*
置き場の volume の中身。type が pvc、existingClaim、hostPath、emptyDir のどれかで形が変わる
persistence の各ボリュームの volume ソース。type が pvc、existingClaim、hostPath、emptyDir のどれかで内容が変わる
*/}}
{{- define "pyxis.volumeSource" -}}
{{- $spec := index .root.Values.persistence .name -}}
Expand Down Expand Up @@ -77,7 +74,7 @@ emptyDir: {}
{{- end -}}

{{/*
app と migrate に渡す接続文字列の環境変数。同梱のときは Service 名とパスワードから組み、外のときは Secret から読む
app と migrate に渡す接続文字列の環境変数。同梱のデータベースなら Service 名とパスワードから組み立て、外部のデータベースなら Secret から読む
*/}}
{{- define "pyxis.connectionStringEnv" -}}
{{- if .Values.postgres.enabled }}
Expand Down
10 changes: 5 additions & 5 deletions charts/pyxis/templates/app-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
labels:
{{- include "pyxis.labels" (dict "root" . "part" "app") | nindent 4 }}
spec:
# 予約の確認やエンコードの列をプロセスの中に持つので 1 つだけ。古い app が止まってから migrate を当てる
# 予約の確認やエンコードのキューをプロセスの中に持つのでレプリカは 1 つだけ。古い app が停止してからマイグレーションを実行する
replicas: 1
strategy:
type: Recreate
Expand All @@ -24,7 +24,7 @@ spec:
{{- with include "pyxis.imagePullSecrets" . }}{{ . | trim | nindent 6 }}{{- end }}
{{- with include "pyxis.nodeSelector" (dict "root" . "own" $app.nodeSelector) }}{{ . | trim | nindent 6 }}{{- end }}
{{- if eq $app.gpu.mode "nvidia" }}
# NVIDIA Container Toolkit の runtime が、ドライバのライブラリと装置をコンテナに差し込む
# NVIDIA Container Toolkit のランタイムが、ドライバのライブラリとデバイスをコンテナにマウントする
runtimeClassName: {{ $app.gpu.runtimeClassName }}
{{- end }}
securityContext:
Expand All @@ -35,7 +35,7 @@ spec:
{{- end }}
initContainers:
{{- if $app.dataProtection.seedSecret }}
# client secret を封じる鍵の種を、置き場に無いときだけ写す。あとから増えた鍵には触らない
# seedSecret の Data Protection の鍵ファイルを、keys のボリュームに同じ名前のファイルが無いときだけコピーする。あとから増えた鍵には触らない
- name: seed-keys
image: {{ $image | quote }}
imagePullPolicy: {{ $app.image.pullPolicy }}
Expand Down Expand Up @@ -71,14 +71,14 @@ spec:
image: {{ $image | quote }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- if eq $app.gpu.mode "devicePlugin" }}
# device plugin が作る装置は root:root 0660 で app が開けない。グループを app のものに替えてから entrypoint に渡す
# device plugin が作るデバイスノードは root:root 0660 で app が開けない。グループを app の gid に変えてから entrypoint を実行する
command:
- bash
- -c
- chgrp {{ $gid }} /dev/dri/* && exec /usr/local/bin/carina app
{{- end }}
{{- if eq $app.gpu.mode "hostPath" }}
# hostPath で渡した装置は device cgroup が開かせないので、特権にする
# hostPath でマウントしたデバイスは device cgroup がアクセスを許可しないので、特権コンテナにする
securityContext:
privileged: true
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/templates/db-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if and .Values.postgres.enabled (not .Values.postgres.auth.existingSecret) }}
{{- if not .Values.postgres.auth.password }}
{{- fail "postgres.auth.existingSecret か postgres.auth.password のどちらかにデータベースのパスワードを書く" }}
{{- fail "postgres.auth.existingSecret にパスワードを持つ Secret の名前を書くか、postgres.auth.password にデータベースのパスワードを書く" }}
{{- end }}
apiVersion: v1
kind: Secret
Expand Down
4 changes: 2 additions & 2 deletions charts/pyxis/templates/driver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
{{- include "pyxis.labels" (dict "root" . "part" "driver") | nindent 4 }}
spec:
# チューナーを占有するので 1 つだけ動かし、入れ替えも古いものが止まってから
# チューナーを占有するのでレプリカは 1 つだけにし、更新のときも古い Pod が停止してから新しい Pod を起動する
replicas: 1
strategy:
type: Recreate
Expand All @@ -26,7 +26,7 @@ spec:
{{- if $driver.hostNetwork }}
hostNetwork: true
{{- end }}
# 録画中に止められると録画の終わりまで待つ。shutdownGraceHours より長くする
# 録画中に停止を要求されると録画の終了まで待つ。shutdownGraceHours より長くする
terminationGracePeriodSeconds: {{ $driver.terminationGracePeriodSeconds }}
containers:
- name: driver
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ metadata:
labels:
{{- include "pyxis.labels" (dict "root" $ "part" $name) | nindent 4 }}
annotations:
# リリースを消しても残す
# リリースを削除しても PVC を残す
helm.sh/resource-policy: keep
spec:
accessModes:
Expand Down
2 changes: 1 addition & 1 deletion charts/pyxis/templates/vela-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
env:
- name: CARINA_API_BASE_URL
value: {{ printf "http://%s:8080" (include "pyxis.partName" (dict "root" . "part" "app")) | quote }}
# next の standalone は HOSTNAME で待ち受ける。k8s は Pod 名を入れるので全部で待ち受けさせる
# Next.js の standalone サーバは HOSTNAME のアドレスで待ち受ける。Kubernetes は HOSTNAME に Pod 名を入れるので、0.0.0.0 を指定してすべてのインターフェースで待ち受ける
- name: HOSTNAME
value: 0.0.0.0
ports:
Expand Down
Loading
Loading