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.

Prerequisites

The Kubernetes Operator for Apache Cassandra prerequisites are:

  • The kubectl CLI tool.

  • A Kubernetes cluster.

    If you have not already, Create a Kubernetes cluster.

    Kubernetes v1.21 or later is recommended and supported. For sample YAML manifest, refer to this GitHub folder.

  • The ability to download Docker Hub images from within the Kubernetes cluster.

  • At least one Kubernetes worker node per Cassandra or DSE instance.

Procedure

  1. 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.

    For example:

    kubectl create ns my-db-ns

    This example uses the namespace my-db-ns. Adjust subsequent commands to match the namespace that you defined.

  2. Define a storage class.

    Kubernetes uses the StorageClass resource 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 StorageClass with the name server-storage. Run the following kubectl command 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

    Sample output:

    NAME                 PROVISIONER            AGE
    server-storage       kubernetes.io/gce-pd   1m
    standard (default)   kubernetes.io/gce-pd   16m
  3. 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:

    1. ServiceAccount, Role, and RoleBinding describe 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.

    2. CustomResourceDefinition (CRD) for the CassandraDatacenter resources configure clusters managed by Kubernetes Operator for Apache Cassandra.

    3. 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.

    Using kubectl, apply the cass-operator-manifests YAML file and wait for the deployment to become ready.

    For example:

    kubectl -n my-db-ns apply -f ./cass-operator-manifests.yaml
  4. 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

    Sample output:

    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.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com