CKAD · 25 November 2026 · 7 min read
Kubernetes adapter pattern: metrics exporters and log normalizers
An adapter is a container in your app's Pod that makes the app look standard from outside: Prometheus metrics, clean log streams, enriched data. How it works, redis_exporter beside Redis, a log-streaming example, the YAML and when not to use it.
The adapter pattern puts a helper container in the same Pod as your app to change how the app looks from the outside. The adapter reads whatever the app produces, in whatever shape the app produces it, and presents it in the standard shape the rest of your system expects. The everyday example is a Prometheus exporter: redis_exporter runs beside Redis, reads Redis's own stats over localhost, and serves them as Prometheus metrics, without a single change to Redis.
TL;DR
- An adapter is a container beside the app in one Pod that turns the app's output into a standard interface: metrics, logs or data.
- It reads the app over
localhostor a shared volume, so the app image stays exactly as it is. - Three uses: transposing data into another format (a metrics exporter), log streaming, and data enrichment.
- Main example:
redis_exporteras a sidecar to Redis, serving Prometheus metrics on port 9121. - Ambassador vs adapter: the ambassador simplifies the outside world for the app; the adapter simplifies the app for the outside world.
- Exam: CKAD Application Design and Build (20%), under "multi-container Pod design patterns (e.g. sidecar, init and others)".
This is part 5 of the Kubernetes Pod Patterns series. Part 4 covers the ambassador, the adapter's mirror image.
How the adapter pattern works
Theme: presenting your app to the outside world
Monitoring, logging and other shared systems want every app to look the same: one metrics format, one place for logs, one record layout. Apps are not built that way.
Problem: every app reports in its own way
Burns and Oppenheimer's 2016 paper on container design patterns gives the classic case. Apps export metrics in different ways, "JMX, statsd, etc", so a monitoring system must learn each one. Google got uniform metrics by code convention, which the paper notes "is only possible if you build your software from scratch". Most of us run software we did not write: Redis, MySQL, a vendor's Java app.
Solution: a translator beside the app
The paper's definition: adapters "present the outside world with a simplified, homogenized view of an application" by standardizing output and interfaces across containers. The adapter talks to the main container "through localhost or a shared local volume", then gives every Pod the same interface. The Kubernetes blog calls it the adapter "(or sometimes façade)" and adds transforming legacy data formats, bridging protocols and joining up mismatched services.

In Kubernetes: essentially a sidecar
Like the ambassador, the adapter has no field of its own in a Pod spec. It is a sidecar with one job, written as a second container that shares the Pod's network and, where it needs files, a volume. Today that usually means a native sidecar: an entry in initContainers with restartPolicy: Always, stable since Kubernetes 1.33.
Three things an adapter does
- Transpose data: read the app's output in one format and serve it in another. A Prometheus exporter is the standard case: Prometheus's own docs describe exporters as the way to export "existing metrics from third-party systems as Prometheus metrics" where "it is not feasible to instrument a given system with Prometheus metrics directly". Exporters exist for MySQL, Redis, JMX and StatsD, among many others.
- Log streaming: an app writes several log files, and Kubernetes reads only a container's standard output. The logging docs show a streaming sidecar that tails one file and writes it to its own stdout, one sidecar per file, so the node's log agent and
kubectl logscan read each stream. - Data enrichment: add what the outside system needs and the app does not know, for example tagging each record with where it came from, before passing it on.
The concrete pair: Redis and redis_exporter
Redis reports its stats in its own format; Prometheus scrapes metrics in its own format over HTTP. You could teach Redis to speak Prometheus, but Redis is not your code. So you put redis_exporter beside it. Its README ships "an example Kubernetes deployment configuration for how to deploy the redis_exporter as a sidecar to a Redis instance", and both it and the official MySQL exporter are actively maintained (redis_exporter v1.99.0 came out on 24 Nov 2026).

In a cluster, the app's clients and Prometheus see two different faces of the same Pod. Clients reach Redis through a Service on port 6379; Prometheus scrapes the adapter on port 9121; the adapter reads Redis on localhost:

