PeerAuthentication

PeerAuthentication

PeerAuthentication defines how traffic will be tunneled (or not) to the sidecar.

Examples:

Policy to allow mTLS traffic for all workloads under namespace foo:

  1. apiVersion: security.istio.io/v1beta1
  2. kind: PeerAuthentication
  3. metadata:
  4. name: default
  5. namespace: foo
  6. spec:
  7. mtls:
  8. mode: STRICT

For mesh level, put the policy in root-namespace according to your Istio installation.

Policies to allow both mTLS & plaintext traffic for all workloads under namespace foo, butrequire mTLS for workload finance.

  1. apiVersion: security.istio.io/v1beta1
  2. kind: PeerAuthentication
  3. metadata:
  4. name: default
  5. namespace: foo
  6. spec:
  7. mtls:
  8. mode: PERMISSIVE
  9. ---
  10. apiVersion: security.istio.io/v1beta1
  11. kind: PeerAuthentication
  12. metadata:
  13. name: default
  14. namespace: foo
  15. spec:
  16. selector:
  17. matchLabels:
  18. app: finance
  19. mtls:
  20. mode: STRICT

Policy to allow mTLS strict for all workloads, but leave port 8080 toplaintext:

  1. apiVersion: security.istio.io/v1beta1
  2. kind: PeerAuthentication
  3. metadata:
  4. name: default
  5. namespace: foo
  6. spec:
  7. selector:
  8. matchLabels:
  9. app: finance
  10. mtls:
  11. mode: STRICT
  12. portLevelMtls:
  13. 8080:
  14. mode: DISABLE

Policy to inherite mTLS mode from namespace (or mesh) settings, and overwritesettings for port 8080

  1. apiVersion: security.istio.io/v1beta1
  2. kind: PeerAuthentication
  3. metadata:
  4. name: default
  5. namespace: foo
  6. spec:
  7. selector:
  8. matchLabels:
  9. app: finance
  10. mtls:
  11. mode: UNSET
  12. portLevelMtls:
  13. 8080:
  14. mode: DISABLE
FieldTypeDescriptionRequired
selectorWorkloadSelector
The selector determines the workloads to apply the ChannelAuthentication on.If not set, the policy will be applied to all workloads in the same namespace as the policy.
No
mtlsMutualTLS
Mutual TLS settings for workload. If not defined, inherit from parent.
No
portLevelMtlsmap<uint32, MutualTLS>
Port specific mutual TLS settings.
No

PeerAuthentication.MutualTLS

Mutual TLS settings.

FieldTypeDescriptionRequired
modeMode
Defines the mTLS mode used for peer authentication.
No

PeerAuthentication.MutualTLS.Mode

NameDescription
UNSET
Inherit from parent, if has one. Otherwise treated as PERMISSIVE.
DISABLE
Connection is not tunneled.
PERMISSIVE
Connection can be either plaintext or mTLS tunnel.
STRICT
Connection is an mTLS tunnel (TLS with client cert must be presented).