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.
The Kubernetes Operator for Apache Cassandra prerequisites are:
Create a namespace.
Kubernetes Operator for Apache Cassandra is built to watch over pods running Cassandra 3.11 or later, or DSE 6.8.0 or later, in a Kubernetes namespace. 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 storage class.
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.
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: WaitForFirstConsumer
You can customize the values for your environment and save the configuration with a name such as
server-storage.yaml. This topic assumes that you have defined a
StorageClasswith the name
server-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
To verify the storage class configuration, run:
kubectl -n my-db-ns get storageclass
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:
RoleBindingdescribe 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 the
CassandraDatacenterresources 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 hosted by DataStax.
The Kubernetes Operator for Apache Cassandra does not require cluster-admin privileges. Only the user defining the CRD requires those permissions.
kubectl, apply the
cass-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 pod
NAME READY STATUS RESTARTS AGE cass-operator-f74447c57-kdf2p 1/1 Running 0 1h
When the pod status is
Running, the operator is ready to use.