apiVersion: v1
data:
    vault-agent-config.hcl: |
        # Comment this out if running as sidecar instead of initContainer
        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"
                }
            }
        }
    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 = <<EOT
        <html>
        <body>
        <p>Some secrets:</p>
        {{- with secret "otus/otus-ro/config" }}
        <ul>
        <li><pre>username: {{ .Data.data.username }}</pre></li>
        <li><pre>password: {{ .Data.data.password }}</pre></li>
        </ul>
        {{ end }}
        </body>
        </html>
        EOT
        }
kind: ConfigMap
metadata:
    name: example-vault-agent-config
    namespace: default
