gateway(nginx) + manager(python 標準ライブラリ) + セッションごとの使い捨て Pod + reaper CronJob の構成。ブラウザ(PC/スマホ)からアクセスし、セッション単位で 独立した Alpine コンテナに Git リポジトリ(GitHub/Gitea など)をチェックアウトして 編集・検証・プッシュする。無操作が続いたセッションは Pod ごと自動破棄。 - セキュリティ: セッション NS 分離 / restricted PodSecurity / RBAC はセッション NS の pods,services のみの Role / セッション Pod は SA トークン非マウント・非 root・ readOnlyRootFilesystem・drop ALL caps・seccomp / NetworkPolicy で egress を DNS+HTTPS+SSH に限定 / Git ホスト allow-list / ResourceQuota+LimitRange - ライフサイクル: idleTimeout(Pod 内ウォッチドッグ + manager 回収) / maxLifetime (activeDeadlineSeconds) / maxSessions / 予備の孤児掃除 CronJob - 認証: token(既定) / basic / forward(外部SSO) / none。WebSocket は Cookie トークン - Claude 認証: ANTHROPIC_API_KEY または CLAUDE_CODE_OAUTH_TOKEN - CI: helm-release.yaml(未リリース版のみ tag+release+publish) / image-update-and-release.yaml(週次 npm 追従) / session-image.yaml(multi-arch build) - files/ 実体を .Files.Get で ConfigMap 化。helm lint / template 検証済み
113 lines
3.7 KiB
Smarty
113 lines
3.7 KiB
Smarty
{{/*
|
|
==========================================================================
|
|
claude-code — 共通ヘルパー
|
|
==========================================================================
|
|
*/}}
|
|
|
|
{{- define "claude-code.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{- define "claude-code.fullname" -}}
|
|
{{- if .Values.fullnameOverride -}}
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- $name := include "claude-code.name" . -}}
|
|
{{- if contains $name .Release.Name -}}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "claude-code.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/* 制御プレーン共通ラベル */}}
|
|
{{- define "claude-code.labels" -}}
|
|
helm.sh/chart: {{ include "claude-code.chart" . }}
|
|
{{ include "claude-code.selectorLabels" . }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
app.kubernetes.io/part-of: claude-code
|
|
{{- with .Values.commonLabels }}
|
|
{{ toYaml . }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
|
|
{{- define "claude-code.selectorLabels" -}}
|
|
app.kubernetes.io/name: {{ include "claude-code.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end -}}
|
|
|
|
{{/* セッション Pod を作成するネームスペース */}}
|
|
{{- define "claude-code.sessionsNamespace" -}}
|
|
{{- default .Release.Namespace .Values.sessionsNamespace.name -}}
|
|
{{- end -}}
|
|
|
|
{{/* 制御プレーン ServiceAccount 名 */}}
|
|
{{- define "claude-code.managerServiceAccountName" -}}
|
|
{{- printf "%s-manager" (include "claude-code.fullname" .) -}}
|
|
{{- end -}}
|
|
|
|
{{/* セッション ServiceAccount 名 */}}
|
|
{{- define "claude-code.sessionServiceAccountName" -}}
|
|
{{- printf "%s-session" (include "claude-code.fullname" .) -}}
|
|
{{- end -}}
|
|
|
|
{{/* 認証トークン Secret 名 */}}
|
|
{{- define "claude-code.authSecretName" -}}
|
|
{{- if .Values.auth.token.existingSecret -}}
|
|
{{- .Values.auth.token.existingSecret -}}
|
|
{{- else if .Values.auth.basic.existingSecret -}}
|
|
{{- .Values.auth.basic.existingSecret -}}
|
|
{{- else -}}
|
|
{{- printf "%s-auth" (include "claude-code.fullname" .) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Anthropic 認証情報 Secret 名(セッション NS 側) */}}
|
|
{{- define "claude-code.anthropicSecretName" -}}
|
|
{{- if .Values.anthropic.existingSecret -}}
|
|
{{- .Values.anthropic.existingSecret -}}
|
|
{{- else -}}
|
|
{{- printf "%s-anthropic" (include "claude-code.fullname" .) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Git アイデンティティ Secret 名(アイデンティティ名を与える) */}}
|
|
{{- define "claude-code.gitIdentitySecretName" -}}
|
|
{{- $ctx := .ctx -}}
|
|
{{- $name := .name -}}
|
|
{{- $id := index $ctx.Values.git.identities $name -}}
|
|
{{- if and $id $id.existingSecret -}}
|
|
{{- $id.existingSecret -}}
|
|
{{- else -}}
|
|
{{- printf "%s-git-%s" (include "claude-code.fullname" $ctx) $name -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* 自動生成トークン(未指定時)。リリース間で安定させるため lookup を優先。 */}}
|
|
{{- define "claude-code.resolvedToken" -}}
|
|
{{- if .Values.auth.token.value -}}
|
|
{{- .Values.auth.token.value -}}
|
|
{{- else -}}
|
|
{{- $sec := (lookup "v1" "Secret" .Release.Namespace (printf "%s-auth" (include "claude-code.fullname" .))) -}}
|
|
{{- if and $sec $sec.data (index $sec.data "token") -}}
|
|
{{- index $sec.data "token" | b64dec -}}
|
|
{{- else -}}
|
|
{{- randAlphaNum 40 -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* 制御プレーン Pod セキュリティコンテキスト */}}
|
|
{{- define "claude-code.podSecurityContext" -}}
|
|
{{- toYaml .Values.podSecurityContext -}}
|
|
{{- end -}}
|
|
|
|
{{- define "claude-code.containerSecurityContext" -}}
|
|
{{- toYaml .Values.containerSecurityContext -}}
|
|
{{- end -}}
|