Giter Site home page Giter Site logo

kubernetes-vault's Introduction

kubernetes-vault

Kubernetes manifests to setup Hashicorp vault server

Full Documentation: https://devopscube.com/vault-in-kubernetes/

#Sample API request to the vault using service account tokens to acquire a token with reading capabilities for path "demo-app"

curl --request POST --data '{"jwt": "<< service account token of the pod >>", "role": "webapp"}' http://192.168.49.2:30493/v1/auth/kubernetes/login

#Sample API request to the vault to fetch secrets at "demo-app"

curl -H "X-Vault-Token: <client_token>" -H "X-Vault-Namespace: vault" -X GET http://192.168.49.2:30493/v1/demo-app/data/user01?version=1

Vault Usage

Initialize the vault.


VAULT_UNSEAL_KEY=$(cat keys.json | jq -r ".unseal_keys_b64[]")
echo $VAULT_UNSEAL_KEY

VAULT_ROOT_KEY=$(cat keys.json | jq -r ".root_token")
echo $VAULT_ROOT_KEY

Unseal the vault

kubectl exec vault-0 -- vault operator unseal $VAULT_UNSEAL_KEY

Login into the vault

kubectl exec vault-0 -- vault login $VAULT_ROOT_KEY

Create secrets

vault secrets enable -version=2 -path="demo-app" kv

Create key-value pairs

vault kv get demo-app/user01 

###Create policies

path "demo-app/*" {
  capabilities = ["read"]
}
EOH

vault policy list

#Enable Kubernetes authentication methods


vault write auth/kubernetes/config token_reviewer_jwt="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" kubernetes_host="https://$KUBERNETES_PORT_443_TCP_ADDR:443" kubernetes_ca_cert=@/var/run/secrets/kubernetes.io/serviceaccount/ca.crt

vault write auth/kubernetes/role/webapp \
        bound_service_account_names=vault \
        bound_service_account_namespaces=default \
        policies=demo-policy \
        ttl=72h
        ```

kubernetes-vault's People

Contributors

bibinwilson avatar shishirkh avatar scriptcamp avatar happinesslijian 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.