The YAML
A Redis Deployment with redis_exporter as a native sidecar. The exporter's defaults already fit the Pod: it connects to redis://localhost:6379 and serves metrics on port 9121 at /metrics, so it needs no settings:
apiVersion: apps/v1kind: Deploymentmetadata: name: redisspec: replicas: 1 selector: matchLabels: app: redis template: metadata: labels: app: redis spec: initContainers: - name: redis-exporter # the adapter image: oliver006/redis_exporter:v1.99.0 restartPolicy: Always # a native sidecar ports: - name: metrics containerPort: 9121 containers: - name: redis image: redis:7.4 ports: - name: redis containerPort: 6379Look at what the adapter serves without setting up Prometheus:
kubectl port-forward deploy/redis 9121:9121curl -s localhost:9121/metrics | headYou will see lines of Prometheus text format. Then point your Prometheus at port 9121 of the Redis Pods. You will also see exporters written as a second entry in containers; that works too. The native form gives it a fixed place in the start and stop order.
A log-streaming adapter
The same shape for logs, adapted from the Kubernetes logging docs (CC BY 4.0). The app writes two files; each adapter turns one file into its own stream:
apiVersion: v1kind: Podmetadata: name: legacy-appspec: initContainers: - name: access-log image: busybox:1.36 restartPolicy: Always command: ['sh', '-c', 'touch /var/log/app/access.log; tail -F /var/log/app/access.log'] volumeMounts: - name: logs mountPath: /var/log/app - name: error-log image: busybox:1.36 restartPolicy: Always command: ['sh', '-c', 'touch /var/log/app/error.log; tail -F /var/log/app/error.log'] volumeMounts: - name: logs mountPath: /var/log/app containers: - name: app image: busybox:1.36 command: ['sh', '-c', 'while true; do echo "$(date) GET /" >> /var/log/app/access.log; echo "$(date) slow query" >> /var/log/app/error.log; sleep 5; done'] volumeMounts: - name: logs mountPath: /var/log/app volumes: - name: logs emptyDir: {}Now kubectl logs legacy-app -c error-log shows only the errors.
When not to use it
- You own the code. If you can add a Prometheus client library to your own app, do that. Exporters exist for software you cannot instrument directly.
- One log file. The logging docs advise writing a single log straight to
/dev/stdoutrather than adding a sidecar to stream it. - A full logging agent in every Pod. Running an agent such as fluentd as a sidecar "can lead to significant resource consumption", and its own logs are not visible to
kubectl logs. - The cost of one more container. Every adapter must be sized, patched and monitored, and, as the paper puts it, sets of containers "generally can't be upgraded atomically", so the test matrix grows.
For the exam
The CKAD curriculum (v1.37) asks you to "understand multi-container Pod design patterns (e.g. sidecar, init and others)" under Application Design and Build (20%). Up to v1.21 it named the adapter explicitly; it is now one of the "others". An adapter task usually looks like the log example above: an app writes something to a shared volume, and you add a container that reshapes or streams it. Be quick with an emptyDir mounted into both containers, a tail -F or sed loop in busybox, and kubectl logs <pod> -c <container> to prove it works.
Common questions
What is the difference between an adapter and an ambassador?
Direction. In the paper's words, the ambassador "presents an application with a simplified view of the outside world"; the adapter presents the outside world with a simplified view of the application. Ambassadors handle the app's outbound calls; adapters handle how others read the app.
Is an adapter a sidecar?
Yes, a sidecar with one job: translation. You declare it exactly like any other sidecar.
How does the adapter get the app's data?
Over localhost, because containers in a Pod share one network, or through a shared volume, because they can mount the same one. The metrics exporter uses the first; the log streamer uses the second.
Does Prometheus scrape the app or the adapter?
The adapter. The app keeps its own port for its real clients, and the adapter serves metrics on a port of its own (9121 for redis_exporter). Both ports belong to the same Pod IP, so they must not clash.
Keep going
The rest of the series: multi-container Pod patterns (the overview), init containers, sidecar containers, the ambassador pattern and service mesh sidecars vs ambient mode.
The Gazeek CKAD course runs every lab on a real cluster, and its Pods and multi-container patterns module has you put helpers, adapters included, beside an app sharing a volume. For more exam-style tasks, try the CKAD practice questions with answers, and keep field names fresh with the free Gazeek Memory Gym.