Setup basic auth
Apply annotations to ingress configuration:
Add this to the ingress manifest and apply changes.
metadata:
annotations:
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required'
Create secret
-
Create a htpasswd file with the desired username. It will prompt for a password twice.
-
Create a secret from the generated file
Make sure you create this secret in the same namespace as the ingress that needs basic auth. -
Verify the created secret. If the namespace is not in your context you will need to add -n [namespace]
-
Test the basic auth.
-
Should return 401.
-
Should return the headers of the application you're running.
-