לפני שיוצרים מאגרי נפח או מקצים נפחים, צריך להגדיר רשת של ענן וירטואלי פרטי (VPC) באמצעות Private Service Connect (PSC), להפעיל את ממשקי ה-API הנדרשים ולהעניק את תפקידי ה-IAM המתאימים.
יצירת פרויקט והפעלת ממשקי API
- נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Filestore APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Filestore APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.
התפקידים הנדרשים
כדי לקבל את ההרשאות שדרושות להגדרת אמצעי אחסון של סוכן Filestore, צריך לבקש מהאדמין להקצות לכם את תפקידי ה-IAM הבאים בפרויקט:
-
הגדרה של מדיניות חיבור לשירות ורשתות VPC:
אדמין רשתות ב-Compute (
roles/compute.networkAdmin) -
צפייה במכונות Filestore וניהול שלהן ושל משאבים קשורים, כולל מאגרי נפח וסוכני נפח:
עורך Cloud Filestore (
roles/file.editor)
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
יכול להיות שאפשר לקבל את ההרשאות הנדרשות גם באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש.
הפעלת סוכן השירות
אם לא יצרתם מופע Filestore בפרויקט, מריצים את הפקודה הבאה כדי לאתחל את סוכן השירות של Filestore:
gcloud beta services identity create \
--service=file.googleapis.com \
--project=PROJECT_ID
מחליפים את PROJECT_ID במזהה הפרויקט ב- Google Cloud.
מתן הרשאות לסוכן השירות
כדי להגדיר נפחי סוכן של Filestore, צריך להקצות את התפקיד 'עריכה' (roles/file.editor) ב-Cloud Filestore לסוכן השירות של Filestore:
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:service-PROJECT_NUMBER@cloud-filer.iam.iam.gserviceaccount.com" \
--role="roles/file.editor"
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט ב- Google Cloud . -
PROJECT_NUMBER: מספר הפרויקט ב-Google Cloud .
הגדרת רשתות של Private Service Connect
כרכים של סוכן Filestore משתמשים ב-Private Service Connect כדי לחבר תשתית אחסון מנוהלת ישירות לרשת ה-VPC שלכם. Private Service Connect מבטיח תקשורת פרטית עם רוחב פס גבוה וזמן אחזור נמוך, בלי לדרוש כתובות IP ציבוריות או הגדרות של קישור בין רשתות VPC שכנות.
כדי ליצור מדיניות של חיבור שירות, מריצים את הפקודה הבאה:
gcloud network-connectivity service-connection-policies create POLICY_NAME \
--project=PROJECT_ID \
--region=REGION \
--network=projects/PROJECT_ID/global/networks/VPC_NETWORK \
--subnets=SUBNET_NAME \
--service-class=google-cloud-filestore
מחליפים את מה שכתוב בשדות הבאים:
-
POLICY_NAME: שם למדיניות חיבור השירות, למשלfilestore-agent-psc-policy. -
PROJECT_ID: מזהה הפרויקט ב- Google Cloud . -
REGION: האזור שבו ימוקמו מאגר הנפחים ועומסי העבודה, למשלus-central1. -
VPC_NETWORK: השם של רשת VPC קיימת. -
SUBNET_NAME: השם של רשת משנה רגילה של VPC באזור שצוין, שבו יוקצו כתובות IP של נקודת קצה מסוג Private Service Connect. לדוגמה, אפשר להגדיר את רשת המשנה שמוגדרת כברירת מחדל עם הדגל--purposeשמוגדר ל-PRIVATE.
יצירת מאגר נפחים ו-StorageClass
מאגר נפחים מספק את נפח האחסון המשותף ואת ה-IOPS לנפחי אחסון של סוכנים.
כדי להקצות נפחים באופן דינמי ממאגר הנפחים ב-GKE, צריך ליצור את מאגר הנפחים ואז להגדיר StorageClass של Kubernetes שמפנה אליו.
יצירת מאגר נפחים
כדי ליצור מאגר נפח לדוגמה, שולחים בקשת HTTP POST לנקודת הקצה volumePools.create:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{
"description": "Sample volume pool for agent volumes",
"network": "projects/PROJECT_ID/global/networks/VPC_NETWORK",
"defaultVolumeQuotaMib": 2048,
}' \
"https://file.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/volumePools?volumePoolId=VOLUME_POOL_ID"
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט ב- Google Cloud . -
VPC_NETWORK: השם של רשת ה-VPC שמופעל בה PSC. -
LOCATION: האזור שבו מאגר הנפחים נפרס, למשלus-central1. -
VOLUME_POOL_ID: מזהה של מאגר הנפח, כמוmy-volume-pool.
מידע נוסף מופיע במאמר בנושא יצירה וניהול של מאגרי נפח.
יצירת StorageClass
יוצרים קובץ מניפסט StorageClass בשם volume-pool-sc.yaml שמפנה אל מאגר הכרכים:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: volume-pool-sc
provisioner: filestore.csi.storage.gke.io
volumeBindingMode: Immediate
reclaimPolicy: Delete
allowVolumeExpansion: true
parameters:
volume-pool: "projects/<var>PROJECT_ID</var>/locations/<var>LOCATION</var>/volumePools/<var>VOLUME_POOL_ID</var>"
מחליפים את מה שכתוב בשדות הבאים:
-
PROJECT_ID: מזהה הפרויקט ב- Google Cloud . -
LOCATION: האזור שבו נפח האחסון של המאגר נפרס. -
VOLUME_POOL_ID: המזהה של מאגר הנפחים.
אם יש לכם אשכול GKE קיים עם מנהל התקן ה-CSI של Filestore, צריך להחיל את StorageClass:
kubectl apply -f volume-pool-sc.yaml
אחרת, צריך להחיל את קובץ המניפסט הזה אחרי שמגדירים את האשכול במאמר הגדרת סביבת GKE לנפחי סוכן Filestore.
המאמרים הבאים
- ליצור ולנהל מאגרי נפח.
- הגדרת סביבת GKE לנפחי אחסון של סוכן Filestore.