---
apiVersion: v1
kind: ConfigMap
metadata:
  name: example-vault-agent-config
  namespace: default
data:
  consul-template-config.hcl: |
    vault {
      renew_token = false
      vault_agent_token_file = "/home/vault/.vault-token"
      retry {
        backoff = "1s"
      }
    }

    template {
      destination = "/etc/secrets/index.html"
      contents = <<EOH
      <html>
      <body>
      <p>Some secrets:</p>
      {{- with secret "otus/otus-ro/config" }}
      <ul>
      <li><pre>username: {{ .Data.username }}</pre></li>
      <li><pre>password: {{ .Data.password }}</pre></li>
      </ul>
      {{ end }}
      </body>
      </html>
      EOH
    }
  vault-agent-config.hcl: |
    exit_after_auth = true
    pid_file = "/home/vault/pidfile"

    auto_auth {
        method "kubernetes" {
            mount_path = "auth/kubernetes"
            config = {
                role = "otus"
            }
        }

        sink "file" {
            config = {
                path = "/home/vault/.vault-token"
            }
        }
    }
