-
Notifications
You must be signed in to change notification settings - Fork 0
[] Add helm/templates/networkpolicy.yaml (DB/Redis/MinIO traffic restriction) and helm/templates/servicemonitor.yaml (Prometheus scraping) #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| {{- if .Values.networkPolicy.enabled }} | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: {{ include "open-git.fullname" . }}-backend-egress | ||
| labels: | ||
| {{- include "open-git.labels" . | nindent 4 }} | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| {{- include "open-git.selectorLabels" . | nindent 6 }} | ||
| app.kubernetes.io/component: backend | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| egress: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 [critical] backend NetworkPolicy が Ingress を全拒否する
Task Goal では 該当箇所: policyTypes:
- Ingress
- Egress
egress:@@ -13,4 +13,3 @@
policyTypes:
- - Ingress
- Egress
egress:
|
||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: postgresql | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| ports: | ||
| - protocol: TCP | ||
| port: 5432 | ||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: redis | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| ports: | ||
| - protocol: TCP | ||
| port: 6379 | ||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: minio | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| ports: | ||
| - protocol: TCP | ||
| port: 9000 | ||
| - ports: | ||
| - protocol: UDP | ||
| port: 53 | ||
| - protocol: TCP | ||
| port: 53 | ||
| --- | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: {{ include "open-git.fullname" . }}-postgresql-ingress | ||
| labels: | ||
| {{- include "open-git.labels" . | nindent 4 }} | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: postgresql | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| policyTypes: | ||
| - Ingress | ||
| ingress: | ||
| - from: | ||
| - podSelector: | ||
| matchLabels: | ||
| {{- include "open-git.selectorLabels" . | nindent 14 }} | ||
| app.kubernetes.io/component: backend | ||
| - podSelector: | ||
| matchLabels: | ||
| {{- include "open-git.selectorLabels" . | nindent 14 }} | ||
| app.kubernetes.io/component: worker | ||
| ports: | ||
| - protocol: TCP | ||
| port: 5432 | ||
| {{- end }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [high] Redis・MinIO の ingress 制限 NetworkPolicy が存在しない 該当箇所: apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "open-git.fullname" . }}-postgresql-ingressタスク要件および PR 説明には「DB/Redis/MinIO traffic restriction」と明記されていますが、実装では PostgreSQL ( backend からの egress は許可されていますが、Redis/MinIO Pod 側で ingress を制限しないと、他の Pod (攻撃者が掌握した Pod 等) からも直接アクセス可能になります。 Redis・MinIO に対しても同様の ---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "open-git.fullname" . }}-redis-ingress
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: redis
app.kubernetes.io/instance: {{ .Release.Name }}
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
{{- include "open-git.selectorLabels" . | nindent 14 }}
app.kubernetes.io/component: backend
ports:
- protocol: TCP
port: 6379
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| {{- if .Values.serviceMonitor.enabled }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "open-git.fullname" . }}-backend | ||
| labels: | ||
| {{- include "open-git.labels" . | nindent 4 }} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: {{ include "open-git.name" . }} | ||
| app.kubernetes.io/component: backend | ||
| endpoints: | ||
| - port: http | ||
| path: /metrics | ||
| interval: 30s | ||
| namespaceSelector: | ||
| matchNames: | ||
| - {{ .Release.Namespace }} | ||
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 [critical] backend-egress ポリシーに
ingressルールが未定義のままpolicyTypes: Ingressを宣言している該当箇所:
policyTypesにIngressを含めているにもかかわらず、spec.ingressフィールドが一切定義されていません。Kubernetes の NetworkPolicy の仕様では、policyTypesにIngressを列挙してingressルールを省略した場合、その Pod へのすべての ingress トラフィックが拒否 されます(空リスト扱い)。backend Pod 宛ての受信トラフィック(外部からの HTTP リクエスト、Ingress Controller からの通信など)が全断するため、本番では即座にサービス停止になります。
意図が「egress のみ制限する」なら
policyTypes: [Egress]のみにすべきです。もし「ingress も制限したい」なら対応するingress:ルールを明示的に追加してください。code.kubernetes.networkpolicy_ingress_missing| confidence: 0.97