24

HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Copyright © 2019 HashiCorp

HashiCorp Vault & Kubernetes

Page 2: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

© 2018 HashiCorp

NetworkingConnect infrastructure and applications

DevelopmentRun applications

SecuritySecure applications and infrastructure

OperationsProvision Infrastructure

The 4 essential elements of dynamic infrastructure

2THE HASHICORP STACK

Page 3: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

一般的なシークレット管理

3

Page 4: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

クライアント

● アプリ● CI● ユーザ● etc,

バックエンド

● GCP● DB● PKI● etc,

認証

トークン(権限)

シークレット要求シークレット発行

ttl=1 hour

シークレット破棄

Page 5: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

クライアント

● アプリ● CI● ユーザ● etc,

バックエンド

● GCP● DB● PKI● etc,

認証

トークン(権限)

シークレット要求シークレット発行

ttl=1 hour

シークレット破棄

🤔

Page 6: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求
Page 7: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

kubernetes.io/serviceaccount/tokenを使ってVaultの認証をしシークレットを取得する

Page 8: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

Page 9: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

● TokenReview APIをコールするための権限

Page 10: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

● TokenReview APIをコールするための権限

● Service Account Tokenが有効かを判断● Vault K8s Authメソッドで利用される

Page 11: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Vault

K8s Auth

$ vault write auth/kubernetes/config \ token_reviewer_jwt="$SA_JWT_TOKEN" \ kubernetes_host="https://$K8S_HOST:443" \ kubernetes_ca_cert="$SA_CA_CRT"

Page 12: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

Pod

--serviceaccount=postgres-vault

ServiceAccountToken

Page 13: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Vault

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

Pod

ServiceAccountToken K8s Auth

--serviceaccount=postgres-vault

verify

Page 14: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

Pod

--serviceaccount=postgres-vault

VAULT_TOKEN

Vault

K8s Auth

Role

ServiceAccountToken

Page 15: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

Pod

--serviceaccount=postgres-vault

Vault

K8s Auth

Role

path "database/creds/postgres-role" { capabilities = ["read"]}path "sys/leases/renew" { capabilities = ["create"]}path "sys/leases/revoke" { capabilities = ["update"]}

VAULT_TOKEN

ServiceAccountToken

Page 16: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Pod

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

--serviceaccount=postgres-vault

Vault

K8s Auth

Role

Postgres Secret Engine

VAULT_TOKEN

ServiceAccountToken

Page 17: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Pod

ClusterRoleBinding ClusterRolesystem: auth-delegatorServiceAccount

--serviceaccount=postgres-vault

Vault

K8s Auth

Role

Postgres Secret Engine

シークレット生成 /破棄/ローテーションシークレット提供

VAULT_TOKEN

ServiceAccountToken

Page 18: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Pod

App

Vault Sidecar

Local Filesystem

Vault

認証、シークレットライフサイクル

Page 19: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Pod

Pod

Pod

Pod

Pod

Vault

K8s Auth

Role

Postgres Secret Engine

secret-a

secret-b

secret-c

secret-d

secret-e

シークレット生成、破棄、リニューアル

Page 20: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Let’s Start Vault on GKE

$ git clone https://github.com/hashicorp/vault-helm.git

$ helm install --name=vault .

Page 21: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

Connect K8s by Consul

Provision K8s by Terraform

Secure K8s by Vault

HashiStack 🤝Kubernetes

🤝

🤝

🤝

Page 23: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求

@hashicorpjp

Page 24: HashiCorp Vault & Kubernetes - Google Cloud Platform...クライアント アプリ CI ユーザ etc, バックエンド GCP DB PKI etc, 認証 トークン(権限) シークレット要求