Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Secrets Management in Kubernetes Umgebungen mit HashiCorp Vault

Kapil Arora
December 03, 2020

Secrets Management in Kubernetes Umgebungen mit HashiCorp Vault

Secrets Management in Kubernetes Umgebungen mit HashiCorp Vault
HashiTalks DACH 2020
Demo : https://github.com/kaparora/hashitalks-demo-nov-2020

Kapil Arora

December 03, 2020
Tweet

Other Decks in Technology

Transcript

  1. © 2020 HashiCorp Kapil Arora Senior Solutions Engineer HashiCorp DACH

    https://www.kaparora.com 1 Secrets Management in Kubernetes Umgebungen mit HashiCorp Vault HashiTalks DACH Dezember 3, 2020
  2. © 2020 HashiCorp Agenda Best Practices Vault and Kubernetes Installation

    with Helm Vault Overview 2 Agent Injection Demo
  3. 1. Helm Chart 2. Kubernetes Auth method 3. Agent sidecar

    injector 4. Vault Secrets with CSI Vault & Kubernetes https://learn.hashicorp.com/collections/vault/kubernetes
  4. 1. Ease of deployment – A single CLI command to

    create multiple resources 2. Templating – Provide defaults with overrides 3. Versioning – Provide backward. Forward support and repeatability Helm Chart
  5. ▪ GitHub – https://github.com/hashicorp/vault-helm ▪ Documentation – https://www.vaultproject.io/docs/platform/k8s/helm ▪ HashiCorp

    Helm Repo – https://helm.releases.hashicorp.com ▪ Modes – Dev (server.dev.enabled) – Standalone – HA (server.ha.enabled) – External (injector.externalVaultAddr) Helm Chart
  6. Helm Install > helm repo add hashicorp https://helm.releases.hashicorp.com “Hashicorp” has

    been added to your repositories > helm search repo hashicorp/consul ... hashicorp/vault … > helm install vault hashicorp/vault NAME: vault ... TERMINAL
  7. Define a Service Account TERMINAL > kubectl apply - <<EOF

    apiVersion: v1 kind: ServiceAccount metadata: name: k8s-service-acct EOF
  8. CODE EDITOR spec: template: metadata: annotations: vault.hashicorp.com/agent-inject: "true" vault.hashicorp.com/role: "internal-app"

    vault.hashicorp.com/agent-inject-secret-database-config.txt: "internal/data/database/config"
  9. Vault Agent Template Released in Vault version 1.4 Provides a

    way to render the secrets managed by Vault Agent in a format useable by the application. Removes requirement for data manipulation with external tools or modification to application code.
  10. CODE EDITOR spec: template: metadata: annotations: vault.hashicorp.com/agent-inject: "true" vault.hashicorp.com/agent-inject-status: "update"

    vault.hashicorp.com/role: "internal-app" vault.hashicorp.com/agent-inject-secret-database-config.txt: "internal/data/database/config" vault.hashicorp.com/agent-inject-template-database-config.txt: | {{- with secret "internal/data/database/config" -}} postgresql://{{ .Data.data.username }}:{{ .Data.data.password }}@postgres:5432/wizard {{- end -}}
  11. ▪ Security Considerations – https://learn.hashicorp.com/tutorials/vault/kubern etes-security-concerns ▪ Reference Architecture –

    https://learn.hashicorp.com/tutorials/vault/kubern etes-reference-architecture Best Practices Resources
  12. Container Storage Interface The Container Storage Interface (CSI) is a

    standard for exposing arbitrary block and file storage systems to containerized workloads on Container Orchestration Systems (COs) like Kubernetes. Using CSI third-party storage providers can write and deploy plugins exposing new storage systems in Kubernetes without ever having to touch the core Kubernetes code.
  13. Container Storage Interface Secrets Store CSI driver for Kubernetes secrets

    - Integrates secrets stores with Kubernetes via a Container Storage Interface (CSI) volume. The Secrets Store CSI driver secrets-store.csi.k8s.io allows Kubernetes to mount multiple secrets, keys, and certs stored in enterprise-grade external secrets stores into their pods as a volume. Once the Volume is attached, the data in it is mounted into the container's file system.
  14. 1. Install the secrets store CSI driver 2. Install the

    provider-vault executable 3. Define a SecretProviderClass Kubernetes resource 4. Define a pod with volume Secret Store CSI Config Steps
  15. Secret injection with Vault Agent Injector https://learn.hashicorp.com/vault/kubernetes/sidecar Secrets with Container

    Storage Interface https://learn.hashicorp.com/vault/kubernetes/secret-store-driver External Vault https://learn.hashicorp.com/vault/kubernetes/external-vault Resources
  16. Summary Vault integrates tightly with K8S Vault offers centralized secret

    management and identity brokering and also encryption as a services for K8S applications. Vault also offers a helm chart and agent injection functionality. Vault secrets can also be mounted using CSI integration