Configuring Cassandra or DSE in Kubernetes with the Kubernetes Operator for Apache Cassandra
Complete the following procedure to configure the Kubernetes Operator for Apache Cassandra in your existing Kubernetes environment.
-
Complete the prerequisites:
-
Create a Kubernetes cluster where you will set up the Cassandra Operator and Cassandra/DSE resources.
-
Authorize connections between your local machine where you will run
kubectlcommands and your Kubernetes cluster, as explained in Create a Kubernetes cluster.
-
-
Create a namespace for the cluster:
kubectl create ns my-db-ns
This example uses the namespace
my-db-ns. Adjust subsequent commands to match the namespace that you defined. -
Define a
StorageClassresource.DataStax recommends that you use the fastest type of networked storage available. For example, on Google Kubernetes Engine (GKE), use the following YAML parameters to define persistent network SSD-backed volumes:
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: server-storage provisioner: kubernetes.io/gce-pd parameters: type: pd-ssd replication-type: none volumeBindingMode: WaitForFirstConsumerYou can customize the values for your environment and save the configuration with a name such as
server-storage.yaml. These steps assume that you have defined aStorageClasswith the nameserver-storage. -
Run the following
kubectlcommand to apply the YAML file and get the resulting storage classes from Kubernetes:kubectl -n my-db-ns apply -f ./server-storage.yaml
-
Verify the storage class configuration:
kubectl -n my-db-ns get storageclass
Make sure your class is in the resulting list. For example:
NAME PROVISIONER AGE server-storage kubernetes.io/gce-pd 1m standard (default) kubernetes.io/gce-pd 16m
-
Deploy the Cassandra Operator.
The examples in this guide present several Kubernetes resources in a single operator YAML manifests file. The file contains the properties needed to deploy the Cassandra Operator. DataStax provides a set of the Cassandra Operator sample manifest YAML files based on supported Kubernetes releases. Download and customize the relevant YAML for your environment. The file includes values for the following resources:
-
ServiceAccount,Role, andRoleBindingdescribe a user and set of permissions necessary to run the Cassandra Operator. In non-production environments that do not have role-based access control enabled, these extra steps are unnecessary yet serve as an anticipatory best practice example for your eventual production deployments. -
CustomResourceDefinition(CRD) for theCassandraDatacenterresources configure clusters managed by the Cassandra Operator. -
Deployment parameters to start the Cassandra Operator in a state where it waits and watches for CassandaDatacenter resources.
Generally, cluster-admin privileges are required to register a CRD. All privileges needed by the Cassandra Operator are present within the release-specific sample manifest YAML files.
The Cassandra Operator doesn’t require cluster-admin privileges. Only the user defining the CRD requires those permissions.
-
-
Using
kubectl, apply thecass-operator-manifestsYAML file and wait for the deployment to become ready:kubectl -n my-db-ns apply -f ./cass-operator-manifests.yaml -
Track progress during deployment. For this async operation, you can watch the status by periodically checking the list of pods for the namespace. For example:
kubectl -n my-db-ns get podWhen the pod status is
Running, the Cassandra Operator is ready to use.