This page lists the gcloud CLI commands needed to set up prerequisites, provision an instance, describe an instance, and delete an instance on a standard VPC network. For instructions on performing these tasks on a Shared VPC network, see Instance provisioning on a Shared VPC network. In order to accomplish these tasks you should follow the instructions in each section of this page.
For more detailed guidance for these tasks, see the following pages:
Enable APIs
Begin by enabling the APIs in this section. These APIs are needed because Memorystore for Valkey uses Private Service Connect service connectivity automation to automate connectivity for instances. For more information, see Networking.
To enable the APIs, run the following commands:
gcloud
gcloud services enable --project=PROJECT_ID networkconnectivity.googleapis.com gcloud services enable --project=PROJECT_ID compute.googleapis.com gcloud services enable --project=PROJECT_ID serviceconsumermanagement.googleapis.com gcloud services enable --project=PROJECT_ID memorystore.googleapis.com
Replace the following:
- PROJECT_ID is your project ID.
Create a service connection policy
You must create a service connection policy
for the project, network, and region where you want to provision the
Memorystore for Valkey instance. A service connection policy lets you authorize
the gcp-memorystore
service class to create a Private Service Connect
connection between producer and consumer VPC networks in the region where the
policy is defined, and in the subnet that the policy specifies.
To see the permission needed to create a service connection policy, see required roles.
This quickstart uses the default
network and default
subnet. IP addresses
for your instance are allocated on this default subnet in the region.
To create the service connection policy, run the following command:
gcloud
gcloud network-connectivity service-connection-policies create POLICY_NAME \ --network=default \ --project=PROJECT_ID \ --region=REGION \ --service-class=gcp-memorystore \ --subnets=https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/subnetworks/default
Replace the following:
- POLICY_NAME is your desired policy name.
- PROJECT_ID is the project ID.
- REGION is the same region where you want to provision your Memorystore for Valkey instance.
Validate service connection policy creation
Validate if the policy was created successfully by running the list
command:
gcloud
gcloud network-connectivity service-connection-policies list --region=REGION --project=PROJECT_ID
Replace the following:
- PROJECT_ID is the project ID.
- REGION is the region where the service connection policy is defined.
Create an instance
To create an instance, run the create
command:
gcloud
gcloud beta memorystore instances create INSTANCE \ --project=PROJECT_ID \ --location=REGION \ --node-type=NODE_TYPE \ --shard-count=SHARD_COUNT \ --replica-count=REPLICA_COUNT \ --psc-auto-connections=network=projects/PROJECT_ID/global/networks/NETWORK_ID,projectId=PROJECT_ID \
Replace the following:
- INSTANCE is the instance ID.
REGION is the region where you want to provision your instance.
NODE_TYPE is your chosen node type. Accepted values are:
shared-core-nano
standard-small
highmem-medium
highmem-xlarge
For more details on node types and instance configurations, see Instance and node specification.
SHARD_COUNT determines the number of shards in your instance. Shard count determines the total memory capacity for storing instance data. To see more details about instance specification, see Instance and node specification.
REPLICA_COUNT is your desired number of read replicas (per shard). Accepted values are
0
,1
, and2
.PROJECT_ID is the ID of the project where you want to create your instance.
NETWORK_ID is the ID of the network you want to use to create your instance.
Describe the instance
To view instance details, run the describe
command:
gcloud
gcloud beta memorystore instances describe INSTANCE \ --project=PROJECT_ID \ --location=REGION
Replace the following:
- INSTANCE is the instance ID.
- PROJECT_ID is the project ID.
- REGION is the region where your instance is located.
Delete the instance
To delete an instance, run the delete
command:
gcloud
gcloud beta memorystore instances delete INSTANCE \ --project=PROJECT_ID \ --location=REGION
Replace the following:
- INSTANCE is the instance ID.
- PROJECT_ID is the project ID.
- REGION is the region where your instance is located.