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

[bitnami/magento] feat!: 🔒 💥 Improve security defaults #24822

Merged
merged 12 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .vib/magento/vib-action.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
verification-mode=SERIAL
10 changes: 5 additions & 5 deletions bitnami/magento/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies:
- name: mariadb
repository: oci://registry-1.docker.io/bitnamicharts
version: 15.2.3
version: 18.0.0
- name: elasticsearch
repository: oci://registry-1.docker.io/bitnamicharts
version: 19.19.3
version: 20.0.1
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.18.0
digest: sha256:a03226f45b598fca0e40f8804aa3fe287ff7ec4fc7100195b467535bbe180163
generated: "2024-03-05T14:34:42.174163373+01:00"
version: 2.19.1
digest: sha256:6ac1ef1f7d9e56775e492722e94ffd21fd88240500c2e25ef3eaafaeb30349a7
generated: "2024-04-02T16:35:08.972929184+02:00"
6 changes: 3 additions & 3 deletions bitnami/magento/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ dependencies:
repository: oci://registry-1.docker.io/bitnamicharts
tags:
- magento-database
version: 15.x.x
version: 18.x.x
- condition: elasticsearch.enabled
name: elasticsearch
repository: oci://registry-1.docker.io/bitnamicharts
version: 19.x.x
version: 20.x.x
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
Expand All @@ -48,4 +48,4 @@ maintainers:
name: magento
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/magento
version: 25.5.0
version: 26.0.0
136 changes: 75 additions & 61 deletions bitnami/magento/README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions bitnami/magento/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name "elasticsearch" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return Elasticsearch port
*/}}
{{- define "magento.elasticsearch.port" -}}
{{- if .Values.elasticsearch.enabled -}}
{{- print .Values.elasticsearch.service.ports.restAPI -}}
{{- else -}}
{{- print .Values.externalElasticsearch.port -}}
{{- end -}}
{{- end -}}

{{/*
Get the user defined LoadBalancerIP for this release.
Note, returns 127.0.0.1 if using ClusterIP.
Expand Down
8 changes: 1 addition & 7 deletions bitnami/magento/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,7 @@ spec:
value: ""
{{- end }}
- name: ELASTICSEARCH_PORT_NUMBER
{{- if .Values.elasticsearch.enabled }}
value: "9200"
{{- else if .Values.externalElasticsearch.port }}
value: {{ .Values.externalElasticsearch.port | quote }}
{{- else }}
value: ""
{{- end }}
value: {{ include "magento.elasticsearch.port" . | quote }}
- name: MAGENTO_SKIP_BOOTSTRAP
value: {{ ternary "yes" "no" .Values.magentoSkipInstall | quote }}
{{- $port:=.Values.service.ports.http | toString }}
Expand Down
80 changes: 0 additions & 80 deletions bitnami/magento/templates/networkpolicy-backend-ingress.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions bitnami/magento/templates/networkpolicy-egress.yaml

This file was deleted.

63 changes: 0 additions & 63 deletions bitnami/magento/templates/networkpolicy-ingress.yaml

This file was deleted.

90 changes: 90 additions & 0 deletions bitnami/magento/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
policyTypes:
- Ingress
- Egress
{{- if .Values.networkPolicy.allowExternalEgress }}
egress:
- {}
{{- else }}
egress:
# Allow dns resolution
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow outbound connections to MariaDB
- ports:
- port: {{ include "magento.databasePort" . }}
{{- if .Values.mariadb.enabled }}
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: mariadb
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
# Allow outbound connections to Elasticsearch
- ports:
- port: {{ include "magento.elasticsearch.port" . | int }}
{{- if .Values.elasticsearch.enabled }}
to:
- podSelector:
matchLabels:
app.kubernetes.io/name: elasticsearch
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- if .Values.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
ingress:
- ports:
- port: {{ .Values.containerPorts.http }}
- port: {{ .Values.containerPorts.https }}
{{- range .Values.extraContainerPorts }}
- port: {{ . }}
{{- end }}
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
- podSelector:
matchLabels:
{{ template "common.names.fullname" . }}-client: "true"
{{- if .Values.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels:
{{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels:
{{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
Loading
Loading