Installing and Running Mashery Local for Docker on GCP
Procedure
-
Download and extract Mashery Local Docker edition. Load the following images in local Docker host, if it is not loaded:
docker load -i ml-core.tar.gz docker load -i ml-db.tar.gz docker load -i ml-mem.tar.gz
-
Upload the Docker Images to the GCP Container Registry.
-
In order to deploy Mashery Local to your Kubernetes cluster on GCP, you will need to upload the images to your GCP Container Registry. The registry console is available at
https://cloud.google.com/container-registry. The ML Docker images need to be tagged first before they can be uploaded to the registry.
Use the following command to tag them:
docker tag [IMAGE] [HOSTNAME]/[PROJECT-ID]/[IMAGE]
For example:docker tag ml-core:v4.1.1.0 us.gcr.io/[PROJECT-ID]/ml-core:v4.1.1.0 docker tag ml-mem:v4.1.1.0 us.gcr.io/[PROJECT-ID]/ml-mem:v4.1.1.0 docker tag ml-db:v4.1.1.0 us.gcr.io/[PROJECT-ID]/ml-db:v4.1.1.0
Upload the images using the gcloud docker push command:gcloud docker -- push us.gcr.io/[PROJECT-ID]/ml-core gcloud docker -- push us.gcr.io/[PROJECT-ID]/ml-mem gcloud docker -- push us.gcr.io/[PROJECT-ID]/ml-db
-
Once the push commands complete, the new images should be listed in the
Container Registry console.
You can also verify the pushed images using the gcloud container images command, for example:gcloud container images list-tags us.gcr.io/[PROJECT-ID]/ml-core DIGEST TAGS TIMESTAMP b20b0700bf3a v4.1.1.0 2017-08-03T22:33:02
-
With the Docker images in the container registry, you can inspect the images in the
Container Registry console.
-
In order to deploy Mashery Local to your Kubernetes cluster on GCP, you will need to upload the images to your GCP Container Registry. The registry console is available at
https://cloud.google.com/container-registry. The ML Docker images need to be tagged first before they can be uploaded to the registry.
-
Go to the folder
<Absolute path>/TIB_mash-local_<ML-version>_docker/examples/googleCloudPlatform/kubernetes in the extracted directory and perform the following steps:
-
Modify the
gcp-env.sh as per requirement and environment. This is the place to customize your deployment such as image version, docker image registry, persistent volume size, etc. All the scripts afterwards should be executed from the same terminal.
source gcp-env.sh
-
Execute the following script to store the Docker registry key as Kubernetes "Secret":
./set-registry-key.sh Sample o/p: secret "mlregistrykey" created
-
Execute the following script to store MOM host and key as Kubernetes "Secret":
set-mom-secret.sh create <MOM key> <MOM secret> <MOM Host>
For example:./set-mom-secret.sh create 7uy26rr6z936hfnsw3jes8ap cu4ChaHt2h mom.api.mca-mom.mashspud.com Sample o/p: secret "mlmomsecret" created
-
Create storage classes for Mashery Local for Docker persistent stores:
./set-storage-classes.sh Sample o/p: storageclass "mldb-storage" created storageclass "mldata-storage" created
-
Create Mashery Local Traffic Manager service and Mashery Local Master service:
./set-ml-services.sh Sample o/p: service "ml-traffic-manager" created service "ml-master" created
-
Check the services with the following commands:
kubectl describe service ml-traffic-manager
kubectl describe service ml-master
-
Deploy Mashery Local Master instance:
./deploy-master.sh Sample o/p: persistentvolumeclaim "mldb-master-pvc" created persistentvolumeclaim "mldata-master-pvc" created deployment "ml-master" created
You can check the ML instance pods with the command:kubectl get pods
For example:kubectl get pods NAME READY STATUS RESTARTS AGE ml-master-2132837488-vrx1n 4/4 Running 0 3m
To find the ML master instance node public IP with the following command:kubectl describe node `kubectl get pods -o wide |grep ml-master |awk -F' ' '{print $7}'` |grep ExternalIP |cut -d "," -f 3
-
Deploy slaves using the following command:
deploy-slaves.sh
For example:./deploy-slaves.sh service "ml-slave" created statefulset "ml-slave" created
Check Master and Slave status:kubectl get pods Sample o/p: NAME READY STATUS RESTARTS AGE ml-master-2132837488-vrx1n 4/4 Running 0 11m ml-slave-0 4/4 Running 0 7m ml-slave-1 4/4 Running 0 4m
-
If everything works properly, you should have a fully deployed cluster with one Master and two Slaves.
-
Access the Mashery Local UI. To access the Mashery Local UI, open the port 5480 on nodes in GCP. Navigate to the
Firewall rules section in the Google Cloud Platform and add an entry as below. This will enable UI on all nodes. You can also create a specific rule node.
To find the LB IP address:export LB=`kubectl describe service ml-traffic-manager|grep Ingress|awk -F' ' '{print $3}'` && echo $LB 35.230.36.250
To make a traffic call through the LB:curl -v -H 'Host:chainsproxy.api.mca.mashspud.com' 'http://35.230.36.250/v1/api/patient/1234/qatest/testRequestInfo.php?api_key=3bvu8u3p8k5vjxmhrs6tnd6e' * Trying 35.230.36.250... * TCP_NODELAY set * Connected to 35.230.36.250 (35.230.36.250) port 80 (#0) > GET /v1/api/patient/1234/qatest/testRequestInfo.php?api_key=3bvu8u3p8k5vjxmhrs6tnd6e HTTP/1.1 > Host:chainsproxy.api.mca.mashspud.com > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 200 OK < X-Mashery-Responder: ml-slave-0 < Content-Type: text/plain; charset=UTF-8 < Date: Thu, 22 Feb 2018 16:11:56 GMT < X-Powered-By: PHP/5.3.3 < Content-Length: 642 < TIME NOW: 2018-02-22 08:11:56 ================================ Server Script: /internal/patients/1234/info/qatest/testRequestInfo.php Query params: api_key=3bvu8u3p8k5vjxmhrs6tnd6e Request Method: GET Request Protocol: HTTP/1.1 Requested URI: /internal/patients/1234/info/qatest/testRequestInfo.php?api_key=3bvu8u3p8k5vjxmhrs6tnd6e REQUEST HEADERS: Array ( [host] => content.mock.mashery.com [Accept] => */* [User-Agent] => Mashery Proxy [X-Original-User-Agent] => curl/7.54.0 [X-Forwarded-For] => 10.138.0.2, 35.230.118.130 [X-Forwarded-Port] => 80 [X-Forwarded-Proto] => http [Connection] => keep-alive ) * Connection #0 to host 35.230.36.250 left intact
-
Modify the
gcp-env.sh as per requirement and environment. This is the place to customize your deployment such as image version, docker image registry, persistent volume size, etc. All the scripts afterwards should be executed from the same terminal.
Copyright © Cloud Software Group, Inc. All rights reserved.