Giter Site home page Giter Site logo

vault_eks_jwt's Introduction

You will find information here to connect a Kubernetes cluster to a Vault cluster. Any time you will create a service account you will need to get secrets from Vault. This tutorial shows how to link a Kubernetes cluster to Vault using the JWT auth method. In my example, I created an EKS cluster managed by AWS.

Step 1. Enable the JWT/OIDC auth method in HCP Vault using your terminal

vault auth enable jwt

Step 2. Define the jwt config. When using the jwt auth method, you only need the oidc discovery url and sometimes a TLS certificate authority to trust

vault write auth/jwt/config
    oidc_discovery_url="https://oidc.eks.us-east-2.amazonaws.com/id/70E6A5C14C513E0BABEE36DD5AF0AA34" \
    default_role="eks"

Step 3. Define the role for a specific service account or many services account. You can create a role per service account if they don't have the same TTL or the policies.

vault write auth/jwt/role/eks @roleseks.json 

The production policy allows to write the production database credentials.

In order to reduce the Vault client, you need to take the 'iss' parameter as the user_claim. The user_claim is tied to the identity of the cluster instead of the subject. The documentation shows the example of attaching the service account to the Vault cluster. The subject (sub) refers to the service account.

You can check the token claims in the jwt.io website to make sure you put the valid claims. Keep in mind that using this approach, you will see the cluster's identity as the Vault client. If you do audit on the logs for whatever the reason is, you will not able to see the services account entities, therefore you will not see who service account did what.

Step 5. Create the service account's token to connect to the Vault cluster

In this example, I took a payment service account that belongs to a production namespace. The token will be valid for 3 hours and will expire after this period.

kubectl create token payment -n production

Links to the documentation :

https://developer.hashicorp.com/vault/docs/auth/jwt/oidc-providers/kubernetes
https://developer.hashicorp.com/vault/tutorials/cloud-ops/vault-eks-jwt-auth

vault_eks_jwt's People

Contributors

lydiafadel avatar

Watchers

 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.