Cloud Service Mesh では、PeerAuthentication ポリシーを適用して、mTLS のみを受け入れるようにサービスを構成できます。Cloud Service Mesh には、サービス メッシュ全体、名前空間、個々のワークロードにポリシーを適用できる柔軟性があります。特定のワークロードにポリシーを指定した場合、そのポリシーが優先されます。たとえば、ワークロード固有のポリシーは、名前空間固有のポリシーよりも優先されます。ワークロードにポリシーが指定されていない場合、名前空間またはメッシュからポリシーが継承されます。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["Configure transport security\n\nIn Cloud Service Mesh 1.5 and later, auto\n[mutual TLS](/service-mesh/v1.20/docs/glossary#mutual_tls) (auto mTLS) is enabled by\ndefault. With auto mTLS, a client sidecar proxy automatically detects if the\nserver has a sidecar. The client sidecar sends mTLS to workloads with sidecars\nand sends plaintext to workloads without sidecars. Note, however, services\n*accept* both plaintext and mTLS traffic. As you\n[inject sidecar proxies](/service-mesh/v1.20/docs/anthos-service-mesh-proxy-injection) to\nyour Pods, we recommend that you also configure your services to only accept\nmTLS traffic.\n\nWith Cloud Service Mesh, you can configure your services to only accept mTLS by\napplying a `PeerAuthentication` policy. Cloud Service Mesh gives you the flexibility\nto apply the policy to the entire service mesh, to a namespace, or to an\nindividual workload. When you specify a policy for a specific workload, that\npolicy takes precedence. For example, a workload-specific policy takes\nprecedence over a namespace-specific one. If no policy is specified for the\nworkload, it inherits the policy from the namespace or the mesh.\n\nEnable mutual TLS per namespace\n\nTo enable mTLS for all workloads within a particular namespace, use a\nnamespace-wide authentication policy. You specify the namespace it applies to\nunder `metadata`. \n\n kubectl apply -f - \u003c\u003cEOF\n apiVersion: \"security.istio.io/v1beta1\"\n kind: \"PeerAuthentication\"\n metadata:\n name: \"\u003cvar translate=\"no\"\u003eAUTH_POLICY_NAME\u003c/var\u003e\"\n namespace: \"\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e\"\n spec:\n mtls:\n mode: STRICT\n EOF\n\nExpected output: \n\n```\npeerauthentication.security.istio.io/AUTH_POLICY_NAME created\n```\n\n\u003cbr /\u003e\n\nEnable mutual TLS per workload\n\nTo set a `PeerAuthentication` policy for a specific workload, you must configure\nthe `selector` section and specify the labels that match the desired workload.\nHowever, Cloud Service Mesh can't aggregate workload-level policies for outbound\nmTLS traffic to a service. You need to configure a destination rule to manage\nthat behavior.\n\n1. Apply an authentication policy to a specific workload in your namespace:\n\n cat \u003c\u003cEOF | kubectl apply -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e -f -\n apiVersion: \"security.istio.io/v1beta1\"\n kind: \"PeerAuthentication\"\n metadata:\n name: \"\u003cvar translate=\"no\"\u003eAUTH_POLICY_NAME\u003c/var\u003e\"\n namespace: \"\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e\"\n spec:\n selector:\n matchLabels:\n app: \u003cvar translate=\"no\"\u003eWORKLOAD\u003c/var\u003e\n mtls:\n mode: STRICT\n EOF\n\n Expected output: \n\n ```\n peerauthentication.security.istio.io/AUTH_POLICY_NAME created\n ```\n2. Configure a matching destination rule:\n\n cat \u003c\u003cEOF | kubectl apply -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e -f -\n apiVersion: \"networking.istio.io/v1alpha3\"\n kind: \"DestinationRule\"\n metadata:\n name: \"\u003cvar translate=\"no\"\u003eDEST_RULE_NAME\u003c/var\u003e\"\n spec:\n host: \"\u003cvar translate=\"no\"\u003eWORKLOAD\u003c/var\u003e.\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e.svc.cluster.local\"\n trafficPolicy:\n tls:\n mode: ISTIO_MUTUAL\n EOF\n\n Expected output: \n\n ```\n destinationrule.networking.istio.io/WORKLOAD created\n ```\n\nEnforce mesh-wide mTLS\n\nTo prevent all your services in the mesh from accepting plain-text traffic, set\na mesh-wide `PeerAuthentication` policy with the mTLS mode set to `STRICT` (the\ndefault is `PERMISSIVE`). The mesh-wide `PeerAuthentication` policy shouldn't\nhave a selector and must be applied in the root namespace, `istio-system`. When\nyou deploy the policy, the control plane automatically provisions TLS\ncertificates so that workloads can authenticate with each other.\n\nTo enforce mesh-wide mTLS: \n\n kubectl apply -f - \u003c\u003cEOF\n apiVersion: \"security.istio.io/v1beta1\"\n kind: \"PeerAuthentication\"\n metadata:\n name: \"\u003cvar translate=\"no\"\u003eAUTH_POLICY_NAME\u003c/var\u003e\"\n namespace: \"istio-system\"\n spec:\n mtls:\n mode: STRICT\n EOF\n\nExpected output: \n\n```\npeerauthentication.security.istio.io/AUTH_POLICY_NAME created\n```\n\n\u003cbr /\u003e\n\nFind and delete `PeerAuthentication` policies\n\nFor a list of all the `PeerAuthentication` policies in the service mesh: \n\n kubectl get peerauthentication --all-namespaces\n\nIf there is a `PeerAuthentication` policy in force, you can delete it with\n`kubectl delete`: \n\n kubectl delete peerauthentication -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \u003cvar translate=\"no\"\u003eAUTH_POLICY_NAME\u003c/var\u003e\n\nWhat's next\n\n- [Cloud Service Mesh by example: mTLS](/service-mesh/v1.20/docs/by-example/mtls)\n- [Learn about security in Cloud Service Mesh](/service-mesh/v1.20/docs/security/security-overview)"]]