Configuring Cassandra or DSE in Kubernetes with Kubernetes Operator for Apache Cassandra
Complete the following procedure to configure Kubernetes Operator for Apache Cassandra in your existing Kubernetes (K8s) environment.
-
Complete the prerequisites:
-
Create a Kubernetes cluster where you will set up Kubernetes Operator for Apache Cassandra® 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 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 operator. DataStax provides a set of Kubernetes Operator for Apache Cassandra 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 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 Kubernetes Operator for Apache Cassandra. -
Deployment parameters to start the 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 Kubernetes Operator for Apache Cassandra are present within the release-specific sample manifest YAML files.
The Kubernetes Operator for Apache Cassandra 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 operator is ready to use.