Custom kubernetes ingress authentication using Hashicorp Vault

This article explains how to implement an ngnix ingress authentication (basic http auth) mechanism for securing your kubernetes (k8s) application endpoints using the credentials stored in hashicorp vault. This can be achieved easily by writing a simple http auth (python-flask) app that talks with the vault. The workflow for custom authentication is explained well in this article.

The basic idea to is modify the opensource httpbin app by adding a new endpoint such as vault-auth. The code this endpoint is going to basic-auth except the http auth credentials will be validate against hashicorp vault instead of the passed parameters. The modified code can then be deployed as a container and as an auth service in your kubernetes cluster.

All the applications whose ingress endpoints need to be secured have to add the following line to their ingress deployment yaml

nginx.ingress.kubernetes.io/auth-url: http://auth.default.svc.cluster.local/vault-auth/x/y

Where auth.default.svc.cluster.local is the service that is running the modified httpbin app

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s