Giter VIP home page Giter VIP logo

vault-helpers's Introduction

Vault Helpers

Project status: in development

The configuration of vault with kubernetes have been completed. The project still needs to include the initial bootstrap of Vault.

Overview

A collection of scripts to configure Hashicorp Vault.

Configuration Scripts

  • vault-general
    • Adds policies
  • vault-auth-kubernetes
    • Enables Kubernetes authentication method
    • Configures new Kubernetes clusters
    • Adds new roles for new namespaces/service accounts
  • vault-secrets-database
    • Enables the database secrets engine
    • Configures new database connection
    • Adds new roles for dynamic secrets
    • Rotates root password
  • kubernetes
    • Use context (assumes context exists)
    • Setup resources for vault
      • Adds token reviewer service account
      • Grants service account the token reviewer permission
      • Adds a configmap with Vault's address
      • Adds Vault's ca.pem file into a secret
    • Get the token reviewers JWT
    • Get the kubernetes api host
    • Get the kubernetes ca certificate in base64
    • Port forward a pod to localhost
    • Create a namespace with a vault service account

Getting Started

Prerequisites

  • $VAULT_TOKEN with root permissions
  • $VAULT_CACERT is a self-signed cert that exists on disk

Assumptions

Scripts are generic, but the Makefile has assumptions. These will be configurable later.

  • common-stage and kubes-stage-la contexts exists in kube conf
  • Vault exists on the common-stage context
  • Vault is ran on port 8200
  • Apps cluster will be on the kubes-stage-la context
  • Apps cluster can access Vault via https://vault.domain.tld:8200
  • Apps cluster can access database via demo2db.domain.tld:3306
    • username: root
    • password: cloudnext
  • Vault has been initialized and unsealed

Usage

  1. Setup kubernetes, port-forward vault, enable database secrets engine and kubernetes auth method.
    make all
    
  2. Add a new namespace and database. Then plumb everything up.
    make newapp
    

Testing

Create a temporary pod to test the connectivity to vault.

kubectl -n demo run -it --rm --image=alpine --serviceaccount=vault test -- /bin/sh
apk add --update vim curl bash jq mysql-client
bash

Grab the service account token.

JWT="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"

Curl out to vault with the proper JWT to get your temp token to retrieve secrets. Save that.

TOKEN="$(curl --request POST --data '{"jwt": "'"$JWT"'", "role": "demo"}' -s -k https://vault.domain.tld:8200/v1/auth/kubernetes/login | jq -r '.auth.client_token')"

Get your dynamic secret using the temporary token.

curl --header "X-Vault-Token: $TOKEN" -s -k  https://vault.domain.tld:8200/v1/database/creds/demo-role | jq -r .data

Try it out.

mysql -u$USER -p$PASS -h demodb.domain.tld

vault-helpers's People

Contributors

jacklei avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.