Skip to content

Instantly share code, notes, and snippets.

@Pan-Maciek
Last active September 14, 2022 22:03
Show Gist options
  • Save Pan-Maciek/f075cb645b15e5136b901a0cc1c57ae3 to your computer and use it in GitHub Desktop.
Save Pan-Maciek/f075cb645b15e5136b901a0cc1c57ae3 to your computer and use it in GitHub Desktop.
Env:
  Ubuntu: 22.04
  Node: v16.17.0
  Npm: 8.15.0
  Java: openjdk 11.0.16
  Git: 2.34.1
  Docker: 20.10.12

Step 1:

Make sure to have node, npm, git, docker, jdk installed on the system. Node must be recent version. Avoid node from snap, it breaks things.

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs git docker.io docker openjdk-11-jdk

Install jhipster

npm install -g generator-jhipster

Step 2:

Setup cluster

Cluster:
  Desired: 3
  Minimum: 3
  Maximum: 5
  Node: t3.medium

Install istio on the cluster, connect kubectl.

curl -sL https://istio.io/downloadIstioctl | sh -
export PATH=$HOME/.istioctl/bin:$PATH

Apply istio sample addons.

kubectl apply -f samples/addons/grafana.yaml
kubectl apply -f samples/addons/prometheus.yaml
kubectl apply -f samples/addons/kiali.yaml
kubectl apply -f samples/addons/extras/zipkin.yaml

Step 3:

Copy jdl file. Modify deployment section at the end of jdl file. Change dockerRepositoryName and ingressDomain.

Generate project using:

jhipster import-jdl *.jdl

There might be some errors regarding, but they might be ignored.

Error executing './npmw install', execute it yourself. (Command failed with exit code 1: ./npmw install)

Step 4:

Generate images Go to store, invoice, notifictaion, product and run

./gradlew bootJar -Pprod jibDockerBuild 

in each of them.

Step 5:

Tag and publish docker images:

$dockerRepositoryName = ""
docker image tag store $dockerRepositoryName/store
docker push $dockerRepositoryName/store
docker image tag invoice $dockerRepositoryName/invoice
docker push $dockerRepositoryName/invoice
docker image tag notification $dockerRepositoryName/notification
docker push $dockerRepositoryName/notification
docker image tag product $dockerRepositoryName/product
docker push $dockerRepositoryName/product

Step 6:

Go to kubernetes and apply configuration

bash kubectl-apply.sh -f
kubectl get svc store -n jhipster
application {
config {
baseName store
applicationType gateway
packageName com.jhipster.demo.store
serviceDiscoveryType no
authenticationType jwt
prodDatabaseType mysql
cacheProvider hazelcast
buildTool gradle
clientFramework react
}
entities *
}
application {
config {
baseName product
applicationType microservice
packageName com.jhipster.demo.product
serviceDiscoveryType no
authenticationType jwt
prodDatabaseType mysql
cacheProvider hazelcast
buildTool gradle
serverPort 8081
}
entities Product, ProductCategory, ProductOrder, OrderItem
}
application {
config {
baseName invoice
applicationType microservice
packageName com.jhipster.demo.invoice
serviceDiscoveryType no
authenticationType jwt
prodDatabaseType mysql
buildTool gradle
serverPort 8082
}
entities Invoice, Shipment
}
application {
config {
baseName notification
applicationType microservice
packageName com.jhipster.demo.notification
serviceDiscoveryType no
authenticationType jwt
databaseType mongodb
cacheProvider no
enableHibernateCache false
buildTool gradle
serverPort 8083
}
entities Notification
}
/**
* Entities for Store Gateway
*/
// Customer for the store
entity Customer {
firstName String required
lastName String required
gender Gender required
email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
phone String required
addressLine1 String required
addressLine2 String
city String required
country String required
}
enum Gender {
MALE, FEMALE, OTHER
}
relationship OneToOne {
Customer{user(login) required} to User
}
service Customer with serviceClass
paginate Customer with pagination
/**
* Entities for product microservice
*/
// Product sold by the Online store
entity Product {
name String required
description String
price BigDecimal required min(0)
productSize ProductSize required
image ImageBlob
}
enum ProductSize {
S, M, L, XL, XXL
}
entity ProductCategory {
name String required
description String
}
entity ProductOrder {
placedDate Instant required
status OrderStatus required
code String required
invoiceId Long
customer String required
}
enum OrderStatus {
COMPLETED, PENDING, CANCELLED
}
entity OrderItem {
quantity Integer required min(0)
totalPrice BigDecimal required min(0)
status OrderItemStatus required
}
enum OrderItemStatus {
AVAILABLE, OUT_OF_STOCK, BACK_ORDER
}
relationship ManyToOne {
OrderItem{product(name) required} to Product
}
relationship OneToMany {
ProductOrder{orderItem} to OrderItem{order(code) required} ,
ProductCategory{product} to Product{productCategory(name)}
}
service Product, ProductCategory, ProductOrder, OrderItem with serviceClass
paginate Product, ProductOrder, OrderItem with pagination
microservice Product, ProductOrder, ProductCategory, OrderItem with product
/**
* Entities for Invoice microservice
*/
// Invoice for sales
entity Invoice {
code String required
date Instant required
details String
status InvoiceStatus required
paymentMethod PaymentMethod required
paymentDate Instant required
paymentAmount BigDecimal required
}
enum InvoiceStatus {
PAID, ISSUED, CANCELLED
}
entity Shipment {
trackingCode String
date Instant required
details String
}
enum PaymentMethod {
CREDIT_CARD, CASH_ON_DELIVERY, PAYPAL
}
relationship OneToMany {
Invoice{shipment} to Shipment{invoice(code) required}
}
service Invoice, Shipment with serviceClass
paginate Invoice, Shipment with pagination
microservice Invoice, Shipment with invoice
/**
* Entities for notification microservice
*/
entity Notification {
date Instant required
details String
sentDate Instant required
format NotificationType required
userId Long required
productId Long required
}
enum NotificationType {
EMAIL, SMS, PARCEL
}
microservice Notification with notification
/**
* Deployments
*/
deployment {
deploymentType kubernetes
appsFolders [store, invoice, notification, product]
dockerRepositoryName "koziejka"
serviceDiscoveryType no
istio true
kubernetesServiceType Ingress
kubernetesNamespace jhipster
ingressType nginx
ingressDomain "34.231.116.38.nip.io"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment