Kubernetes version:1.21.4
Cloud being used: (put bare-metal if not on a public cloud) : On-Premise
Installation method: Manual installation
Host OS: Centos8
I have a deployment which exposes an API endpoint via the service (NodePort) resource. If I do a simple curl https://node-ip:30010 , I can see everything and till this point it works fine.
Now, how can I restrict access to this API endpoint using the Kubernetes resources so that only a particular user can query this and not everybody ?
RBAC authorization uses the rbac.authorization.k8s.ioAPI group to drive authorization decisions, allowing you to dynamically configure policies through the Kubernetes API.
Your application exposes the endpoint in https://node-ip:30010, so requests to this endpoint are handled by your application.
in order to enforce access by user I would use an ingress point (for example nginx ingress controller and expose an ingress) and there you can add more control on HTTP requests.
once you use an ingress you can choose which urls are accessible through the ingress (exposed outside instead of using a NodePort) and which wil be accessible only from within the SDN (ClusterIP service).