Skip to content

Latest commit

 

History

History
120 lines (95 loc) · 5 KB

File metadata and controls

120 lines (95 loc) · 5 KB

Prerequisites

  1. Install necessary tools: azure cli, Jdk(8 is recommended) maven, docker, docker-compose, kompose, kubectl
  2. Create a AKS using the following scripts:
az login
az account set --subscription <your-subscription-guid>
az aks create  --resource-group <your-resource-group> --name <your-kubernetes-name> --enable-addons http_application_routing
  1. Install the docker on your local machine: https://gist.github.com/rstacruz/297fc799f094f55d062b982f7dac9e41

Steps

  1. Clone the code
git clone https://github.com/sqshq/PiggyMetrics
  1. Build the code
cd PiggyMetrics
mvn package -DskipTests
  1. Build the image Modify the docker-compose.dev.yml file at the root folder, remove rabbitmq service and add images for each service, see the modified docker-compose.dev.yml at this forked repo. Run the following command to build the docker image locally:
docker-compose -f docker-compose.dev.yml build
  1. Publish the images, Login Docker hub using docker login, input your Docker hub username and password.
docker push <Your Docker hub username>/piggymetrics-config
docker push <Your Docker hub username>/piggymetrics-registry
docker push <Your Docker hub username>/piggymetrics-gateway
docker push <Your Docker hub username>/piggymetrics-auth-service
docker push <Your Docker hub username>/piggymetrics-account-service
docker push <Your Docker hub username>/piggymetrics-statistics-service
docker push <Your Docker hub username>/piggymetrics-notification-service
docker push <Your Docker hub username>/piggymetrics-mongodb
docker push <Your Docker hub username>/piggymetrics-monitoring
docker push <Your Docker hub username>/piggymetrics-turbine-stream-service
  1. Modify docker-compose.yml at root folder, replace sqshq/ with <Your Docker hub username>/ to use your own images, then change the version in docker-compose.yml to '2', replace the unsupported statement
  depends_on:
      config:
        condition: service_healthy

to

  depends_on:
      - config 

Add the ports from docker-compose.dev.yml and change the port number the same as the the second port, eg: from 26000:27017 to 27017:27017

see the modified docker-compose.yml at this forked repo.

  1. Convert the docker-compose.yml into kubernetes manifest files using kompose
export CONFIG_SERVICE_PASSWORD=root
export NOTIFICATION_SERVICE_PASSWORD=root
export STATISTICS_SERVICE_PASSWORD=root
export ACCOUNT_SERVICE_PASSWORD=root
export MONGODB_PASSWORD=root 
mkdir piggymetrics && kompose convert -f docker-compose.yml -o piggymetrics
  1. start mongodb, RabbitMQ
kubectl apply -f ./piggymetrics/auth-mongodb-deployment.yaml -f ./piggymetrics/auth-mongodb-service.yaml
kubectl apply -f ./piggymetrics/account-mongodb-deployment.yaml -f ./piggymetrics/account-mongodb-service.yaml
kubectl apply -f ./piggymetrics/statistics-mongodb-deployment.yaml -f ./piggymetrics/statistics-mongodb-service.yaml
kubectl apply -f ./piggymetrics/notification-mongodb-deployment.yaml -f ./piggymetrics/notification-mongodb-service.yaml
kubectl apply -f ./piggymetrics/rabbitmq-deployment.yaml -f ./piggymetrics/rabbitmq-service.yaml
  1. start config-service.
kubectl apply -f ./piggymetrics/config-deployment.yaml -f ./piggymetrics/config-service.yaml
  1. start registry-service
kubectl apply -f ./piggymetrics/registry-deployment.yaml -f ./piggymetrics/registry-service.yaml
  1. start other services
kubectl apply -f ./piggymetrics/gateway-deployment.yaml -f ./piggymetrics/gateway-service.yaml
kubectl apply -f ./piggymetrics/auth-service-deployment.yaml -f ./piggymetrics/auth-service-service.yaml
kubectl apply -f ./piggymetrics/account-service-deployment.yaml -f ./piggymetrics/account-service-service.yaml
kubectl apply -f ./piggymetrics/statistics-service-deployment.yaml -f ./piggymetrics/statistics-service-service.yaml
kubectl apply -f ./piggymetrics/notification-service-deployment.yaml -f ./piggymetrics/notification-service-service.yaml
kubectl apply -f ./piggymetrics/monitoring-deployment.yaml -f ./piggymetrics/monitoring-service.yaml
kubectl apply -f ./piggymetrics/turbine-stream-service-deployment.yaml -f ./piggymetrics/turbine-stream-service-service.yaml
  1. enable public access, first get the DNS zone name for the AKS cluster(in this step, you need http_application_routing to be enabled on your aks, see https://docs.microsoft.com/en-us/azure/aks/http-application-routing for details), using the following script to get the the DNS zone name.
az aks show --resource-group <your-resource-group> --name <your-kubernetes-name> --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o table
  1. replace CLUSTER_SPECIFIC_DNS_ZONE in ingress.yaml with the DNS zone name get from previous step, and then create the ingress:
kubectl apply -f ingress.yaml
  1. wait sometime for the dns to be applied, then the navigate to the url defined in spec.rules.host field of ingress.yaml.