Helm chart: cannot expose Memcached port (11211) correctly via Service; `service.port=11211` still routes to Redis port (6379) because Service `targetPort` is fixed
Describe the bug
When deploying Dragonfly via the official OCI Helm chart and enabling Memcached mode (--memcached_port=11211), setting service.port: 11211 does not expose the Memcached protocol on the Service. The Service still routes traffic to the Redis listener (6379) because the chart’s Service targetPort is fixed to the named port dragonfly (which maps to containerPort 6379).
This makes “drop-in memcached replacement on Kubernetes” non-trivial: users have to create an additional Service (e.g. via extraObjects) that explicitly targets port 11211.
To Reproduce
Install the chart
oci://ghcr.io/dragonflydb/dragonfly/helm/dragonfly(example versionv1.34.2) with values like:extraArgs: - --memcached_port=11211 service: port: 11211Observe Service and endpoints:
kubectl -n <ns> get svc <release-name> -o yaml kubectl -n <ns> get endpoints <release-name> -o wideYou’ll see that even if the Service port is 11211, the endpoints point to
:6379(Redis).Optional protocol proof (port-forwarding the Service to localhost):
kubectl -n <ns> port-forward svc/<release-name> 11211:11211 printf '*1\r\n$4\r\nPING\r\n' | nc -w 2 127.0.0.1 11211Output is
+PONG(Redis), i.e. the Service is routing to 6379, not to Memcached.
Expected behavior
If --memcached_port=11211 is configured and I set service.port: 11211, the Service should route to the Memcached listener (pod port 11211), so memcached clients can use <service>:11211 normally.
Actual behavior
The Service exposes port 11211 but routes to pod port 6379 because targetPort remains the fixed named port dragonfly (containerPort 6379). Memcached text protocol via the Service does not work as expected because traffic hits the Redis listener.
Reproducible Code Snippet
# values.yaml
extraArgs:
- --memcached_port=11211
service:
port: 11211Additional context
Root cause: Kubernetes Services route based on
targetPort(can be a number or a named port). The chart’s Service template uses a fixedtargetPort: dragonfly, and the pod defines only the named portdragonfly: 6379, so changingservice.portalone can’t route to 11211. Kubernetes Service docs:https://kubernetes.io/docs/concepts/services-networking/service/Chart values expose
service.port, but there is noservice.targetPortoption; however the chart supportsextraObjectsfor adding manifests. Chart values/README (showingextraObjects):https://raw.githubusercontent.com/dragonflydb/dragonfly/main/contrib/charts/dragonfly/values.yamlhttps://raw.githubusercontent.com/dragonflydb/dragonfly/main/contrib/charts/dragonfly/README.md
Workaround we used: keep the chart Service on 6379, and create a separate Service for Memcached via
extraObjects:service: port: 6379 extraObjects: - apiVersion: v1 kind: Service metadata: name: memcached spec: type: ClusterIP selector: app.kubernetes.io/instance: <release-name> app.kubernetes.io/name: dragonfly ports: - name: memcached port: 11211 targetPort: 11211 protocol: TCPProposed fix (chart UX improvement):
- Add
service.targetPortsupport, or - Add first-class
memcachedService/ multi-port Service support when--memcached_portis configured, and/or - Add a named container port for 11211 when memcached is enabled (so
targetPort: memcachedis possible).
- Add
Related but not the same issue (for context; none of these covers the Helm Service mapping problem directly):
https://github.com/dragonflydb/dragonfly/issues/303(memcached protocol topic)https://github.com/dragonflydb/dragonfly/issues/5096(memcached_port equals redis port crash)https://github.com/dragonflydb/dragonfly/issues/874(shows chart patterntargetPort: dragonfly, but different problem)
Source: dragonflydb/dragonfly