Search code examples
cassandragoogle-kubernetes-enginecass-operator

get shell of the pod running Cassandra via GKE


I have created a GKE cluster of Cassandra and I want to run nodetool on each node to back up the data. I am unable to figure out how to do it.

So far, I have SSHed to the node on the kubernetes cluster and I lost from that point onwards. I did docker ps -a and can see the containers. How do I get to each container/pod and take back up?


Solution

  • @Manu Chadha

    I am not sure which method you used to install Cass on GKE, but with the cass-operator tag I am going to assume you used the Cass Operator.

    This is how i get to pods (NEED POD NAME):

    kubectl -n cass-operator get pods
    NAME                             READY   STATUS    RESTARTS   AGE
    cass-operator-557f6689df-qftdf   1/1     Running   0          14m
    cluster1-dc1-default-sts-0       2/2     Running   0          11m
    cluster1-dc1-default-sts-1       2/2     Running   0          11m
    cluster1-dc1-default-sts-2       2/2     Running   0          11m
    

    Next I can get to bash with pod name:

    kubectl -n cass-operator exec --stdin cluster1-dc1-default-sts-0 -- /bin/bash
    

    From bash I can use nodetool or dsetool

    You can also execute these directly like this:

    kubectl -n cass-operator exec -it -c cassandra cluster1-dc1-default-sts-0 -- nodetool status
    

    I am updating to answer the last question about backups. Backups are done a bit different with cass-operator. Be sure to include backup enabled in your yaml:

    # Sized to work on 3 k8s workers nodes with 1 core / 4 GB RAM
    # See neighboring example-cassdc-full.yaml for docs for each parameter
    apiVersion: cassandra.datastax.com/v1beta1
    kind: CassandraDatacenter
    metadata:
      name: dc1
    spec:
      clusterName: cluster1
      serverType: dse
      serverVersion: "6.8.4"
      managementApiAuth:
        insecure: {}
      size: 3
      storageConfig:
        cassandraDataVolumeClaimSpec:
          storageClassName: server-storage
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 25Gi
      config:
        cassandra-yaml:
          backup_service:
            enabled: true
        jvm-server-options:
          initial_heap_size: "800M"
          max_heap_size: "800M"
          additional-jvm-opts:
            # As the database comes up for the first time, set system keyspaces to RF=3
            - "-Ddse.system_distributed_replication_dc_names=dc1"
            - "-Ddse.system_distributed_replication_per_dc=3"
    

    Follow the documented steps for GKE and Google Blog Storage:

    https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/operations/opsBackupRestoreCreateBackupStore.html

    https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/operations/opsCqlCreateBackupStore.html