Contents:
Following are the steps I used to install cassandra db on my macbook.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The output if the installation looks like this:
Run the commands in the last line of the ouput to set homebrew to the PATH. In this case:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/shantanushinde/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew install openjdk@11
Determine which shell profile file you are using. Common shell profile files are ~/.bash_profile for Bash, ~/.zshrc for Zsh, and ~/.bashrc for Bash (on some systems). In my case it was ~/.zshrc. Run the following command to open the shell profile file using a text editor (replace ~/.zshrc with the appropriate file if you're using a different shell):
open -a TextEdit ~/.zshrc
Add the following lines at the end of the file:
export JAVA_HOME="/usr/local/opt/openjdk@11"
export PATH="$JAVA_HOME/bin:$PATH"
These lines set the JAVA_HOME environment variable to the OpenJDK 11 installation path and add it to the PATH variable. Save the file and close the text editor. To apply the changes, run the following command in the Terminal:
source ~/.zshrc
To install Cassandra run:
brew install cassandra
To start cassandra and restart at login run:
brew services start cassandra
Check installation using the following command:
brew services list
It should show an output similar to:
Alternatively, to check installation you can also run:
cqlsh
This should open up the CQL shell.
Launch the CQL shell using:
cqlsh
Create the customerDB keyspace:
CREATE KEYSPACE customerDB WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
If you want to deploy Cassandra DB on Minikube instead of running it locally, checkout this link. Not implemented here as my local machine ran out of memory!!!.
Follwing steps are for setting up Solace for JMS messaging to a loggingQueue
You need have Docker installed. Installation can be found here. Install Minikube.
Clone the GitHub repository containing the Docker Compose template.
git clone https://github.com/SolaceLabs/solace-single-docker-compose.git
cd solace-single-docker-compose/template
This step is optional and is mostly required in development as the default port for spring boot apllication is 8080. The JMS solace application also used the 8080 port for it's SEMP/PubSub+ Manager. In order to do this, open the template/PubSubStandard_singleNode.yml file in the cloned repository and change the line:
...
#SEMP / PubSub+ Manager
- '8080:8080'
...
to:
...
#SEMP / PubSub+ Manager
- '8081:8080'
...
Run the following command to create a PubSub+ software event broker using the Compose template:
docker-compose -f PubSubStandard_singleNode.yml up -d
To start issuing configuration or monitoring commands on the event broker, you can access Broker Manager or the Solace CLI. To access PubSub+ Broker Manager:
- Open a browser and enter http://localhost:8080. (8081 if you changed it)
- Log in as user admin with password admin.
In Messaging -> Message VPNs
select + Message VPN
and fill out the following:
The select Set up Default User ->
and set admin as username and password then press Create
.
Open the CustomerApplicationMessages. Got to System -> Uset Mgmt -> Users
and add a user with admin as password and user name with all accesses granted if not already present.
Go to Messaging -> Queues
and Select + Queue
. Give it a name loggingQueue and add admin as owner.
To check out how Solace queues work open Messaging -> Try Me!
. Also refer this.
Follwing steps can be used to deploy a Spring Boot application on Minikube capable of querying a locally hosted cassandra db and a Solace queue.
You need have Docker installed. Installation can be found here. Install Minikube.
Start your cluster using:
minikube start --driver=docker
Here's how the output looks:
Check the status using:
minikube status
It should display something close to the following:
Run the following command to retreive the ip address of the Docker host machine:
minikube ssh -- cat /etc/hosts | grep host.minikube.internal | awk '{print $1}'
Use the ip address return in the above command to configure the Spring Boot Application. In the src/main/resources/application.properties file apdate the following properties:
# Cassandra Connection Configuration
cassandra.contactPoints=<enter docker host ip>
...
#Solace Connection Configuration
solace.host=<enter docker host ip>
...
Run mvn clean install
in the spring project to generate the jar files.
In case mvn clean install
does not work, you need to skip tests using the command:
mvn clean install -DskipTests
Run the following command to list the Docker images present in your local Docker environment:
docker images
In my case I get the following output:
Minikube comes with a docker daemon preinstalled on it. So the Minikube cluster is running on a Docker virtual machine and a Docker version is installed on this minikube cluster. In order to deploy the Spring boot application docker we need to perform the following steps:
minikube docker-env
This will give an output similar to the following:
Run the command in the last line of this output to activate the docker commands on the minikube cluster. For eg; in this case:
eval $(minikube -p minikube docker-env)
Now if run docker images
again, we will see the docker images present in the minikube environment. For eg;
A change in output here represents that the previous commands worked.
cd
into the demoCustomer folder which has the Dockerfile and run the following command to build the docker image on minikube:
docker build -t springstarterproject:1.0 .
Here's how the output looks:
Now if we run docker images
we see that springstarterproject is added with tag 1.0:
Next we need to create a deployment on kubernetes using the kubectl
commands.
kubectl create deployment springstarterproject-dep --image=springstarterproject:1.0 --port=8080
Now if we run:
kubectl get all
we see that a pod and a deployment is created with springstarterproject in their names:
Inorder to check if the pod is running properly, run:
kubectl logs <pod_name>
In my case it was:
kubectl logs springstarterproject-dep-6f897d5f46-qlf6c
The output should look like the following with Started DemoCustomerApplication displayed:
Now we need to create a service for the deployment using:
kubectl expose deployment springstarterproject-dep --port=8080 --type=NodePort --name=springstarterproject-service
Now if we run kubectl get all
we see that springstarterproject-service is added in services:
Now that we have created a service, we can retrive the url for the service using:
minikube service springstarterproject-service --url
The displayed url is the host and port that we can query using postman or a web browser to run our microservices.
Inorder to access Swagger-UI after deploying on Minikube use the url returned by the baove command followed by swagger-ui.html. Use the follwowing format:
http://localhost:<port>/swagger-ui.html
Stuff left to do on this project:
- Develop small UI page to capture that form data from frontend
- Integrate UI with backend
- Deploy UI into minikube
- Make documentation conataining:
- Overall architecture diagram showing front end and backend components
- Physical architecture
- Sequence diagram
- Technical documentation