How to retrieve K8ssandra superuser credentials ?

yashgangwar7558

Yash Gangwar

Posted on May 18, 2022

How to retrieve K8ssandra superuser credentials ?

Before starting

Before proceeding further just make sure you have your K8ssandra cluster up and running. To check the status of your pods run:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Your output should look like this:

NAME                                                   READY   STATUS    RESTARTS   AGE
dok-k8ssandra-kube-prometh-operator-6fdf96f759-dqhmb   1/1     Running   0          9h
prometheus-dok-k8ssandra-kube-prometh-prometheus-0     2/2     Running   0          9h
dok-k8ssandra-dc1-stargate-55fb98ff88-6lhm2            1/1     Running   14         9h
dok-k8ssandra-grafana-5b8b6986f4-h7js9                 2/2     Running   0          9h
dok-k8ssandra-dc1-default-sts-0                        2/2     Running   0          39m
dok-k8ssandra-cass-operator-84549dd7d6-b42lq           1/1     Running   9          9h
Enter fullscreen mode Exit fullscreen mode

Retrieve K8ssandra superuser credentials

You’ll need the K8ssandra superuser username and password in order to access Cassandra utilities and do things like generating Stargate access token to connect to Cassandra, accessing Cassandra using CQLSH, etc.

✅ Step 1: Retrieve the K8ssandra superuser username and password:

  • To extract the username execute the following command:

    kubectl get secrets <deployment/cluster-name>-superuser -o jsonpath="{.data.username}"
    

    In my case, I have kept my cluster-name as dok-k8ssandra, so my command will look like:

    kubectl get secrets dok-k8ssandra-superuser -o jsonpath="{.data.username}"
    

    Your output should look like this:

    ZG9rLWs4c3NhbmRyYS1zdXBlcnVzZXI=
    
  • To extract the password execute the following command:

    kubectl get secrets <deployment/cluster-name>-superuser -o jsonpath="{.data.password}"
    

    In my case, I have kept my cluster-name as dok-k8ssandra, so my command will look like:

    kubectl get secrets dok-k8ssandra-superuser -o jsonpath="{.data.password}"
    

    Your output should look like this:

    WmdsSDNkdDhqVTJZem9ldGdYelI=
    

    The credentials you extracted here are encoded, so before using them you need to decode them using base64.

✅ Step 2: Decoding the K8ssandra superuser username and password:

  • Decoding username using base64:

    If you are using Ubuntu CLI, you can run the following command:

    echo <encoded username> | base64 --decode
    

    If this command dosen't works on your CLI, you can try using the online base64 decoder.

    Your decoded username should look like this:

    dok-k8ssandra-superuser
    
  • Decoding password using base64:

    If you are using Ubuntu CLI, you can run the following command:

    echo <encoded password> | base64 --decode
    

    If this command dosen't works on your CLI, you can try using the online base64 decoder.

    Your decoded password should look like this:

    ZglH3dt8jU2YzoetgXzR
    

Awesome, So now we have our decoded credentials ready to use for accessing Cassandra utilities. Let's see an example where we need to use them to generate a Stargate access token to access Cassandra.

💖 💪 🙅 🚩
yashgangwar7558
Yash Gangwar

Posted on May 18, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related