- Install necessary tools: azure cli, Jdk(8 is recommended) maven, docker, docker-compose, kompose, kubectl
- 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- Install the docker on your local machine:
https://gist.github.com/rstacruz/297fc799f094f55d062b982f7dac9e41
- Clone the code
git clone https://github.com/sqshq/PiggyMetrics- Build the code
cd PiggyMetrics
mvn package -DskipTests- Build the image
Modify the
docker-compose.dev.ymlfile at the root folder, removerabbitmqservice and add images for each service, see the modifieddocker-compose.dev.ymlat this forked repo. Run the following command to build the docker image locally:
docker-compose -f docker-compose.dev.yml build- 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- Modify
docker-compose.ymlat root folder, replacesqshq/with<Your Docker hub username>/to use your own images, then change the version indocker-compose.ymlto '2', replace the unsupported statement
depends_on:
config:
condition: service_healthyto
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.
- Convert the
docker-compose.ymlinto kubernetes manifest files usingkompose
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- 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
- start
config-service.
kubectl apply -f ./piggymetrics/config-deployment.yaml -f ./piggymetrics/config-service.yaml- start
registry-service
kubectl apply -f ./piggymetrics/registry-deployment.yaml -f ./piggymetrics/registry-service.yaml- 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- 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
- replace
CLUSTER_SPECIFIC_DNS_ZONEin ingress.yaml with the DNS zone name get from previous step, and then create the ingress:
kubectl apply -f ingress.yaml- wait sometime for the dns to be applied, then the navigate to the url defined in
spec.rules.hostfield ofingress.yaml.