Sidecars & extra volumes
The Drupal Operator lets you extend the main Drupal pod with:
- Extra environment variables
- Sidecar containers
- Extra volumes and volume mounts
These are provided as multiline YAML snippets in the Drupal spec and
are inserted directly into the generated Kubernetes manifests.
Extra environment variables
Use drupal_extra_envs to inject additional environment variables into the
main Drupal container.
Example:
spec:
drupal_extra_envs: |-
- name: DRUPAL_EXTRA_ENV
value: fooisbar
- name: DRUPAL_EXTRA_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PASSWORD
valueFrom:
secretKeyRef:
name: my-secrets
key: password
This block becomes part of the env list for the Drupal container.
Sidecar containers
Use drupal_sidecars to define additional containers that run in the same
pod as the Drupal container.
Simple example:
spec:
drupal_sidecars: |-
- name: foo
image: nginx:1.14.2
ports:
- containerPort: 80
Sidecars can be used for:
- Reverse proxies or additional HTTP endpoints
- Logging / metrics exporters
- Utility containers that share volumes with Drupal
You can mount shared volumes into both the main Drupal container and sidecars.
Extra volumes and volume mounts
The operator lets you add extra volumes and mounts to the Drupal pod:
drupal_extra_volumes: extra volume definitionsdrupal_extra_volumes_mounts: extra volumeMounts on the Drupal container
Example: mount a config map special-config into the Drupal container.
spec:
drupal_extra_volumes: |-
- name: config-volume
configMap:
name: special-config
drupal_extra_volumes_mounts: |-
- name: config-volume
mountPath: /etc/config
This results in:
- A volume named
config-volumethat referencesConfigMap/special-config - A mount of that volume at
/etc/configin the Drupal container
Mounting volumes into sidecars
To mount the same volumes into sidecars, define the volumeMounts directly
in the drupal_sidecars snippet.
Example: reuse config-volume in an Nginx sidecar:
spec:
drupal_extra_volumes: |-
- name: config-volume
configMap:
name: special-config
drupal_sidecars: |-
- name: foo
image: nginx:1.14.2
ports:
- containerPort: 80
volumeMounts:
- name: config-volume
mountPath: /etc/config
In this setup:
config-volumeis shared between Drupal and thefoosidecar.- Both containers can read from
/etc/config(or different mount paths).
Common use cases
Some examples of how you might use these features:
-
TLS certificates Mount certificate secrets into both Drupal and a sidecar that terminates TLS.
-
Extra configuration Provide environment-specific config via ConfigMaps and mount them as files.
-
Log shipping / monitoring Add a log shipper (e.g. Fluent Bit) or monitoring agent as a sidecar that reads logs from a shared volume.
-
Debugging / maintenance Temporarily add a sidecar with tools (curl, shell, etc.) to inspect the runtime environment without modifying the Drupal image.
Because these fields are raw YAML snippets, make sure the indentation and structure are valid YAML; the operator will not validate them beyond what Kubernetes itself checks when applying the resulting manifests.