# Cluster Operations

This page describes the steps to perform the following operations using the TigerGraph Kubernetes Operator.

In Kubernetes, you provision resources such as TigerGraph clusters by creating a Deployment. Depending on the context, this document may refer to creating a cluster by creating a Deployment.

 Kubernetes Operator support is currently a Preview Feature. Preview Features give users an early look at future production-level features. Preview Features should not be used for production deployments.

## Create TigerGraph clusters

To create a TigerGraph cluster, run the following command:

``$kubectl tg create --cluster-name <cluster_name> --storage-class <storage_class> --namespace <namespace_name>`` Each cluster is provisioned with persistent volumes for each node by default. When you create a cluster with persistent volumes, you must specify a storage class. Run `kubectl get storageclass` to show the names of the available storage classes. ``````$ kubectl get storageclass

NAME                 PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
gcp-pd-ssd           kubernetes.io/gce-pd    Delete          WaitForFirstConsumer   false                  35d
premium-rwo          pd.csi.storage.gke.io   Delete          WaitForFirstConsumer   true                   232d
standard (default)   kubernetes.io/gce-pd    Delete          Immediate              true                   232d
standard-rwo         pd.csi.storage.gke.io   Delete          WaitForFirstConsumer   true                   232d``````

The default storage class is `standard`.

If you create a cluster in a specific namespace, the namespace must already exist. The command does not create a namespace for you.

You can specify pod CPU, memory, TigerGraph version, and other parameters through command-line options.

You must also provide your license key with the `--license` command. Contact TigerGraph support for help finding your license key. A free license, valid for 14 days, is available through this link: A free license is available through this link: ftp://ftp.graphtiger.com/lic/license3.txt

Starting with Operator version 0.0.4, you need to provide your own SSH key for security. See Secrets in Kubernetes for more information. In this example, it is named `ssh-key-secret`.

``````# Create a new private key
echo -e 'y\n' | ssh-keygen -b 4096 -t rsa -f $HOME/.ssh/tigergraph_rsa -q -N '' # Create a Kubernetes secret with above SSH key files kubectl create secret generic ssh-key-secret --from-file=private-ssh-key=$HOME/.ssh/tigergraph_rsa --from-file=public-ssh-key=$HOME/.ssh/tigergraph_rsa.pub --namespace YOUR_NAME_SPACE`````` Example cluster creation command ``````kubectl tg create --cluster-name <your cluster name> --size 3 --ha 2 --version 3.9.0 --private-key-secret ssh-key-secret \ --storage-class standard --storage-size 10G --cpu 3000m --memory 6Gi --namespace${YOUR_NAMESPACE} --license <your TigerGraph license>``````

Run `kubectl tg help` to view all options available and their default values, which will be used if left unspecified. Some of the most common additional options are explained here.

The `--ha` flag specifies the replication factor (HA factor) of the cluster, which is the total number of instances of your data. If you create a 6-node cluster with the `--ha 2` flag, your cluster has two instances of data that are divided into 3 partitions.

If you have cloned TigerGraph images for a self-hosted registry, specify the registry with the `--docker-registry` option:

``$kubectl tg create --cluster-name <cluster_name> --namespace <namespace_name> --docker-registry <your_registry>`` ## List TigerGraph clusters Run the following command to list all running TigerGraph clusters in all namespaces as well as their size: ``$ kubectl tg list --namespace all``

If you want to limit the scope to a specific namespace, change `all` to the namespace you want to list clusters for.

## Check cluster version and status

Run the following command to check the status of a cluster. Replace `<cluster_name>` with the name of the cluster, and `<namespace_name>` with the namespace where the cluster is provisioned:

``$kubectl tg status --cluster-name <cluster_name> --namespace <namespace_name>`` You can also check the version with `version`. ``````$ kubectl tg version
Version: 0.0.4
Default version of TigerGraph cluster: 3.9.0``````

## Delete TigerGraph clusters

Run the following command to delete a cluster. Replace `<cluster_name>` with the name of the cluster, and `<namespace_name>` with the namespace where the cluster is provisioned:

``$kubectl tg delete --cluster-name <cluster_name> --namespace <namespace_name>`` To protect your data, deleting a cluster does not delete the Persistent Volume Claims (PVC) provisioned when you create the cluster. To delete the PVCs created with a cluster, run the following command: ``$ kubectl delete pvc  -l app=<cluster_name> -n <namespace_name>``

## Shrink or expand a cluster

Run the following commands to change the size of a cluster. Replace `<cluster_name>` with the name of the cluster, and `<namespace_name>` with the namespace where the cluster is provisioned: