Zugriff auf VM-Betriebssystem-Images für Batch steuern
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie die Einschränkung für die Richtlinie für vertrauenswürdige Images konfigurieren.
So können Sie den Zugriff auf die Betriebssystem-Images steuern, die zum Erstellen der Bootlaufwerke für Compute Engine-VM-Instanzen verwendet werden können.
Standardmäßig kann ein Nutzer jedes öffentliche Image oder jedes benutzerdefinierte Image verwenden, das für die Compute Engine-VMs, auf denen seine Batch-Jobs ausgeführt werden, für ihn freigegeben ist.
Wenn die Einschränkung für die Trusted Image-Richtlinie nicht aktiviert ist und Sie VM-Betriebssystem-Images nicht einschränken möchten, können Sie das Lesen dieses Dokuments beenden.
Aktivieren Sie die Richtlinieneinschränkung für vertrauenswürdige Images, wenn alle Nutzer in einem Projekt, Ordner oder einer Organisation VMs erstellen müssen, die genehmigte Software enthalten, die Ihren Richtlinien- oder Sicherheitsanforderungen entspricht.
Wenn die Einschränkung für die Trusted Image-Richtlinie aktiviert ist, können betroffene Nutzer keine Batchjobs ausführen, es sei denn, das VM-Betriebssystem-Image für ihren Job ist zulässig.
Wenn die Einschränkung für Trusted Image-Richtlinien aktiviert ist, müssen Sie mindestens eine der folgenden Aktionen ausführen, um Jobs zu erstellen und auszuführen:
In den folgenden Schritten wird beschrieben, wie Sie die Einschränkung für die Richtlinie für vertrauenswürdige Images so ändern, dass alle VM-Betriebssystemimages aus Batch zugelassen werden. Dazu verwenden Sie dieGoogle Cloud Console oder die Google Cloud CLI.
Weitere Informationen zur Verwendung der Richtlinienbeschränkung für vertrauenswürdige Images (compute.trustedImageProjects) finden Sie in der Compute Engine-Dokumentation unter Trusted Image-Richtlinien einrichten.
Klicken Sie in der Richtlinienliste auf Vertrauenswürdige Image-Projekte definieren.
Die Seite Richtliniendetails wird geöffnet.
Klicken Sie auf der Seite Richtliniendetails auf editRichtlinie verwalten. Die Seite Richtlinie bearbeiten wird geöffnet.
Wählen Sie auf der Seite Richtlinie bearbeiten die Option Anpassen aus.
Wählen Sie unter Richtlinienerzwingung eine Erzwingungsoption aus.
Klicken Sie auf Regel hinzufügen.
In der Liste Richtlinienwerte können Sie auswählen, ob Sie eine Regel hinzufügen möchten, die den Zugriff auf alle nicht angegebenen Image-Projekte zulässt, den Zugriff auf alle nicht angegebenen Image-Projekte verweigert oder einen benutzerdefinierten Satz von Projekten angibt, für die der Zugriff zugelassen oder verweigert werden soll. So lassen Sie alle Bilder aus Batch zu:
Wählen Sie in der Liste Richtlinienwerte die Option Benutzerdefiniert aus.
Die Felder Richtlinientyp und Benutzerdefinierte Werte werden angezeigt.
Wählen Sie in der Liste Richtlinientyp die Option Zulassen aus.
Geben Sie im Feld Benutzerdefinierte Werte den Wert projects/batch-custom-image ein.
Klicken Sie auf Fertig, um die Regel zu speichern.
Klicken Sie auf Speichern, um die Organisationsrichtlinie zu speichern und anzuwenden.
gcloud
Im folgenden Beispiel wird beschrieben, wie Sie Bilder aus Batch für ein bestimmtes Projekt zulassen:
Ersetzen Sie PROJECT_ID durch die Projekt-ID des Projekts, das Sie aktualisieren möchten.
Öffnen Sie die Datei policy.yaml in einem Texteditor. Ändern Sie dann die Einschränkung compute.trustedImageProjects, indem Sie projects/batch-custom-image dem Feld allowedValues hinzufügen.
Wenn Sie beispielsweise nur VM-Betriebssystem-Images aus Batch zulassen möchten, legen Sie die Einschränkung compute.trustedImageProjects auf Folgendes fest:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[[["\u003cp\u003eThis document guides users on configuring the trusted image policy constraint to control which operating system images can be used for creating boot disks for Compute Engine VM instances.\u003c/p\u003e\n"],["\u003cp\u003eBy default, users can utilize any public or shared custom image unless the trusted image policy constraint is enabled, which then restricts access to only approved images.\u003c/p\u003e\n"],["\u003cp\u003eEnabling this constraint requires users to either specify an already-approved VM OS image or allow the default VM OS images provided by Batch, in order to run Batch jobs.\u003c/p\u003e\n"],["\u003cp\u003eThe process to allow all VM OS images from Batch involves modifying the trusted image policy constraint through the Google Cloud console or Google Cloud CLI, specifically by adding \u003ccode\u003eprojects/batch-custom-image\u003c/code\u003e to the allowed projects.\u003c/p\u003e\n"],["\u003cp\u003eOnce configured, the document recommends testing the constraints and references a few documents to create and run jobs, or learn more about VM OS images.\u003c/p\u003e\n"]]],[],null,["# Control access to VM OS images for Batch\n\nThis page describes how to configure the trusted image policy constraint.\nThis lets you control access to the operating system (OS) images that can be\nused to create the boot disks for any Compute Engine\nvirtual machine (VM) instances.\n\nBy default, a user can use any public image or any custom image that is\nshared with them for the Compute Engine VMs that run their\nBatch jobs.\nIf the trusted image policy constraint is not enabled and you don't want to\nrestrict VM OS images, you can stop reading this document.\n\nEnable the trusted image policy constraint\nif you want to require all the users in a project, folder, or organization to\ncreate VMs that contain approved software that meets your policy or\nsecurity requirements.\nIf the trusted image policy constraint is enabled, affected users\n[can't run Batch jobs](/batch/docs/troubleshooting#constraint-violated-trusted-images)\nunless the VM OS image for their job is allowed.\nTo create and run jobs when the trusted image policy constraint is enabled,\ndo at least one of the following:\n\n- Have users [specify a VM OS image](/batch/docs/specify-vm-os-image) that is already allowed.\n- Allow the default VM OS images from Batch, as shown in this document.\n\nTo learn more about VM OS images and boot disks, see\n[VM OS environment overview](/batch/docs/vm-os-environment-overview).\nTo learn about which policy constraints have been\nenabled for your project, folder, or organization,\n[view your organization policies](/resource-manager/docs/organization-policy/creating-managing-policies).\n\nBefore you begin\n----------------\n\n1. If you haven't used Batch before, review [Get started with Batch](/batch/docs/get-started) and enable Batch by completing the [prerequisites for projects and users](/batch/docs/get-started#prerequisites).\n2.\n\n To get the permissions that\n you need to configure organization policies,\n\n ask your administrator to grant you the\n\n\n [Organization Policy Administrator](/iam/docs/roles-permissions/orgpolicy#orgpolicy.policyAdmin) (`roles/orgpolicy.policyAdmin`)\n IAM role on the organization.\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\n\u003cbr /\u003e\n\nAllow images from Batch\n-----------------------\n\nThe following steps describe how to modify the trusted image policy constraint\nto allow all VM OS images from Batch by using the\nGoogle Cloud console or Google Cloud CLI.\n\nFor more instructions on how to use the trusted image\n(`compute.trustedImageProjects`) policy constraint, see\n[Setting up trusted image policies](/compute/docs/images/restricting-image-access)\nin the Compute Engine documentation. \n\n### Console\n\n1. Go to the **Organization policies** page.\n\n [Go to Organization policies](https://console.cloud.google.com/iam-admin/orgpolicies/)\n2. From the policies list, click **Define trusted image projects**.\n\n The **Policy details** page opens.\n3. On the **Policy details** page, click edit **Manage Policy** . The **Edit policy**\n page opens.\n\n4. On the **Edit policy** page, select **Customize**.\n\n5. For **Policy enforcement**, select an enforcement option.\n\n6. Click **Add rule**.\n\n7. In the **Policy values** list, you can select whether to add a rule that\n allows access to all unspecified image projects, denies access to all\n unspecified image projects, or specifies a custom set of projects to\n allow or deny access to. To allow all images from Batch,\n do the following:\n\n 1. In the **Policy values** list, select **Custom** . A **Policy type** and **Custom values** field appears.\n 2. In the **Policy type** list, select **Allow**.\n 3. In the **Custom values** field, enter `projects/batch-custom-image`.\n8. To save the rule, click **Done**.\n\n9. To save and apply the organization policy, click **Save**.\n\n### gcloud\n\nThe following example describes how to allow images\nfrom Batch for a specific project:\n\n1. To get the existing policy settings for a project, run the\n [`resource-manager org-policies describe` command](/sdk/gcloud/reference/resource-manager/org-policies/describe):\n\n ```\n gcloud resource-manager org-policies describe \\\n compute.trustedImageProjects --project=PROJECT_ID \\\n --effective \u003e policy.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the project ID of the project\n that you want to update.\n2. Open the `policy.yaml` file in a text editor. Then, modify the\n `compute.trustedImageProjects` constraint by adding\n `projects/batch-custom-image` to the `allowedValues` field.\n For example, to allow only VM OS images from Batch\n set the `compute.trustedImageProjects` constraint to the following:\n\n ```\n constraint: constraints/compute.trustedImageProjects\n listPolicy:\n allowedValues:\n - projects//batch-custom-image\n ```\n\n When you have finished editing the `policy.yaml` file, save your changes.\n3. To apply the `policy.yaml` file to your project, use the\n [`resource-manager org-policies set-policy` command](/sdk/gcloud/reference/resource-manager/org-policies/set-policy):\n\n ```\n gcloud resource-manager org-policies set-policy \\\n policy.yaml --project=PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the project ID of the project\n that you want to update.\n\nWhen you finish updating constraints, testing those constraints is\nrecommended to verify that they are working as intended.\n\nWhat's next\n-----------\n\n- Create and run jobs, such as the following:\n - [Create and run a basic job](/batch/docs/create-run-basic-job), which uses a VM OS image from Batch by default.\n - [Create and run a job that uses a specific VM OS image](/batch/docs/specify-vm-os-image).\n- Learn more about [VM OS images and boot disks](/batch/docs/vm-os-environment-overview)."]]