diff --git a/stable/magento/Chart.yaml b/stable/magento/Chart.yaml index e8ce70881e..f0d8fd1380 100644 --- a/stable/magento/Chart.yaml +++ b/stable/magento/Chart.yaml @@ -1,5 +1,5 @@ name: magento -version: 3.3.0 +version: 4.0.0 appVersion: 2.2.6 description: A feature-rich flexible e-commerce solution. It includes transaction options, multi-store functionality, loyalty programs, product categorization and shopper filtering, promotion rules, and more. keywords: diff --git a/stable/magento/templates/NOTES.txt b/stable/magento/templates/NOTES.txt index 6f0a4ab2e4..65486ca547 100644 --- a/stable/magento/templates/NOTES.txt +++ b/stable/magento/templates/NOTES.txt @@ -10,12 +10,12 @@ host. To configure Magento with the URL of your service: 1. Get the Magento URL by running: - {{- if contains "NodePort" .Values.serviceType }} + {{- if contains "NodePort" .Values.service.type }} export APP_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "magento.fullname" . }} -o jsonpath="{.spec.ports[0].nodePort}") export APP_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - {{- else if contains "LoadBalancer" .Values.serviceType }} + {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "magento.fullname" . }}' @@ -39,22 +39,23 @@ host. To configure Magento with the URL of your service: ## PLEASE UPDATE THE EXTERNAL DATABASE CONNECTION PARAMETERS IN THE FOLLOWING COMMAND AS NEEDED ## helm upgrade {{ .Release.Name }} stable/magento \ - --set magentoPassword=$APP_PASSWORD,magentoHost=$APP_HOST,serviceType={{ .Values.serviceType }},mariadb.enabled=false{{- if not (empty .Values.externalDatabase.host) }},externalDatabase.host={{ .Values.externalDatabase.host }}{{- end }}{{- if not (empty .Values.externalDatabase.user) }},externalDatabase.user={{ .Values.externalDatabase.user }}{{- end }}{{- if not (empty .Values.externalDatabase.password) }},externalDatabase.password={{ .Values.externalDatabase.password }}{{- end }}{{- if not (empty .Values.externalDatabase.database) }},externalDatabase.database={{ .Values.externalDatabase.database }}{{- end }} + --set magentoPassword=$APP_PASSWORD,magentoHost=$APP_HOST,service.type={{ .Values.service.type }},mariadb.enabled=false{{- if not (empty .Values.externalDatabase.host) }},externalDatabase.host={{ .Values.externalDatabase.host }}{{- end }}{{- if not (empty .Values.externalDatabase.user) }},externalDatabase.user={{ .Values.externalDatabase.user }}{{- end }}{{- if not (empty .Values.externalDatabase.password) }},externalDatabase.password={{ .Values.externalDatabase.password }}{{- end }}{{- if not (empty .Values.externalDatabase.database) }},externalDatabase.database={{ .Values.externalDatabase.database }}{{- end }} {{- end }} {{- else -}} 1. Get the Magento URL by running: -{{- if eq .Values.serviceType "ClusterIP" }} +{{- if eq .Values.service.type "ClusterIP" }} echo "Store URL: http://127.0.0.1:8080/" echo "Admin URL: http://127.0.0.1:8080/{{ .Values.magentoAdminUri }}" - kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "magento.fullname" . }} 8080:80 + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "magento.fullname" . }} 8080:{{ .Values.service.port }} {{- else }} - echo Store URL : http://{{ include "magento.host" . }}/ - echo Admin URL : http://{{ include "magento.host" . }}/{{ .Values.magentoAdminUri }} +{{- $port:=.Values.service.port | toString }} + echo Store URL : http://{{ include "magento.host" . }}{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}/ + echo Admin URL : http://{{ include "magento.host" . }}{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}/{{ .Values.magentoAdminUri }} {{- end }} @@ -76,9 +77,9 @@ host. To configure Magento to use and external database host: 1. Complete your Magento deployment by running: -{{- if contains "NodePort" .Values.serviceType }} +{{- if contains "NodePort" .Values.service.type }} export APP_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") -{{- else if contains "LoadBalancer" .Values.serviceType }} +{{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "magento.fullname" . }}' @@ -93,5 +94,5 @@ host. To configure Magento to use and external database host: ## PLEASE UPDATE THE EXTERNAL DATABASE CONNECTION PARAMETERS IN THE FOLLOWING COMMAND AS NEEDED ## helm upgrade {{ .Release.Name }} stable/magento \ - --set magentoPassword=$APP_PASSWORD,magentoHost=$APP_HOST,serviceType={{ .Values.serviceType }},mariadb.enabled=false{{- if not (empty .Values.externalDatabase.user) }},externalDatabase.user={{ .Values.externalDatabase.user }}{{- end }}{{- if not (empty .Values.externalDatabase.password) }},externalDatabase.password={{ .Values.externalDatabase.password }}{{- end }}{{- if not (empty .Values.externalDatabase.database) }},externalDatabase.database={{ .Values.externalDatabase.database }}{{- end }},externalDatabase.host=YOUR_EXTERNAL_DATABASE_HOST + --set magentoPassword=$APP_PASSWORD,magentoHost=$APP_HOST,service.type={{ .Values.service.type }},mariadb.enabled=false{{- if not (empty .Values.externalDatabase.user) }},externalDatabase.user={{ .Values.externalDatabase.user }}{{- end }}{{- if not (empty .Values.externalDatabase.password) }},externalDatabase.password={{ .Values.externalDatabase.password }}{{- end }}{{- if not (empty .Values.externalDatabase.database) }},externalDatabase.database={{ .Values.externalDatabase.database }}{{- end }},externalDatabase.host=YOUR_EXTERNAL_DATABASE_HOST {{- end }} diff --git a/stable/magento/templates/_helpers.tpl b/stable/magento/templates/_helpers.tpl index 7fdce86d89..c032a3f24a 100644 --- a/stable/magento/templates/_helpers.tpl +++ b/stable/magento/templates/_helpers.tpl @@ -44,7 +44,7 @@ Get the user defined LoadBalancerIP for this release. Note, returns 127.0.0.1 if using ClusterIP. */}} {{- define "magento.serviceIP" -}} -{{- if eq .Values.serviceType "ClusterIP" -}} +{{- if eq .Values.service.type "ClusterIP" -}} 127.0.0.1 {{- else -}} {{- index .Values (printf "%sLoadBalancerIP" .Chart.Name) | default "" -}} diff --git a/stable/magento/templates/deployment.yaml b/stable/magento/templates/deployment.yaml index fa104f8d39..d3748050e4 100644 --- a/stable/magento/templates/deployment.yaml +++ b/stable/magento/templates/deployment.yaml @@ -78,8 +78,9 @@ spec: name: {{ template "magento.fullname" . }}-externaldb key: db-password {{- end }} + {{- $port:=.Values.service.port | toString }} - name: MAGENTO_HOST - value: {{ include "magento.host" . | quote }} + value: "{{ include "magento.host" . }}{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}" - name: MAGENTO_USERNAME value: {{ .Values.magentoUsername | quote }} - name: MAGENTO_PASSWORD diff --git a/stable/magento/templates/svc.yaml b/stable/magento/templates/svc.yaml index 93f2438e93..d20d17a321 100644 --- a/stable/magento/templates/svc.yaml +++ b/stable/magento/templates/svc.yaml @@ -8,16 +8,16 @@ metadata: release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: - type: {{ .Values.serviceType }} - {{- if eq .Values.serviceType "LoadBalancer" }} - loadBalancerIP: {{ default "" .Values.magentoLoadBalancerIP }} + type: {{ .Values.service.type }} + {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }} + externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }} {{- end }} ports: - - name: http - port: 80 - targetPort: http - - name: https - port: 443 - targetPort: https + - name: http + port: {{ .Values.service.port }} + targetPort: http + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}} + nodePort: {{ .Values.service.nodePorts.http }} + {{- end }} selector: app: {{ template "magento.fullname" . }} diff --git a/stable/magento/values.yaml b/stable/magento/values.yaml index 11c4f4aa05..8459bd832f 100644 --- a/stable/magento/values.yaml +++ b/stable/magento/values.yaml @@ -140,7 +140,23 @@ mariadb: ## Kubernetes configuration ## For minikube, set this to NodePort, elsewhere use LoadBalancer ## -serviceType: LoadBalancer +service: + type: LoadBalancer + # HTTP Port + port: 80 + # HTTPS Port + httpsPort: 443 + ## + ## nodePorts: + ## http: + ## https: + nodePorts: + http: "" + https: "" + ## Enable client source IP preservation + ## ref http://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip + ## + externalTrafficPolicy: Cluster ## Configure liveness and readiness probes ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)