Quarkus for Architects who Sometimes Write Code - Postman Setup
I have created a Postman collection for you to use in this exercise. If you don’t have postman, now is a good time to go get it: https://www.postman.com/downloads/
-
Once you have Postman installed, go ahead and start it.
-
Now, we’re going to import a Postman collection and an environment.
Postman collections allow you to create and save API calls and tests. An environment allows you to store variable configurations for the API calls and tests. There’s a lot more to it than that, but that’s what we’re going to need for this exercise.
-
From the main Postman screen, click on the
Import
button that is in the top left portion of the screen: -
You should now see the Import dialog. Select the
Link
option from the list at the top of the Import window. -
Past the following URL into the text box under
Enter a URL
, then clickContinue
:https://raw.githubusercontent.com/cgruver/k8ssandra-blog-resources/main/postman/BookCatalog-Quarkus-Demo.postman_collection.json
-
Click
Import
to import the collection: -
Repeat the above steps with the following URL to also import the Envrionment that I prepared for you:
https://raw.githubusercontent.com/cgruver/k8ssandra-blog-resources/main/postman/BookCatalog-Quarkus-Demo.postman_environment.json
-
Take some time to explore the collection
and environment
. You can access them via the left-hand vertical nav bar.
Add Credentials to Environment and Activate the Environment
-
Next, we need credentials to access Cassandra. We’re going to bypass creating additional users in Cassandra for this exercise and just use the super-user account that was automatically generated for us.
The auto-generated credentials are stored in a
secret
that is in thek8ssandra-operator
namespace. To retrieve it, first log into yourcrc
OpenShift instance:-
Open a terminal and set the
crc
environment:~ % eval $(crc oc-env)
-
Retireve the login command and credentials:
~ % crc console --credentials
You should see output similar to:
To login as a regular user, run 'oc login -u developer -p developer https://api.crc.testing:6443'. To login as an admin, run 'oc login -u kubeadmin -p 3QxJ6-P5Z2c-DD7as-zfmfI https://api.crc.testing:6443'
-
Copy the command to login as
kubeadmin
and run it:~ % oc login -u kubeadmin -p 3QxJ6-P5Z2c-DD7as-zfmfI https://api.crc.testing:6443
You should see output similar to:
Login successful. You have access to 68 projects, the list has been suppressed. You can list all projects with 'oc projects' Using project "default".
-
Now grab the contents of the secret created for the Cassandra credentials:
echo $(oc -n k8ssandra-operator get secret k8ssandra-cluster-superuser -o jsonpath="{.data.password}" | base64 -d)
Copy the resulting string into your clipboard. We’re going to add it to our Postman environment.
-
-
Add the cassandra super-user password to the Postman Environment:
Note: I know I don’t have to say this… but I’m going to anyway… You should NEVER put production credentials into your Postman environment. This is a development tool. While the values that we’re going to be using are not persisted, it’s still sitting there on your machine in plain text for the duration of your session.
OK, with that disclaimer out of the way, go ahead and open the Environment that I prepared for you:
Note that there are two columns of values for each key. The left column of values, called
INITIAL VALUE
, is persisted as part of the collection. Never put anything sensitive there. It will be saved in plain-text. The right hand column of values, calledCURRENT_VALUE
, is ephemeral. It lasts as long as your postman session, and can be dynamically changed by your Postman tests or scripts. We’ll see an example of that with the value forAUTH_TOKEN
token. I still wouldn’t put anything sensitive here, but that’s up to you. :-)Now, paste the value for the k8ssandra-cluster-superuser password in the row named
auth_password
. Paste it into theCURRENT VALUE
column. -
Finally, activate the environment for this session by clicking the checkbox next to
Book Catalog - Quarkus Demo ...
in the Environments list: