How to enable egress network policy for Windows Server 2022 pods?
Nikita Krivets
491
Reputation points
Hi,
Could you please help me out with the network policy configuration for Windows Server 2022 pods in AKS?
I followed the guide and all the steps listed here to no avail. https://zcusa.951200.xyz/en-us/azure/aks/use-network-policies#create-an-aks-cluster-with-azure-network-policy-manager-enabled---windows-server-2022-preview
The network policy that I used:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: restrict-instance-metadata
namespace: default
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0 #Allow all other traffic
except:
- 169.254.169.254/32 #Block metadata API
It works great on Linux pods but I struggle to make it work on Windows.
No matter what I tried so far I still can run
kubectl exec -it <windows-server-2022-pod> -n default -- powershell
and then get a successful response with all the data from this one
Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | ConvertTo-Json -Depth 64
What could be the issue here?
Sign in to answer