This module includes all prerequisites for running the Serverless Spark lab-
1. Declare variables
2. Enable Google Dataproc and Composer APIs
3. Network Configuration
4. Create a User Managed Service Account
5. Grant IAM permissions for UMSA
Note the project number and project ID.
We will need this for the rest fo the lab
Grant yourself Security Admin role.
This is needed for the networking setup and UMSA
Open Cloud shell or navigate to shell.cloud.google.com.
Run the below command to set the project to cloud shell terminal:
gcloud config set project <enter your project id here>
We will use these throughout the lab.
Run the below in cloud shell coped to the project you selected-
PROJECT_ID= #Project ID
REGION= #Region to be used
#User Managed Service Account
UMSA="serverless-spark"
# Note: Lowercase letters, numbers, hyphens allowed. All network names must be unique within the project
VPC=
SUBNET=
FIREWALL=
From cloud shell, run the below-
gcloud services enable dataproc.googleapis.com
gcloud services enable composer.googleapis.com
Run the commands below to create the networking entities required for the hands on lab.
gcloud compute networks create $VPC \
--subnet-mode=custom \
--bgp-routing-mode=regional \
--mtu=1500
b) List VPCs with:
gcloud compute networks list
c) Describe your network with:
gcloud compute networks describe $VPC
gcloud compute networks subnets create $SUBNET \
--network=$VPC \
--range=10.0.0.0/24 \
--region=$REGION \
--enable-private-ip-google-access
Intra-VPC, allow all communication
gcloud compute firewall-rules create $FIREWALL \
--project=$PROJECT_ID \
--network=projects/$PROJECT_ID/global/networks/$VPC \
--description="Allows connection from any source to any instance on the network using custom protocols." \
--direction=INGRESS \
--priority=65534 \
--source-ranges=10.0.0.0/9 \
--action=ALLOW --rules=all
gcloud iam service-accounts create $UMSA \
--description="User Managed Service Account for Serverless Spark" \
--display-name "Serverless Spark SA"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/viewer
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/storage.admin
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/dataproc.editor
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/dataproc.worker
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/bigquery.dataEditor
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$UMSA@$PROJECT_ID.iam.gserviceaccount.com --role roles/bigquery.user