In dieser Kurzanleitung erfahren Sie, wie Sie von einer Google Kubernetes Engine-Anwendung (GKE) aus auf Cloud Storage-Buckets zugreifen können, als wären sie lokale Dateisysteme. In dieser Kurzanleitung finden Sie ein Beispiel für ein Kubernetes-Manifest zum Erstellen eines Pods, in dem der Bucket bereitgestellt wird. Außerdem wird gezeigt, wie Sie über das Dateisystem des Pods auf den Inhalt des Buckets zugreifen.
Diese Seite richtet sich an Entwickler, Speicherexperten und alle anderen, die Cloud-Ressourcen bereitstellen und verwalten und Arbeitslasten bereitstellen möchten. Weitere Informationen zu gängigen Rollen finden Sie unter Häufig verwendete GKE-Nutzerrollen und -Aufgaben.
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
In the Principal column, find all rows that identify you or a group that
you're included in. To learn which groups you're included in, contact your
administrator.
For all rows that specify or include you, check the Role column to see whether
the list of roles includes the required roles.
Klicken Sie in der Liste der Buckets auf den Namen des Buckets, den Sie gerade erstellt haben.
Führen Sie im Tab Objekte für den Bucket einen der folgenden Schritte aus:
Ziehen Sie Dateien von Ihrem Desktop oder Dateimanager in den Hauptbereich der Google Cloud -Konsole.
Klicken Sie auf die Schaltfläche Upload Files (Dateien hochladen). Wählen Sie im angezeigten Dialogfeld die Dateien aus, die Sie hochladen möchten, und klicken Sie auf Öffnen.
Zugriff auf Ihren Cloud Storage-Bucket konfigurieren
Ersetzen Sie BUCKET_NAME durch den Namen des Cloud Storage-Buckets.
Wenn Sie einen anderen Namespace oder ein anderes Dienstkonto verwenden, ersetzen Sie die Felder namespace und serviceAccountName entsprechend.
Der Inhalt dieses Manifests startet einen Pod namens gcsfuse-test, der den Bucket auf seinem Pfad /data bereitstellt.
Prüfen Sie, ob der Pod ausgeführt wird:
kubectlgetpodgcsfuse-test
Die Ausgabe sieht etwa so aus:
NAME READY STATUS RESTARTS AGE
gcsfuse-test 2/2 Running 0 12s
Der Cloud Storage FUSE-CSI-Treiber hängt einen Sidecar-Container an Ihren Pod an, um die Interaktionen mit Cloud Storage zu verwalten.
Wenn der Pod nicht ausgeführt wird, können Sie die Ereignisprotokolle abrufen, um das Problem zu diagnostizieren. Führen Sie dazu den Befehl kubectl describe pod gcsfuse-test aus. Weitere Informationen finden Sie auf GitHub unter Fehlerbehebung.
Nachdem der Pod ausgeführt wurde, können Sie sein Dateisystem durchsuchen:
kubectlexec-itgcsfuse-test--find/data
Bereinigen
Wenn Sie vermeiden möchten, dass Ihrem Google Cloud Konto die in dieser Anleitung verwendeten Ressourcen in Rechnung gestellt werden, löschen Sie den Pod:
[[["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-07-31 (UTC)."],[],[],null,["# Quickstart: Access Cloud Storage buckets with the FUSE CSI driver\n=================================================================\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview)\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\nIn this quickstart guide, you learn how to access Cloud Storage buckets from within\na Google Kubernetes Engine (GKE) application as if they were local file systems. This\nquickstart provides a sample Kubernetes manifest to create a Pod that mounts the\nbucket, and shows you how to interact with the bucket's contents using the Pod's file\nsystem.\n\nThis page is for Developers, Storage specialists, and anyone else\nwho wants to provision and manage cloud resources, and deploy workloads. To\nlearn more about common roles, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nBefore reading this page, ensure that you're familiar with [Kubernetes](https://kubernetes.io/)\nand [Cloud Storage FUSE CSI driver](/kubernetes-engine/docs/concepts/cloud-storage-fuse-csi-driver).\n\nThis quickstart uses the GKE Autopilot mode. If you want to use the\nStandard mode, see [Set up the Cloud Storage FUSE CSI driver for GKE](/kubernetes-engine/docs/how-to/cloud-storage-fuse-csi-driver-setup#standard).\n\nBefore you begin\n----------------\n\nSign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n\nIn the Google Cloud console, on the project selector page,\nselect or create a Google Cloud project.\n| **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n[Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n\n\n[Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n\n[Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com,storage.googleapis.com) \nIn the Google Cloud console, on the project selector page,\nselect or create a Google Cloud project.\n| **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n[Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n\n\n[Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n\n[Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com,storage.googleapis.com)\n1. Make sure that you have the following role or roles on the project: Kubernetes Engine Admin, Storage Admin, Service Account User\n\n#### Check for the roles\n\n1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n2. Select the project.\n3.\n In the **Principal** column, find all rows that identify you or a group that\n you're included in. To learn which groups you're included in, contact your\n administrator.\n\n4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.\n\n#### Grant the roles\n\n1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n2. Select the project.\n3. Click person_add **Grant access**.\n4.\n In the **New principals** field, enter your user identifier.\n\n This is typically the email address for a Google Account.\n\n5. In the **Select a role** list, select a role.\n6. To grant additional roles, click add **Add\n another role** and add each additional role.\n7. Click **Save**.\n\nCreate a GKE Autopilot cluster\n------------------------------\n\n1.\n\n\n In the Google Cloud console, go to the **Create an Autopilot cluster** page.\n\n [Go to Create an Autopilot cluster](https://console.cloud.google.com/kubernetes/auto/add)\n\n \u003cbr /\u003e\n\n2. Under **Cluster basics**, do the following:\n\n 1. In the **Name** field, enter a name for the cluster.\n\n 2. Keep the default values for the rest of the settings.\n\n3. To create the cluster, click **Create**.\n\nCreate a Cloud Storage bucket\n-----------------------------\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page. \n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. Click add_box **Create**.\n\n3. On the **Create a bucket** page, in the **Get started** section, do the following:\n\n 1. Enter a globally unique name for your bucket that meets the\n [bucket naming requirements](/storage/docs/buckets#naming).\n\n 2. Keep the default values for the rest of the settings.\n\n4. To create the bucket, click **Create**.\n\nUpload objects to your Cloud Storage bucket\n-------------------------------------------\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page. \n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. In the list of buckets, click the name of the bucket that you just created.\n\n3. In the **Objects** tab for the bucket, do either of the following:\n\n - Drag files from your desktop or file manager\n to the main pane in the Google Cloud console.\n\n - Click the **Upload Files** button. In the dialog that appears, select the\n files that you want to upload, and click **Open**.\n\n | **Note:** If you're using the Chrome browser, folder uploads are also supported.\n\nConfigure access to your Cloud Storage bucket\n---------------------------------------------\n\nTo make sure your Cloud Storage bucket is accessible by your GKE\ncluster, follow the steps in [Configure access to Cloud Storage buckets](/kubernetes-engine/docs/how-to/cloud-storage-fuse-csi-driver-setup#authentication).\n\nSet up Cloud Shell\n------------------\n\nIn the Google Cloud console, activate Cloud Shell.\n\n[Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\nA [Cloud Shell](/shell/docs/how-cloud-shell-works) session starts and displays a command-line prompt. It can take a few seconds for the session to initialize.\n\nDeploy a Pod to access your Cloud Storage bucket by using FUSE\n--------------------------------------------------------------\n\n| **Note:** To optimize your configuration, see [Optimize Cloud Storage Cloud Storage FUSE CSI driver for GKE performance](/kubernetes-engine/docs/how-to/cloud-storage-fuse-csi-driver-perf).\n\n1. Set the default project where you want\n to deploy the Pod:\n\n gcloud config set project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID.\n2. Create and apply the Pod manifest with the following content:\n\n cat \u003c\u003c EOF | kubectl apply -f -\n apiVersion: v1\n kind: Pod\n metadata:\n name: gcsfuse-test\n namespace: default\n annotations:\n gke-gcsfuse/volumes: \"true\"\n spec:\n terminationGracePeriodSeconds: 60\n containers:\n - image: busybox\n name: busybox\n command: [\"sleep\"]\n args: [\"infinity\"]\n volumeMounts:\n - name: gcsfuse-test\n mountPath: /data\n readOnly: true\n serviceAccountName: default\n volumes:\n - name: gcsfuse-test\n csi:\n driver: gcsfuse.csi.storage.gke.io\n volumeAttributes:\n bucketName: \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e\n mountOptions: \"implicit-dirs\"\n EOF\n\n - Replace \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e with your Cloud Storage bucket name.\n - If you're using a different namespace or a service account, replace the `namespace` and `serviceAccountName` fields accordingly.\n\n The content of this manifest starts a Pod called `gcsfuse-test` that mounts the bucket on its `/data` path.\n3. Verify that the Pod is running:\n\n kubectl get pod gcsfuse-test\n\n The output is similar to the following: \n\n NAME READY STATUS RESTARTS AGE\n gcsfuse-test 2/2 Running 0 12s\n\n The Cloud Storage FUSE CSI driver [attaches a sidecar container](https://kubernetes.io/blog/2023/08/25/native-sidecar-containers/) in your Pod to manage interactions with Cloud Storage.\n\n If the Pod isn't running, you can fetch the event logs to help you diagnose the\n issue by running the `kubectl describe pod gcsfuse-test` command. For more information,\n see [Troubleshooting](https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/docs/troubleshooting.md#pod-event-warnings) on GitHub.\n4. After the Pod is running, you can explore its file system:\n\n kubectl exec -it gcsfuse-test -- find /data\n\n | **Success:** You've successfully accessed your Cloud Storage bucket as a local file system!\n\nClean up\n--------\n\n\u003cbr /\u003e\n\nTo avoid incurring charges to your Google Cloud account for the resources that you used\nin this tutorial, delete the Pod: \n\n kubectl delete pod gcsfuse-test\n\nWhat's next\n-----------\n\n- [Learn how the Cloud Storage FUSE CSI driver for GKE works](/kubernetes-engine/docs/concepts/cloud-storage-fuse-csi-driver).\n- [Learn more about the capabilities of Cloud Storage FUSE](/storage/docs/cloud-storage-fuse/overview).\n- [Troubleshoot Cloud Storage FUSE](https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/docs/troubleshooting.md).\n- [Optimize Cloud Storage FUSE for performance](/kubernetes-engine/docs/how-to/cloud-storage-fuse-csi-driver-perf)."]]