Skip to content

Network Policies ​

Learn about the network policies for the Istio module, enable the network policy support, and allow egress traffic to your workloads.

Overview ​

To enable secure-by-default practices, the Istio module allows creation of network policies in the istio-system and kyma-system namespaces. These policies restrict traffic to and from Istio components, ensuring that only necessary baseline communication is allowed. The policies make sure that in case a deny-by-default policy is applied at the cluster or namespace level, the Istio module's components can still function properly.

Enable Network Policy Support ​

To enable support for network policies, set the flag networkPoliciesEnabled: true in the Istio custom resource. This setting is disabled by default.

yaml
apiVersion: operator.kyma-project.io/v1alpha2
kind: Istio
metadata:
  name: default
  namespace: kyma-system
spec:
  networkPoliciesEnabled: true

When the flag changes, Istio components are restarted, terminating existing TCP connections and enforcing the policies immediately.

Network Policies Applied by the Istio Module ​

When enabled, the module applies network policies in the istio-system and kyma-system namespaces. All module-managed policies are labeled with:

  • kyma-project.io/module: istio
  • kyma-project.io/managed-by: kyma

Do not modify these resources, as they are automatically updated by the module. Any manual changes are overwritten.

This table lists the network policies applied when support is enabled and the traffic they allow:

ComponentNamespacePortProtocolDirectionSource/DestinationPurpose
istio-controller-managerkyma-system53UDP/TCPEgressdestination: *DNS resolution
istio-controller-managerkyma-system443TCPEgressdestination: *Kubernetes API server access
istiodistio-system53UDP/TCPEgressdestination: *DNS resolution
istiodistio-system80TCPEgressdestination: *Access to external JWKS endpoints for JWT validation (HTTP)
istiodistio-system443TCPEgressdestination: *Access to external JWKS endpoints for JWT validation (HTTPS) / Kubernetes API server access
istiodistio-system15012TCP/gRPCIngresssource (any of): - podSelector security.istio.io/tlsMode: istio (any namespace) - podSelector istio: ingressgatewayXDS config distribution to sidecars and gateways
istiodistio-system15014TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Control plane metrics (Prometheus scrape)
istiodistio-system15017TCP/HTTPSIngresssource: *Webhook endpoint (defaulting/mutation/admission). It is genarally only accessed by the Kubernetes API server.
istio-egressgatewayistio-system*UDP/TCPEgressAll outbound traffic from egress is allowed, as the configuration is done via Istio resources
istio-egressgatewayistio-system*UDP/TCPIngresssource: podSelector networking.kyma-project.io/to-egressgateway: allowed (any namespace)Traffic from labeled user Pods (networking.kyma-project.io/to-egressgateway: allowed)
istio-egressgatewayistio-system15020TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Merged Prometheus metrics
istio-egressgatewayistio-system15021TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Health check endpoint
istio-egressgatewayistio-system15090TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Envoy Prometheus telemetry
istio-ingressgatewayistio-system*TCPEgressTraffic to labeled user Pods (networking.kyma-project.io/from-ingressgateway: allowed)
istio-ingressgatewayistio-system*TCPEgressdestination: podselector networking.kyma-project.io/from-ingressgateway: allowed (any namespace)Traffic to labeled user Pods (networking.kyma-project.io/from-ingressgateway: allowed)
istio-ingressgatewayistio-system53UDP/TCPEgressdestination: *DNS resolution
istio-ingressgatewayistio-system8080TCPIngresssource: *HTTP traffic inbound to cluster
istio-ingressgatewayistio-system8443TCPIngresssource: *HTTPS traffic inbound to cluster
istio-ingressgatewayistio-system15012TCP/gRPCEgressdestination: podSelector istio: pilotRequest XDS config from istiod
istio-ingressgatewayistio-system15020TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Merged Prometheus metrics
istio-ingressgatewayistio-system15021TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Health check endpoint
istio-ingressgatewayistio-system15090TCP/HTTPIngresssource (any of): - has label kyma-project.io/module (any namespace) - podSelector networking.kyma-project.io/istio-metrics: allowed (any namespace) - podSelector networking.kyma-project.io/metrics-scraping: allowed (any namespace)Envoy Prometheus telemetry
istio-cni-nodeistio-system53UDP/TCPEgressdestination: *DNS resolution
istio-cni-nodeistio-system443TCPEgressdestination: *Kubernetes API server access

Networking Diagram ​

The following diagram illustrates the allowed traffic flows between Istio components and user workloads when network policy support is enabled.

In the diagram, network policies are illustrated as the resources through which allowed traffic flows. In reality, a network policy is a custom resource that configures which traffic is allowed or denied, while the actual filtering is performed by the Istio module's components.

Istio Module NetworkPolicies

Enable Egress from istio-ingressgateway to Your Workloads ​

Because the egress traffic from istio-ingressgateway to user workloads is restricted by default, you must take additional steps to allow traffic to your applications.

To allow egress traffic from istio-ingressgateway to your workloads, add this label to the Pods that should be reachable from istio-ingressgateway:

  • networking.kyma-project.io/from-ingressgateway: allowed

See the following example workload template snippet:

yaml
spec:
  template:
    metadata:
      labels:
        networking.kyma-project.io/from-ingressgateway: allowed

Enable egress traffic from your workloads to istio-egressgateway ​

In case you have egressgateway enabled and want to allow traffic from your workloads to egressgateway, add this label to the Pods:

  • networking.kyma-project.io/to-egressgateway: allowed.

See the following example workload template snippet:

yaml
spec:
  template:
    metadata:
      labels:
        networking.kyma-project.io/to-egressgateway: allowed

Enable access to metrics and health check endpoints ​

To allow access to the metrics and health check endpoints of istio-ingressgateway and istio-egressgateway, add either of these labels to the Pods that should be able to access those endpoints:

  • networking.kyma-project.io/istio-metrics: allowed
  • networking.kyma-project.io/metrics-scraping: allowed

See the following example workload template snippet:

yaml
spec:
  template:
    metadata:
      labels:
        networking.kyma-project.io/istio-metrics: allowed
        networking.kyma-project.io/metrics-scraping: allowed

[Optional] Apply a Deny-By-Default Policy ​

To isolate a workload's namespace with a deny-by-default policy, make sure to allow ingress from istio-ingressgateway in that policy. See an example NetworkPolicy resource allowing ingress from istio-ingressgateway to the workload:

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
    name: allow-ingress-from-istio-ingressgateway
    namespace: my-namespace
spec:
    podSelector:
      matchLabels:
        app: my-app
    policyTypes:
    - Ingress
    ingress:
    - from:
      - namespaceSelector:
          matchLabels:
            kubernetes.io/metadata.name: istio-system
        podSelector:
          matchLabels:
            istio: ingressgateway
      ports:
        - protocol: TCP
          port: 8080 # The targetPort of the application container

In case you are also using egressgateway (for details, see Sending Requests Using Istio Egress Gateway) and want to allow traffic from your workloads to egressgateway, add this label to the Pods: networking.kyma-project.io/to-egressgateway: allowed.