Quickstart for the Kubernetes Operator for Apache Cassandra
Get started with automating the process of deploying and managing Apache Cassandra® or DataStax Enterprise (DSE) in a Kubernetes (K8s) cluster.
For other install options, see Installation options.
Prepare the infrastructure
|
For guided instructions, see Create a Kubernetes cluster. |
-
Create a Kubernetes cluster and authorize connections between the cluster and your local machine.
The connection to your local machine is required to run
kubectlcommands. -
Install
kubectl. -
Recommended: Make sure you can download DataStax Docker images from within the Kubernetes cluster.
-
Have at least one Kubernetes worker node for each planned Cassandra or DSE instance.
After you prepare the infrastructure, follow the remainder of this quickstart to apply pre-configured Cassandra Operator manifests and related definitions to the Kubernetes environment, including deploying the Cassandra or DSE database. Then, you’ll connect to the deployed database from inside or outside the K8s cluster.
Create resources
The following kubectl commands create the Cassandra Operator and Cassandra or DSE resources on an existing GKE cloud that is running Google Kubernetes Engine (GKE) version 1.16.
Adjust the commands based on your cloud, storage, and database options.
-
Run this
kubectlcommand to reference a YAML file that applies the Cassandra Operator manifest’s definitions to the connected Kubernetes cluster.kubectl create -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/docs/user/cass-operator-manifests.yamlFor more manifest examples, see the Cassandra Operator GitHub repository.
-
Run the following
kubectlcommand to apply a YAML manifest that defines the storage settings to use for Cassandra nodes in a cluster.An example is SSD as a storage type. In this case, storage settings are for a GKE cluster. Kubernetes uses the
StorageClassresource as an abstraction layer between pods needing persistent storage and the physical storage resources that a specific Kubernetes cluster can provide.kubectl create -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/operator/k8s-flavors/gke/storage.yamlFor more options, see the Cassandra Operator GitHub repository.
-
Apply a YAML manifest that defines a
CassandraDatacenter.The following example creates a
CassandraDatacenterwith the open-source Apache Cassandra 3.11.7 image with three nodes on one rack in the Kubernetes cluster:kubectl -n cass-operator create -f https://raw.githubusercontent.com/k8ssandra/cass-operator/v1.7.1/operator/example-cassdc-yaml/cassandra-3.11.x/example-cassdc-minimal.yamlAlternatively, this example creates a
CassandraDatacenterwith the DataStax Enterprise (DSE) 6.8.4 image and three Kubernetes worker nodes on one rack:kubectl -n cass-operator create -f https://raw.githubusercontent.com/k8ssandra/cass-operator/master/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yamlFor more examples, see the Cassandra Operator GitHub repository.
Inspect resources in the Google Cloud Console
With the Cassandra Operator manifest, storage class, and datacenter definitions applied to the Kubernetes cluster, view the resources created and visible in the Kubernetes cluster. This GKE example uses the Google Cloud Console (aka Cloud Console), and the resources already established in Create a Kubernetes cluster.
-
Navigate to the Kubernetes Engine page in Cloud Console, and log into your account.
-
If you have not already done so, select your project.
-
On the Clusters tab, click the link for your cluster’s name.
-
Navigate through the Details, Storage, and Nodes sections to familiarize yourself with the created resources.
-
Click Workloads.
Workloads are deployable computing units that can be created and managed in the Kubernetes cluster. The Cassandra Operator manifest applied the YAML file applied that defined the cass-operator namespace and workload.
-
Click the Cluster link on the Workloads page to load details about the Cassandra Operator and Cassandra deployments in the Kubernetes cluster.
-
Select Services & Ingress to see how the Service labels for the deployed
cluster1Cassandra cluster and for thedc1datacenter correspond to the YAML manifest applied usingkubectlearlier. Notice the three serving pods. Services are sets of pods with a network endpoint that can be used for discovery and load balancing. Ingresses are collections of rules for routing external HTTP or HTTPS traffic to Services. From the initial Services tab, click thecluster1-dc1-serviceto get that service’s status. -
For more details, scroll to the Serving pods section, and select the link for one of the serving pods. The Cloud Console switches to the Workloads tab, and the Pod details page includes the status labels, such as
cassandra.datastax.com/node-state: Startedand additional metadata. Scroll down to the Containers section and notice the running container for thecassandra 3.11.7image. This container is deployed to your Kubernetes cluster and matches the YAML configuration applied earlier in this topic.
|
While many more options are available in Cloud Console, this introduction familiarizes you with the basics, and shows how applying the provided YAML files results in the creation and deployment of those Cassandra Operator and Cassandra resources in the Kubernetes cluster. |
Next steps
Connect to your database on your cluster:
-
Use
cqlshto connect to your database from within the Kubernetes cluster. -
Use various connection methods to connect to database resources and services running in K8s from outside the cluster.
With your database resources and connections in place, you can then use the Cassandra Operator to manage Cassandra and DSE resources in your Kubernetes cluster.