-
Notifications
You must be signed in to change notification settings - Fork 9
Working with Data
There are two main ways to communicate with Cassandra: API, and CQLSH. In this part, we will use both! Let's start with an application first:
✅ Step 1: Deploy the PetClinic app by applying the manifest.
kubectl apply -f petclinic.yaml
Click to show output 📃
ec2-user@ip-172-31-5-5:~/kubernetes-workshop-online> kubectl apply -f petclinic.yaml
deployment.apps/petclinic-backend created
service/petclinic-backend created
deployment.apps/petclinic-frontend created
service/petclinic-frontend created
ingress.networking.k8s.io/petclinic-ingress created
We can watch our app come online with the same command we used before. Just like last time use Ctrl + C to exit the watch.
watch kubectl get pods
Click to show output 📃
Every 2.0s: kubectl get pods ip-172-31-5-5.eu-central-1.compute.internal: Tue Nov 17 15:28:10 2020
NAME READY STATUS RESTARTS AGE
cass-operator-cd9b57568-hcqc6 1/1 Running 0 26m
grafana-deployment-cfc94cf66-n7jk4 1/1 Running 0 21m
k8ssandra-cluster-a-grafana-operator-k8ssandra-6466cf94c9-skzrs 1/1 Running 0 23m
k8ssandra-cluster-a-reaper-k8ssandra-59cb88b674-lh6cx 1/1 Running 0 20m
k8ssandra-cluster-a-reaper-k8ssandra-schema-2p2tp 0/1 Completed 4 23m
k8ssandra-cluster-a-reaper-operator-k8ssandra-56cc9bf47c-9nt2l 1/1 Running 0 23m
k8ssandra-dc1-default-sts-0 2/2 Running 0 23m
k8ssandra-tools-kube-prome-operator-6d556b76f8-pqbmt 1/1 Running 0 26m
petclinic-backend-7d47bcc6cc-smmv7 1/1 Running 0 59s
petclinic-frontend-75b98f7f8d-x2zgk 1/1 Running 0 59s
prometheus-k8ssandra-cluster-a-prometheus-k8ssandra-0 2/2 Running 1 23m
traefik-7877ff76c9-rcm9n 1/1 Running 0 27m
✅ Step 2: Using PetClinic
✅ Step 2a: Local/Civo Installs
-
Local install: If you are using your own infrastructure navigate to
localhost:80
to see the UI
For minikube only, you may need the following additional command to enable ingress.
sudo minikube tunnel
-
Civo install: Use the output of the following command and navigate to
<IP-FROM-COMMAND-BELOW>:80
to see the UI
civo kubernetes show k8ssandra | grep DNS | awk '{print $5}'
✅ Step 2b: Datastax provided VMs
- Datastax hosted VMs install: Navigate to the petclinic link in your cloud instance page to interact with the pet clinic app. If you have done everything correctly you should see the following.
You should see the following UI.
Click on the pet types tab at the top of the page.
Click the add button and enter a new pet type.
To see the original app, the Pet Clinic app Github repo is here. But, we have forked our own version for today.
✅ Step 3: Setup port forwarding
✅ Step 3a: Local/Civo Installs Only If using local or civo installs, setup port forwarding with the following command.
kubectl port-forward svc/k8ssandra-dc1-stargate-service 8080 8081 8082 9042 &
✅ Step 4: Retrieve K8ssandra superuser credentials.
You’ll need the K8ssandra superuser name and password in order to access Cassandra utilities and do things.
Retrieve the K8ssandra superuser name:
kubectl get secret k8ssandra-superuser -o jsonpath="{.data.username}" | base64 --decode ; echo
Output: k8ssandra-superuser
Retrieve the K8ssandra superuser password:
kubectl get secret k8ssandra-superuser -o jsonpath="{.data.password}" | base64 --decode ; echo
Output: PGo8kROUgAJOa8vhjQrE49Lgruw7s32HCPyVvcfVmmACW8oUhfoO9A
✅ Step 5: connect using CQLSH.
Issue the following command from a terminal. For Datastax provided VMs, use the secure shell terminal to issue the command.
kubectl exec -it k8ssandra-dc1-default-sts-0 -c cassandra -- cqlsh -u k8ssandra-superuser -p <PASSWORD>
✅ Step 6: run basic CQL operations.
describe keyspaces;
use spring_petclinic;
describe tables;
select * from petclinic_pet_by_owner;
select * from petclinic_reference_lists;
✅ Step 7: Exit CQL Shell.
exit
Proceed to the Step V
Got questions? Ask us using discord chat or a community forum!