Built using express js, message broker using rabbitmq and containerized by docker. Now in progess to implement with service mesh paradigm in kubernetes cluster.
git clone https://github.com/launathiel/microservice-online-shopping
cd microservice-online-shopping
docker-compose -f ./rabbitmq-docker.yml up -d
note that rabbitmq succesfully running, to avoid service error because rabbitmq, after 1 minute run command below;
docker-compose -f ./service-with-db-docker.yml up -d
curl -L https://istio.io/downloadIstio | sh -
chmod +x ./kubernetes/istio/istio-init.sh
./kubernetes/istio/istio-init.sh
kubectl get all -n istio-system
chmod +x ./kubernetes/rabbitmq/rabbitmq.sh
./kubernetes/rabbitmq/rabbitmq.sh
kubectl get all -o wide -n rabbitmq-system
kubectl get all -o wide -n rabbitmq
chmod +x ./kubernetes/customer/mongodb.sh
chmod +x ./kubernetes/customer/customer.sh
./kubernetes/customer/mongodb.sh
kubectl exec -ti -n customer mongod-customer-0 bash
# initiate replicaset
mongo --quiet <<EOF
rs.initiate({
_id : "MainRepSet",
version : 1,
members: [
{ _id: 0, host: "mongod-customer-0.mongodb-service.customer.svc.cluster.local:27017" },
{ _id: 1, host: "mongod-customer-1.mongodb-service.customer.svc.cluster.local:27017" }
]
});
EOF
# you can specify member of replicaset depend on your mongoDB sts' replica
# check
mongo --eval 'rs.status();'
# create user admin
mongo --quiet <<EOF
db.getSiblingDB("admin").createUser({
user : "customerdb",
pwd : "thisisasecret",
roles: [ { role: "root", db: "admin" } ]
});
EOF
exit
./kubernetes/customer/customer.sh
chmod +x ./kubernetes/products/mongodb.sh
chmod +x ./kubernetes/products/products.sh
./kubernetes/products/mongodb.sh
kubectl exec -ti -n products mongod-products-0 bash
# initiate replicaset
mongo --quiet <<EOF
rs.initiate({
_id : "MainRepSet",
version : 1,
members: [
{ _id: 0, host: "mongod-products-0.mongodb-service.products.svc.cluster.local:27017" },
{ _id: 1, host: "mongod-products-1.mongodb-service.products.svc.cluster.local:27017" }
]
});
EOF
# you can specify member of replicaset depend on your mongoDB sts' replica
# check
mongo --eval 'rs.status();'
# create user admin
mongo --quiet <<EOF
db.getSiblingDB("admin").createUser({
user : "productsdb",
pwd : "thisisasecret",
roles: [ { role: "root", db: "admin" } ]
});
EOF
exit
./kubernetes/products/products.sh
chmod +x ./kubernetes/shopping/mongodb.sh
chmod +x ./kubernetes/shopping/shopping.sh
./kubernetes/shopping/mongodb.sh
kubectl exec -ti -n shopping mongod-shopping-0 bash
# initiate replicaset
mongo --quiet <<EOF
rs.initiate({
_id : "MainRepSet",
version : 1,
members: [
{ _id: 0, host: "mongod-shopping-0.mongodb-service.shopping.svc.cluster.local:27017" },
{ _id: 1, host: "mongod-shopping-1.mongodb-service.shopping.svc.cluster.local:27017" }
]
});
EOF
# you can specify member of replicaset depend on your mongoDB sts' replica
# check
mongo --eval 'rs.status();'
# create user admin
mongo --quiet <<EOF
db.getSiblingDB("admin").createUser({
user : "shoppingdb",
pwd : "thisisasecret",
roles: [ { role: "root", db: "admin" } ]
});
EOF
exit
./kubernetes/shopping/shopping.sh
kubectl apply -n istio-system -f https://raw.githubusercontent.com/launathiel/microservice-online-shopping/main/kubernetes/istio/prometheus.yaml
kubectl apply -n istio-system -f https://raw.githubusercontent.com/launathiel/microservice-online-shopping/main/kubernetes/istio/grafana.yaml
kubectl apply -f https://raw.githubusercontent.com/launathiel/microservice-online-shopping/main/kubernetes/istio/kiali-crd.yaml
kubectl apply -n istio-system -f https://raw.githubusercontent.com/launathiel/microservice-online-shopping/main/kubernetes/istio/kiali.yaml
keep exploring!