Dalam panduan memulai ini, Anda akan mempelajari cara mengakses bucket Cloud Storage dari dalam aplikasi Google Kubernetes Engine (GKE) seolah-olah bucket tersebut adalah sistem file lokal. Panduan memulai ini menyediakan contoh manifes Kubernetes untuk membuat Pod yang me-mount bucket, dan menunjukkan cara berinteraksi dengan konten bucket menggunakan sistem file Pod.
Halaman ini ditujukan untuk Developer, spesialis Penyimpanan, dan siapa pun yang ingin menyediakan dan mengelola resource cloud, serta men-deploy workload. Untuk
mempelajari peran umum lebih lanjut, lihat
Peran dan tugas pengguna GKE umum.
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.
Ganti BUCKET_NAME dengan nama bucket Cloud Storage Anda.
Jika Anda menggunakan namespace atau akun layanan yang berbeda, ganti kolom namespace
dan serviceAccountName dengan tepat.
Konten manifes ini memulai Pod bernama gcsfuse-test yang memasang bucket di jalur /data-nya.
Verifikasi bahwa Pod sedang berjalan:
kubectlgetpodgcsfuse-test
Outputnya mirip dengan hal berikut ini:
NAME READY STATUS RESTARTS AGE
gcsfuse-test 2/2 Running 0 12s
Driver CSI Cloud Storage FUSE melampirkan container sidecar di Pod Anda untuk mengelola interaksi dengan Cloud Storage.
Jika Pod tidak berjalan, Anda dapat mengambil log peristiwa untuk membantu mendiagnosis
masalah dengan menjalankan perintah kubectl describe pod gcsfuse-test. Untuk mengetahui informasi selengkapnya,
lihat Pemecahan masalah di GitHub.
Setelah Pod berjalan, Anda dapat menjelajahi sistem filenya:
kubectlexec-itgcsfuse-test--find/data
Pembersihan
Agar tidak menimbulkan biaya pada akun Google Cloud Anda untuk resource yang Anda gunakan
dalam tutorial ini, hapus Pod:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]