AWS CloudWatch Logs in Docker
Setting an AWS CloudWatch Logs driver in docker is done with log-driver=awslogs and log-opt, for example -
#!/bin/bash
docker run \
--log-driver=awslogs \
--log-opt awslogs-region=eu-central-1 \
--log-opt awslogs-group=whatever-group \
--log-opt awslogs-stream=whatever-stream \
--log-opt awslogs-create-group=true \
wernight/funbox \
fortune
My Problem
I would like to use AWS CloudWatch logs in a Kubernetes cluster, where each pod contains a few Docker containers. Each deployment would have a separate Log Group, and each container would have a separate stream. I could not find a way to send the logging parameters to the docker containers via Kubernetes create / apply.
My Question
How can I send the log-driver and log-opt parameters to a Docker container in a pod / deployment?
What have I tried
- Setting relevant parameters for the Docker daemon on each machine. It's possible, but this way all the containers on the same machine would share the same stream - therefore irrelevant for my case.
- RTFM for
kubectl apply - Reading the relevant README in
kops - Read
Kubernetes Logging Architecture