I successfully deployed k8s pod with service of type NodePort in microk8s cluster. Now when I enable ufw and try to deny incoming traffic to the exposed port 31001 using command ```ufw deny 31001``` , ufw still allows traffic to port 31001.

What should I do in ufw to allow and deny traffic to port 31001 ?

Please help.

1 Answer 1


I believe you're "fighting" against the internal Docker network used for the microk8s instancees. I've come across different options, from setting up after rules for ufw to disabling the docker ip tables configuration. The nicest setup in my opinion seems to be this: https://github.com/chaifeng/ufw-docker#how-to-do

Edit: it can also be inherent to NodePort, see per comment on SO: https://stackoverflow.com/questions/62772319/ufw-not-blocking-traffic-to-microk8s-cluster#comment112367622_62772319

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.