I've a Kubernetes cluster with IPs: 10.10.10.1 (Master) 10.10.10.2 (Slave)
and I've a remote server with nginx with IP 12.12.12.12.
Right now I've configured a nodePort (31000) to allow access on a resource from my cluster.
So if I try to download the content from: 10.10.10.1:31000, I manage to download the file.
So what I want to do is to allow this download only from IP 12.12.12.12 (my nginx server).
I think that a NetworkPolicy cannot do the job because it's an external server (outside the cluster):
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-specific-ip-nodeport spec: podSelector: {} policyTypes: - Ingress ingress: - from: - ipBlock: cidr: 12.12.12.12/32 ports: - protocol: TCP port: 31000 So I tried with iPtables on master and slave, but the traffic continue to be allowed from everywhere:
sudo iptables -A INPUT -p tcp --dport 31000 -s 12.12.12.12 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 31000 -j DROP Any idea?
My goal is to block traffic from everywhere on port 31000 except from my nginx server outside the cluster.