This post is somewhat related to a previous post about accessing k8s services using nginx reverse proxy. Let’s try to add a simple basic authentication to these services at the proxy level. Now, this may come in handy in non-production environments but at the very least, make sure that you are doing this over HTTPS as basic authentication credentials are not encrypted.
We will be using the htpasswd tool to generate our passwords. In Ubuntu, you can install this using the following command:
Let’s generate our password file:
Let’s add a config map to our previous YAML file and enable basic authentication to svc1 only:
You should now be able to access svc1 using your username:password.
If you have any questions or feedback, please reach out @flowerinthenyt.