Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigation/design for network traffic restrictions in ambient mode #1028

Open
Tracked by #681
mjnagel opened this issue Nov 20, 2024 · 2 comments
Open
Tracked by #681

Investigation/design for network traffic restrictions in ambient mode #1028

mjnagel opened this issue Nov 20, 2024 · 2 comments
Assignees
Labels
design-doc issue is for or requires a design doc istio Issues related to istio components / resources

Comments

@mjnagel
Copy link
Contributor

mjnagel commented Nov 20, 2024

Related to #681

During initial investigations of istio ambient we discovered that traffic appears to primarily/exclusively flow through the ztunnel port. This seems to make some of our network policies not have an effect. We should ensure that we are able to provide the same restrictions around ingress/egress and make a design for how to do this with ambient.

Definition of done should be a design doc/proposal that ensures traffic lock down, considering these items in particular:

  • Support for hybrid mesh (sidecar and ambient)
  • Usage of Istio AuthorizationPolicies?
  • Easy Migration/Upgrade Process
@mjnagel mjnagel added istio Issues related to istio components / resources design-doc issue is for or requires a design doc labels Jan 16, 2025
@noahpb
Copy link
Contributor

noahpb commented Jan 24, 2025

I found this doc related to the topic:
https://istio.io/latest/docs/ambient/usage/networkpolicy/

Additionally, L4 AuthorizationPolicies do not currently apply to Waypoints.

@sgettys
Copy link
Contributor

sgettys commented Jan 27, 2025

Looks like ambient should work with existing netpols with 2 caveats:

Once you have added applications to the ambient mesh, ambient’s secure L4 overlay will tunnel traffic between your pods over port 15008. Once secured traffic enters the target pod with a destination port of 15008, the traffic will be proxied back to the original destination port.

However, NetworkPolicy is enforced on the host, outside the pod. This means that if you have preexisting NetworkPolicy in place that, for example, will deny list inbound traffic to an ambient pod on every port but 443, you will have to add an exception to that NetworkPolicy for port 15008.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
spec:
  ingress:
  - ports:
    - port: 8080
      protocol: TCP
    - port: 15008
      protocol: TCP
  podSelector:
    matchLabels:
      app.kubernetes.io/name: my-app

And

In Istio ambient, this problem is solved by using a combination of iptables rules and source network address translation (SNAT) to rewrite only packets that provably originate from the local node with a fixed link-local IP, so that they can be explicitly ignored by Istio policy enforcement as unsecured health probe traffic. A link-local IP was chosen as the default since they are typically ignored for ingress-egress controls, and by IETF standard are not routable outside of the local subnetwork.

This behavior is transparently enabled when you add pods to the ambient mesh, and by default ambient uses the link-local address 169.254.7.127 to identify and correctly allow kubelet health probe packets.

However if your workload, namespace or cluster has a preexisting ingress or egress NetworkPolicy, depending on the CNI you are using, packets with this link-local address may be blocked by the explicit NetworkPolicy, which will cause your application pod health probes to begin failing when you add your pods to the ambient mesh.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-ingress-allow-kubelet-healthprobes
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: my-app
  ingress:
    - from:
      - ipBlock:
          cidr: 169.254.7.127/32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-doc issue is for or requires a design doc istio Issues related to istio components / resources
Projects
None yet
Development

No branches or pull requests

3 participants