Skip to content
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

Add other network policy options #797

Merged
merged 1 commit into from
Mar 8, 2021
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
35 changes: 33 additions & 2 deletions cost-analyzer/templates/cost-analyzer-network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,49 @@
{{- if .Values.networkPolicy.enabled -}}
apiVersion: {{ include "cost-analyzer.networkPolicy.apiVersion" . }}
kind: NetworkPolicy
{{- if .Values.networkPolicy.denyEgress }}
metadata:
name: deny-egress
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{ include "cost-analyzer.selectorLabels" . | nindent 6 }}
{{- include "cost-analyzer.selectorLabels" . | nindent 6 }}
policyTypes:
- Egress
egress:
- to:
- namespaceSelector: {}
{{- else }}
{{- if .Values.networkPolicy.sameNamespace}}
metadata:
name: shared-namespace
namespace: {{ default "kubecost" .Values.networkPolicy.namespace}}
spec:
podSelector:
matchLabels:
app: prometheus
component: server
{{- else }}
metadata:
name: closed-traffic
namespace: {{ default "kubecost" .Values.networkPolicy.namespace}}
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: cost-analyzer
{{- end }}
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app.kubernetes.io/name: cost-analyzer
- namespaceSelector:
matchLabels:
name: k8s-kubecost
{{- end }}
{{- end -}}
{{- end -}}
3 changes: 3 additions & 0 deletions cost-analyzer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ priority:
# If true, enable creation of NetworkPolicy resources.
networkPolicy:
enabled: false
denyEgress: true # create a network policy that denies egress from kubecost
sameNamespace: true # Set to true if cost analyser and prometheus are on the same namespace
# namespace: kubecost # Namespace where prometheus is installed

podSecurityPolicy:
enabled: true
Expand Down