[[["わかりやすい","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,["# Set up Service Security on Proxyless gRPC service mesh on GKE\n=============================================================\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to set up security features on a proxyless gRPC service mesh on\nGKE.\n\nPrerequisites\n-------------\n\nAs a starting point, this guide assumes that you have already:\n\n- [Created a GKE cluster and registered it to a fleet](/service-mesh/docs/gateway/prepare-gateway#create_and_register_a_cluster).\n- [Setup xDS enabled gRPC client and Service](/service-mesh/docs/gateway/proxyless-grpc-mesh).\n\nSetup authorization policies on proxyless gRPC service.\n-------------------------------------------------------\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis section shows you how to set up different kinds of\n[authorization policies](/load-balancing/docs/auth-policy/auth-policy-overview)\non Cloud Service Mesh proxyless gRPC services on GKE.\n\nBefore you can create an authorization policy, you must install the\nGCPAuthzPolicy CustomResourceDefinition (CRD): \n\n curl https://github.com/GoogleCloudPlatform/gke-networking-recipes/blob/main/gateway-api/config/mesh/crd/experimental/gcpauthzpolicy.yaml \\\n | kubectl apply -f -\n\nAuthorization Policies can enforce access control on traffic entering proxyless gRPC services. Policies can be applied on Kubernetes deployments. Deployment should be in the same namespace as Authorization Policy.\n\n### Authorization policy to deny all the requests\n\nWhen you have a workload that is supposed to make only outbound calls, like a\ncron job, you can configure an authorization policy to deny any incoming HTTP\nrequests to the workload. The following example denies incoming HTTP requests to\nthe gRPC service `psm-grpc-server`.\n\nPerform the following steps to create and apply the deny authorization policy:\n\n1. Create a deny policy by creating a file called `deny-all-authz-policy.yaml`:\n\n cat \u003edeny-all-authz-policy.yaml \u003c\u003cEOF\n apiVersion: networking.gke.io/v1\n kind: GCPAuthzPolicy\n metadata:\n name: myworkload-authz\n namespace: default\n spec:\n targetRefs:\n - kind: Deployment\n name: psm-grpc-server\n httpRules:\n - to:\n operations:\n - paths:\n - type: Prefix\n value: \"/\"\n action: DENY\n EOF\n\n2. Apply the policy:\n\n kubectl apply -f deny-all-authz-policy.yaml\n\n### Authorization policy to allow requests\n\nYou can also configure an allow policy that allows only requests that match a\nspecific criteria while rejecting the rest. The following example configures an\nauthorization policy on the `psm-grpc-server`where only `POST` requests that have http header `x-user-role:admin` present in the request will be allowed.\n\nPerform the following steps to create and apply the allow authorization policy, delete the previously created deny policy before adding this policy to see the results:\n\n1. Create a custom policy by creating a file called `allow-authz-policy.yaml`:\n\n cat \u003eallow-authz-policy.yaml \u003c\u003cEOF\n apiVersion: networking.gke.io/v1\n kind: GCPAuthzPolicy\n metadata:\n name: myworkload-authz\n namespace: default\n spec:\n targetRefs:\n - kind: Deployment\n name: psm-grpc-server\n httpRules:\n - to:\n operations:\n - methods: [\"POST\"]\n when: \"request.headers['x-user-role'] == 'admin'\n action: ALLOW\n EOF\n\n2. Apply the policy:\n\n kubectl apply -f allow-authz-policy.yaml\n\n### Authorization policy to deny requests based on rules\n\nThe following example denies incoming HTTP `POST` requests to\nthe workload `psm-grpc-server` when it is on the path `/admin` .\n\nPerform the following steps to create and apply the deny authorization policy:\n\n1. Create a deny policy by creating a file called `deny-path-authz-policy.yaml`:\n\n cat \u003edeny-path-authz-policy.yaml \u003c\u003cEOF\n apiVersion: networking.gke.io/v1\n kind: GCPAuthzPolicy\n metadata:\n name: myworkload-authz\n namespace: default\n spec:\n targetRefs:\n - kind: Deployment\n name: psm-grpc-server\n httpRules:\n - to:\n operations:\n - paths:\n - type: Prefix\n value: \"/admin\"\n methods: [\"GET\"]\n action: DENY\n EOF\n\n2. Apply the policy:\n\n kubectl apply -f deny-path-authz-policy.yaml"]]