shopware
by Shopware
A Helm chart for deploying a Shopware shop on Kubernetes. Requires the Shopware Operator chart to be installed.
About this chart
Shopware Helm Chart
Table of Contents
- Cluster Installation
- Usage
- Information
Cluster Installation
This Helm chart can be installed locally or within an existing Kubernetes cluster, using tools like ArgoCD. This guide focuses on a simple local installation to help you get started.
This Helm chart installs the Percona Operator along with a MySQL database and RustFS for S3-compatible object storage. For more information on Percona, visit Percona's website. For more information on RustFS, visit the RustFS GitHub repository. Currently, this Helm chart supports Percona and RustFS by default. However, you can modify the configuration to your needs.
[!WARNING] The Percona operator installed with this Helm chart currently does not support ARM64 images. Therefore, it is essential to ensure that AMD64 nodes are available within your cluster. While it is possible to use a different database system, please note that this Helm chart officially supports only Percona. We are aware of this limitation and have included it in our development roadmap.
Existing Cluster
Prerequisites
- Kubernetes v1.28.0+
- Helm v3
- S3 based api (More Details)
- Optional: KEDA operator and CRDs, if you want the worker deployments to scale on queue length (More Details)
- Optional: cert-manager, if you want to enable the validating webhook of the operator (More Details)
If you have an existing cluster make sure the prerequisites are installed and go directly to Usage.
Local Test Cluster
Prerequisites
Install Kind
Kind is a tool for running local Kubernetes clusters using Docker container “nodes”. It was primarily designed for testing Kubernetes itself but is also useful for local development or CI.
For more information, visit the Kind documentation.
To properly set up the network configuration, we provide a baseline config file for Kind. To create the cluster, execute:
kind create cluster --config kind-config.yaml
# Install Gateway API CRDs
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.1/standard-install.yaml
Install Ingress in Kind
Ingress is a Kubernetes resource that manages external access to services in a cluster, providing load balancing, SSL termination, and name-based virtual hosting. To enable this, deploy an ingress resource such as NGINX:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
[!NOTE] This setup may take a few seconds. You can either grab a coffee or check the pod ready status with:
kubectl wait --namespace ingress-nginx \ --for=condition=ready pod \ --selector=app.kubernetes.io/component=controller \ --timeout=90s
Load local Images into your cluster
You can use this process to load a local image into your cluster, a common practice for this test environment. For a complete guide, refer to Loading an Image into Your Cluster.
You can build a local shopware image and load the image into the Kind cluster:
kind load docker-image <your-image>
If you need guidance on creating a Docker image, please refer to the Creating a Docker Image section.
[!NOTE] Ensure that the
PullImagePolicyis not set toAlways, as this will force the cluster to attempt to pull the image from a remote repository, which may not be available.
Usage
Once you have a running cluster with S3 and ingress support, you can install this Helm chart. Customize the installation using the values.yaml file.
Minimal Installation
For a minimal installation, run:
helm repo add shopware https://shopware.github.io/helm-charts/
helm install operator shopware/operator --namespace shopware --create-namespace
helm install my-shop shopware/shopware --namespace shopware --create-namespace
If you want to use your own image use:
helm repo add shopware https://shopware.github.io/helm-charts/
helm install operator shopware/operator --namespace shopware --create-namespace
helm install my-shop shopware/shopware --namespace shopware --create-namespace --set store.container.image=<image-name>
[!WARNING] While a default image is provided with this Helm chart, it is recommended that you do not use it. Instead, create your own custom Docker images and override the default image in the Helm chart.
After applying the Helm chart, you can monitor the status of the store resource using:
kubectl get stores -n shopware --watch
[!NOTE] The RustFS storage and database setup may take a few seconds, that's why you can run into setup errors.
Once the setup job in your cluster is complete and your store is in the ready state, you can access the shop at https://localhost.traefik.me/ If needed, you can modify the domain by updating the values.yaml file.
Create Docker image shopware-cli
For shopware running in a docker container we have a new way of supporting this. You can find the starting documentation in our docs.
shopware-cli project create test -n --docker --version 6.7.13.1
cd test
composer require shopware/k8s-meta --ignore-platform-reqs
Currently we also need to update the Dockerfile manually, make sure that
you use -otel for the base-image and add the extension enabled to your line.
printf '%s' '#syntax=docker/dockerfile:1.4
ARG PHP_VERSION=8.4
# We use otel in kubernetes so make sure we set this also in this image.
FROM ghcr.io/shopware/docker-base:$PHP_VERSION-caddy-otel AS base-image
FROM ghcr.io/shopware/shopware-cli:latest-php-$PHP_VERSION AS shopware-cli
FROM shopware-cli AS build
# We need open telemetry for the build process, so we need to enable it here.
RUN docker-php-ext-enable opentelemetry
ADD . /src
WORKDIR /src
RUN /usr/local/bin/entrypoint.sh shopware-cli project ci /src
FROM base-image AS final
COPY --from=build --chown=82 --link /src /var/www/html
' > Dockerfile
After adding the Dockerfile create two tagged versions for the repository like this:
docker build -t test:v1 -f Dockerfile .
docker build -t test:v2 -f Dockerfile .
Then, load the images into your container registry for the cluster. If you're using Kind, use the following command:
kind load docker-image test:v1
kind load docker-image test:v2
Finally, patch the current installation or install it from base and patch the values.yaml file with the docker image:
helm upgrade my-shop shopware/shopware --namespace shopware --set store.container.image=test:v1
kubectl get stores -n shopware --watch
If you now patch the image again you can see a migration happening in the shopware-operator. Image updates with a new different image always triggers a new update and a migration job to happen. This will then use the deployment-helper under the hood.
helm upgrade my-shop shopware/shopware --namespace shopware --set store.container.image=test:v2
kubectl get stores -n shopware --watch
TLS with Nginx controller
If you want to enable TLS termination with Traefik and do not require custom certificates, you can use the following snippet to utilize the public certificates from Traefik for proper TLS termination:
# Create a directory to store the certificates
mkdir -p certs
# Download the public certificates from traefik.me
wget -O certs/privkey.pem https://traefik.me/privkey.pem
wget -O certs/fullchain.pem https://traefik.me/fullchain.pem
# Create a Kubernetes secret to store the certificates
kubectl create secret tls traefik-me-cert \
--cert=certs/fullchain.pem --key=certs/privkey.pem \
--namespace=ingress-nginx --dry-run=client -o yaml | kubectl apply -f -
# Verify if the default SSL certificate is already set; if not, patch the deployment
kubectl get deployment ingress-nginx-controller -n ingress-nginx -o jsonpath='{.spec.template.spec.containers[0].args}' | grep -q -- '--default-ssl-certificate=ingress-nginx/traefik-me-cert' && echo "Certificate already added" || kubectl patch deployment ingress-nginx-controller -n ingress-nginx --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--default-ssl-certificate=ingress-nginx/traefik-me-cert"}]'
This configuration will download the required certificates, create a Kubernetes secret to store them, and ensure that the Ingress controller uses the correct certificate for TLS termination.
[!WARNING] This configuration is not recommended for use in a production environment, as it does not provide secure traffic for your shop.
Operator
The Operator is not designed to be used on a cluster level. Each namespace should have its own operator installation. The operator is responsible for managing the lifecycle of Shopware stores, including creating and updating deployments, services, and other resources. It is installed with the operator chart, see Minimal Installation.
The operator chart renders its Custom Resource Definitions (CRDs) as regular templates, so helm install
and helm upgrade install and update the CRDs together with the operator. No separate CRD installation
step is required.
Optional features are disabled by default and have to be activated in the operator chart:
metrics.enabled=trueexposes an HTTP endpoint with store metrics and the queue length API. AServiceMonitorfor Prometheus can be enabled on top of it.webhook.enabled=trueinstalls aValidatingWebhookConfigurationthat validates the schemaless container override fields of aStoreon create and update. This requires cert-manager in the cluster.keda.enabled=truelets the operator manage KEDA resources for the worker deployments, see Worker autoscaling with KEDA. This requires the KEDA CRDs andmetrics.enabled=true.
For the CRD lifecycle, the available values and a more advanced setup, see the operator chart README.
Worker autoscaling with KEDA
[!IMPORTANT] Worker autoscaling requires shopware-operator 1.9.0 or newer. Older operator versions ship a
StoreCRD without the KEDA fields, sospec.worker.enableKedaScalingand the tuning fields below are pruned by the API server and the setting has no effect.
The operator can scale the Shopware message queue workers based on the queue length using
KEDA. This is optional. Without KEDA the operator creates a single worker deployment
that consumes all queues (failed, async and low_priority) and uses the fixed replica count from
store.container.replicas or store.workerDeploymentContainer.replicas.
With KEDA enabled the operator creates one worker deployment per queue and a KEDA ScaledObject for each
of them, which scales on the queue length read from the operator metrics endpoint. Additional transports
configured in your shop are picked up automatically once the operator has collected the queue statistics
from the admin pod.
KEDA has to be enabled in two places: in the operator chart, so the operator watches the KEDA resources,
and in this chart for the store, so the operator creates the per queue deployments and ScaledObject
resources for it. To use it you need to:
-
Install the KEDA operator together with its CRDs and enable
keda.enabled=trueandmetrics.enabled=truein the operator chart (1.9.0 or newer), see the operator chart README. -
Install this chart with KEDA scaling enabled for the store:
helm install my-shop shopware/shopware --namespace shopware --create-namespace \ --set store.worker.enableKedaScaling=trueOr in your values file:
store: worker: enableKedaScaling: true # Optional, the defaults of the Store resource are used when they are not set maxReplicas: 3 minReplicas: 0 cooldownPeriod: 30 pollingInterval: 10 targetQueueLength: 100
After the store is ready you can inspect the created resources:
kubectl get deployments -n shopware -l shop.shopware.com/store.app=shopware-worker
kubectl get scaledobjects -n shopware
[!NOTE] The replica count from
store.container.replicasandstore.workerDeploymentContainer.replicasis only used as the initial value for the worker deployments when KEDA is enabled. KEDA takes over the scaling afterwards. The queue statistics are collected from the admin pod, so the admin deployment must be running for the workers to scale.
Network policies
The chart creates a NetworkPolicy for the store's pods (storefront, admin, worker and jobs) by default. It only
takes effect with a CNI that enforces NetworkPolicy. Set store.networkPolicy.create: false to disable it.
store:
networkPolicy:
create: true
deniedEgressCIDRs:
- 169.254.169.254/32
- fd00:ec2::254/128
The policy allows all egress except store.networkPolicy.deniedEgressCIDRs. By default this blocks the cloud
metadata service, which
Deploy shopware with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has shopware on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartshopware is pinned at v2.5.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply