Files
claude-code/templates/networkpolicy-session.yaml
claude 1bd0fec23a
Helm Chart Release / release-chart (push) Successful in 12s
Build Session Image / build-push (push) Successful in 2m15s
feat: Alpine ベースの Claude Code リモート実行 Helm チャート初版 (v2.1.259)
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 検証済み
2026-09-03 08:10:12 +09:00

76 lines
2.1 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{- if .Values.networkPolicy.enabled }}
{{- $np := .Values.networkPolicy -}}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "claude-code.fullname" . }}-session
namespace: {{ include "claude-code.sessionsNamespace" . }}
labels:
{{- include "claude-code.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: claude-code
app.kubernetes.io/component: session
policyTypes:
- Ingress
- Egress
ingress:
# 制御プレーン(gateway)からの ttyd 接続のみ許可
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
podSelector:
matchLabels:
{{- include "claude-code.selectorLabels" . | nindent 14 }}
app.kubernetes.io/component: control-plane
ports:
- protocol: TCP
port: {{ .Values.session.ttydPort }}
egress:
# DNS
- to:
- namespaceSelector:
matchLabels:
{{- toYaml $np.dnsNamespaceSelector | nindent 14 }}
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
{{- if $np.allowInternetHttps }}
# HTTPS(git over HTTPS + api.anthropic.com)。内部レンジは except で遮断。
- to:
- ipBlock:
cidr: 0.0.0.0/0
{{- with $np.blockedEgressCIDRs }}
except:
{{- toYaml . | nindent 14 }}
{{- end }}
ports:
- protocol: TCP
port: 443
{{- end }}
{{- if $np.allowSshGit }}
# SSH git(port 22)
- to:
- ipBlock:
cidr: 0.0.0.0/0
{{- with $np.blockedEgressCIDRs }}
except:
{{- toYaml . | nindent 14 }}
{{- end }}
ports:
- protocol: TCP
port: 22
{{- end }}
{{- range $np.sessionEgressExtra }}
- to:
- ipBlock:
cidr: {{ .cidr }}
ports:
{{- toYaml .ports | nindent 8 }}
{{- end }}
{{- end }}