Google Cloud Platform
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Prerequisites
- Download and install the Google Cloud SDK.
NOTE: If you install gcloud using a package manager (as opposed to downloading and installing it manually), it does not support some of the commands below.
- Install
kubectl
After installing Cloud SDK, install the kubectl command-line tool by running the following command:
1. $ gcloud components install kubectl
- Configure defaults for gcloud
Set the project id as yugabyte. You can change this as per your need.
1. $ gcloud config set project yugabyte
Set the defaut compute zone as us-west1-b. You can change this as per your need.
1. $ gcloud config set compute/zone us-west1-b
1. Create a GKE cluster
Create a Kubernetes cluster if you have not already done so by running the following command.
1. $ gcloud container clusters create yugabyte
2. Create a YugabyteDB cluster
Create a YugabyteDB cluster by running the following.
1. $ kubectl create -f https://raw.githubusercontent.com/yugabyte/yugabyte-db/master/cloud/kubernetes/yugabyte-statefulset.yaml
1. service "yb-masters" created
2. statefulset "yb-master" created
3. service "yb-tservers" created
4. statefulset "yb-tserver" created
3. Check the cluster
You should see the following pods running.
1. $ kubectl get pods
1. NAME READY STATUS RESTARTS AGE
2. yb-master-0 1/1 Running 0 3m
3. yb-master-1 1/1 Running 0 3m
4. yb-master-2 1/1 Running 0 3m
5. yb-tserver-0 1/1 Running 0 3m
6. yb-tserver-1 1/1 Running 0 3m
7. yb-tserver-2 1/1 Running 0 3m
You can view the persistent volumes.
1. $ kubectl get persistentvolumes
1. NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
2. pvc-f3301c41-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-master-0 standard 5m
3. pvc-f33f29b3-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-master-1 standard 5m
4. pvc-f35005b6-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-master-2 standard 5m
5. pvc-f36189ab-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-tserver-0 standard 5m
6. pvc-f366a4af-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-tserver-1 standard 5m
7. pvc-f36d2892-1110-11e8-8231-42010a8a0083 1Gi RWO Delete Bound default/datadir-yb-tserver-2 standard 5m
You can view all the services by running the following command.
1. $ kubectl get services
1. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
2. kubernetes ClusterIP XX.XX.XX.X <none> 443/TCP 23m
3. yb-masters ClusterIP None <none> 7000/TCP,7100/TCP 17m
4. yb-tservers ClusterIP None <none> 9000/TCP,9100/TCP,9042/TCP,6379/TCP 14m
4. Connect to the cluster
You can connect to the YCQL API by running the following.
1. $ kubectl exec -it yb-tserver-0 bin/cqlsh
1. Connected to local cluster at 127.0.0.1:9042.
2. [cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]
3. Use HELP for help.
4. cqlsh> DESCRIBE KEYSPACES;
6. system_schema system_auth system
5. Destroy cluster (optional)
Destroy the YugabyteDB cluster we created above by running the following.
1. $ kubectl delete -f https://raw.githubusercontent.com/yugabyte/yugabyte-db/master/cloud/kubernetes/yugabyte-statefulset.yaml
1. service "yb-masters" deleted
2. statefulset "yb-master" deleted
3. service "yb-tservers" deleted
4. statefulset "yb-tserver" deleted
To destroy the persistent volume claims (you will lose all the data if you do this), run:
1. $ kubectl delete pvc -l app=yb-master
2. $ kubectl delete pvc -l app=yb-tserver
6. Destroy the GKE cluster (optional)
To destroy the machines we created for the gcloud cluster, run the following.
1. $ gcloud container clusters delete yugabyte
Advanced Kubernetes Deployment
More advanced scenarios for deploying in Kubernetes are covered in the Kubernetes Deployments section.
