K8s – Add allowlist to existing Ingress

Kubernetes Ingress

Once you have a working ingress in place, you may want to restrict access to it by IP.  Fortunately, K8s makes this pretty easy with a simple annotation.

  1. Edit the ingress
  2. Near the top should be the annotations metadata.annotations
  3. Add the following annotation and update it with the desired IPs
    nginx.ingress.kubernetes.io/whitelist-source-range: ###.###.###.###/32,###.###.###.###/32
  4. Save your changes
  5. Test.

Leave a Reply

Your email address will not be published. Required fields are marked *