Skip to content

Commit

Permalink
feat: add networkpolicy and pdb
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Sep 4, 2024
1 parent 15bd211 commit 7961056
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 174 deletions.
156 changes: 82 additions & 74 deletions charts/openbas/README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions charts/openbas/ci/ci-common-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ env:

testConnection: true

networkPolicy:
enabled: true

podDisruptionBudget:
enabled: true

autoscaling:
enabled: true

caldera:
enabled: true

env:
CALDERA_URL: http://openbas-ci-caldera:8888
config:
Expand Down Expand Up @@ -79,6 +86,12 @@ caldera:
- stockpile
- training

networkPolicy:
enabled: true

podDisruptionBudget:
enabled: true

collectors:
- name: atomic-red-team
enabled: true
Expand Down
1 change: 1 addition & 0 deletions charts/openbas/templates/caldera/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: ConfigMap
metadata:
name: {{ include "openbas.fullname" . }}-caldera-config
labels:
openbas.component: caldera
{{- include "openbas.labels" . | nindent 4 }}
data:
local.yml: |
Expand Down
1 change: 1 addition & 0 deletions charts/openbas/templates/caldera/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ include "openbas.fullname" . }}-caldera
labels:
openbas.component: caldera
{{- include "openbas.labels" . | nindent 4 }}
spec:
scaleTargetRef:
Expand Down
50 changes: 50 additions & 0 deletions charts/openbas/templates/caldera/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- if .Values.caldera.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "openbas.fullname" . }}-caldera
labels:
openbas.component: caldera
{{- include "openbas.labels" . | nindent 4 }}
spec:
{{- if and (not .Values.caldera.networkPolicy.policyTypes) (not .Values.caldera.networkPolicy.ingress) (not .Values.caldera.networkPolicy.egress) }}
podSelector: {}
{{- else }}
podSelector:
matchLabels:
openbas.component: caldera
{{- include "openbas.selectorLabels" . | nindent 6 }}
{{- end }}

{{- if .Values.caldera.networkPolicy.policyTypes }}
{{- with .Values.caldera.networkPolicy.policyTypes }}
policyTypes:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
policyTypes:
- Ingress
- Egress
{{- end }}

{{- if .Values.caldera.networkPolicy.ingress }}
{{- with .Values.caldera.networkPolicy.ingress }}
ingress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
ingress:
- {}
{{- end }}

{{- if .Values.caldera.networkPolicy.egress }}
{{- with .Values.caldera.networkPolicy.egress }}
egress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
egress:
- {}
{{- end }}

{{- end }}
20 changes: 20 additions & 0 deletions charts/openbas/templates/caldera/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.caldera.podDisruptionBudget.enabled -}}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "openbas.fullname" . }}-caldera
labels:
openbas.component: caldera
{{- include "openbas.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
openbas.component: caldera
{{- include "openbas.selectorLabels" . | nindent 6 }}
{{- if .Values.caldera.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.caldera.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.caldera.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.caldera.podDisruptionBudget.maxUnavailable }}
{{- end }}
{{- end -}}
1 change: 1 addition & 0 deletions charts/openbas/templates/server/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ include "openbas.fullname" . }}-server
labels:
openbas.component: server
{{- include "openbas.labels" . | nindent 4 }}
spec:
scaleTargetRef:
Expand Down
50 changes: 50 additions & 0 deletions charts/openbas/templates/server/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "openbas.fullname" . }}-server
labels:
openbas.component: server
{{- include "openbas.labels" . | nindent 4 }}
spec:
{{- if and (not .Values.networkPolicy.policyTypes) (not .Values.networkPolicy.ingress) (not .Values.networkPolicy.egress) }}
podSelector: {}
{{- else }}
podSelector:
matchLabels:
openbas.component: server
{{- include "openbas.selectorLabels" . | nindent 6 }}
{{- end }}

{{- if .Values.networkPolicy.policyTypes }}
{{- with .Values.networkPolicy.policyTypes }}
policyTypes:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
policyTypes:
- Ingress
- Egress
{{- end }}

{{- if .Values.networkPolicy.ingress }}
{{- with .Values.networkPolicy.ingress }}
ingress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
ingress:
- {}
{{- end }}

{{- if .Values.networkPolicy.egress }}
{{- with .Values.networkPolicy.egress }}
egress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- else }}
egress:
- {}
{{- end }}

{{- end }}
20 changes: 20 additions & 0 deletions charts/openbas/templates/server/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.podDisruptionBudget.enabled -}}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "openbas.fullname" . }}-server
labels:
openbas.component: server
{{- include "openbas.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
openbas.component: server
{{- include "openbas.selectorLabels" . | nindent 6 }}
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
{{- end -}}
1 change: 1 addition & 0 deletions charts/openbas/templates/server/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type: Opaque
metadata:
name: {{ include "openbas.fullname" . }}-credentials
labels:
openbas.component: server
{{- include "openbas.labels" . | nindent 4 }}
annotations:
helm.sh/hook: "pre-install,pre-upgrade"
Expand Down
1 change: 1 addition & 0 deletions charts/openbas/templates/server/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: ServiceAccount
metadata:
name: {{ include "openbas.serviceAccountName" . }}
labels:
openbas.component: server
{{- include "openbas.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
Expand Down
Loading

0 comments on commit 7961056

Please sign in to comment.