title: How to Send Kubernetes Logs to AWS CloudWatch?
body: <h1>AWS CloudWatch Logs in Docker</h1>
  
  <p>Setting an AWS CloudWatch Logs driver in <code>docker</code> is done with <code>log-driver=awslogs</code> and <code>log-opt</code>, for example -</p>
  
  <pre><code>#!/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
  </code></pre>
  
  <h1>My Problem</h1>
  
  <p>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 <code>create</code> / <code>apply</code>.</p>
  
  <h1>My Question</h1>
  
  <p><strong>How can I send the <code>log-driver</code> and <code>log-opt</code> parameters to a Docker container in a pod / deployment?</strong></p>
  
  <h1>What have I tried</h1>
  
  <ul>
  <li>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.</li>
  <li>RTFM for <a href="https://kubernetes-v1-4.github.io/docs/user-guide/kubectl/kubectl_apply/" rel="noreferrer"><code>kubectl apply</code></a></li>
  <li>Reading the <a href="https://github.com/kubernetes/kops/blob/master/vendor/github.com/docker/docker/docs/admin/logging/awslogs.md" rel="noreferrer">relevant README in <code>kops</code></a></li>
  <li>Read <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="noreferrer"><code>Kubernetes Logging Architecture</code></a></li>
  </ul>