AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Restarting Node Resets NSG Inbound Rule to Default

Open ghost opened this issue 8 years ago • 12 comments

I am not sure if this is a bug or intended functionality, but restarting an AKS node reverts all network security group rules associated to that node back to their default, specifically on the rules auto created by AKS when using a load balancer type service.

steps to reproduce:

  1. create service of type loadbalancer, wait for external ip to be created
  2. modify nsg inbound rule for the auto created rule. (change to restrict to IP address 1.1.1.1 for example)
  3. restart server from portal

results in ip restriction being removed.

ghost avatar Jul 30 '18 18:07 ghost

We're having the same issue. This needs to be fixed.

fredshino avatar Aug 02 '18 13:08 fredshino

@fredshino

I have spoken with premier support and was told this is intended functionality. I am actually quite shocked.

The reason is people were getting locked out of their cluster after scaling up and down, so microsoft purposely writes over the security group rules each time. It sounds like the "fix" and i use that term loosely, is to delete your cluster, re-create with advanced networking, dont use k8s load balancer services, buy a third party load balancer and have it forward to the IPs created by AKS (new IP per pode only in vnet), buy a third party firewall and poke a hole through to the load balancer which is IP restricted. When i say third party i mean in azure, but not the azure branded resource. Im still waiting for confirmation from the support engineer that this is indeed the solution.

We actually spun up a GKE cluster and pointed our ci/cd solution at this cluster, deployed everything and are up and running again with IP restrictions. The rules stay in place after restarts and scaling the nodes to 0. Much better.

ghost avatar Aug 02 '18 14:08 ghost

This is a upstream issue with the Azure cloud provider code. Can you file an issue there?

JackQuincy avatar Aug 07 '18 19:08 JackQuincy

@JackQuincy this is surprising to me. As I stated premier support is telling customers that this is scenario was specifically implemented by AKS (always overwriting the network security group). So are you confirming now that this is in fact a bug? And not an issue with AKS directly? Could you provide any further details?

ghost avatar Aug 07 '18 19:08 ghost

We work on upstream as well. So it is still an issue the AKS team should get fixed. I'm not an expert on the NSG rules the kubelet sets up though. My understanding is it is by design. The kubelet on start up makes sure all ports etc it needs to support k8s services are open, apparently it considers your changes taints that need to be cleaned up. So under a feature request instead of bug. A work around would be to make a higher priority rule in the nsg that does what you want and it will override the lower priority rule k8s will set up.

feature requests should live here: https://feedback.azure.com/forums/914020-azure-kubernetes-service-aks

JackQuincy avatar Aug 07 '18 20:08 JackQuincy

https://feedback.azure.com/forums/914020-azure-kubernetes-service-aks/suggestions/35067874-restarting-nodes-or-scaling-shouldn-t-reset-networ

ghost avatar Aug 09 '18 11:08 ghost

looks like k8s already supports this, https://github.com/kubernetes/kubernetes/blob/b6f75ac30e863531ac73cfd02a0edd57983cc5c0/pkg/apis/core/annotation_key_constants.go#L84 you just need to add an annotation to your service when you expose it

JackQuincy avatar Aug 15 '18 18:08 JackQuincy

// Not all cloud providers support this annotation, though AWS & GCE do.

Gotta love Azure.

fredshino avatar Aug 15 '18 19:08 fredshino

@fredshino Premier support came back to me after sort of slow playing the response. I believe they just started supporting this when they released 1.11. Tested with 1.10.6 and it worked, however we will be moving to GKE still.

ghost avatar Aug 15 '18 19:08 ghost

The comment is outdated. It is supported by the azure cloud provider. I went from the azure cloud provider to find the annotation.

JackQuincy avatar Aug 15 '18 19:08 JackQuincy

@JackQuincy I still think that changes directly to the network security group should persist after a restart or scale operation.

ghost avatar Aug 15 '18 19:08 ghost

Something I check every 3 days in one of our production environment. I also think that changes made directly to the nsg should persist even after restarts.

sithumc avatar Sep 09 '19 09:09 sithumc