From d4dfa7d0240a5d77b9f26ba80b67dafcb0926c7b Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Sun, 23 Feb 2020 11:23:01 -0800 Subject: [PATCH] Added mobile shopping aggregator deploy template and pipeline --- .../aro/azure-devops-templates/variables.yml | 8 + .../aro/mobileshoppingagg/azure-pipelines.yml | 35 ++++ .../mobileshoppingagg-deploy-template.yml | 178 ++++++++++++++++++ 3 files changed, 221 insertions(+) create mode 100644 deploy/aro/mobileshoppingagg/azure-pipelines.yml create mode 100644 deploy/aro/openshift-templates/mobileshoppingagg-deploy-template.yml diff --git a/deploy/aro/azure-devops-templates/variables.yml b/deploy/aro/azure-devops-templates/variables.yml index 04b5531d8..f04066aa4 100644 --- a/deploy/aro/azure-devops-templates/variables.yml +++ b/deploy/aro/azure-devops-templates/variables.yml @@ -8,11 +8,14 @@ variables: IdentityPublicHostName: identity$(EnvironmentName) IdentityUrlExternal: https://$(IdentityPublicHostName) IdentityApiUrl: http://$(IdentityApiHostName):8080 + IdentityApiHc: $(IdentityApiUrl)/hc BasketApiHostName: basketapi.$(OpenShiftProject).svc BasketApiUrl: http://$(BasketApiHostName):8080 + BasketApiGrpcUrl: http://$(BasketApiHostName):8081 BasketApiHc: $(BasketApiUrl)/hc CatalogApiHostName: catalogapi.$(OpenShiftProject).svc CatalogApiUrl: http://$(CatalogApiHostName):8080 + CatalogApiGrpcUrl: http://$(CatalogApiHostName):8081 CatalogApiUrlExternal: https://$(CatalogPublicHostName) CatalogApiHc: $(CatalogApiUrl)/hc PicBaseUrl: $(CatalogApiUrlExternal)/api/v1/catalog/items/[0]/pic/ @@ -27,7 +30,12 @@ variables: MarketingDbName: MarketingDb OrderingApiHostName: orderingapi.$(OpenShiftProject).svc OrderingApiUrl: http://$(OrderingApiHostName):8080 + OrderingApiGrpcUrl: http://$(OrderingApiHostName):8081 OrderingApiHc: $(OrderingApiUrl)/hc + PaymentApiHostName: paymentapi.$(OpenShiftProject).svc + PaymentApiUrl: http://$(PaymentApiHostName):8080 + PaymentApiGrpcUrl: http://$(PaymentApiHostName):8081 + PaymentApiHc: $(PaymentApiUrl)/hc MobileShoppingAggregatorHostName: mobileshoppingaggregator.$(OpenShiftProject).svc MobileShoppingAggregatorUrl: http://$(MobileShoppingAggregatorHostName):8080 MobileShoppingAggregatorHc: $(MobileShoppingAggregatorUrl)/hc diff --git a/deploy/aro/mobileshoppingagg/azure-pipelines.yml b/deploy/aro/mobileshoppingagg/azure-pipelines.yml new file mode 100644 index 000000000..14b5fd617 --- /dev/null +++ b/deploy/aro/mobileshoppingagg/azure-pipelines.yml @@ -0,0 +1,35 @@ +variables: + OpenShiftServiceConnection: 'OpenShift on ARO' +trigger: + branches: + include: + - master + - dev + paths: + include: + - deploy/aro/mobileshoppingagg/* + - deploy/aro/openshift-templates/* +stages: + - stage: development + displayName: Development + variables: + OpenShiftProject: development + SourceImageRegistryProjectName: development + jobs: + - job: MobileShoppingAggregatorDeployment + displayName: 'Mobile Shopping Aggregator Deployment' + variables: + - template: ../azure-devops-templates/variables.yml + pool: + vmImage: 'windows-latest' + steps: + - task: redhat.openshift-vsts.oc-setup-task.oc-setup@2 + displayName: 'Setup Openshift CLI' + inputs: + openshiftService: $(OpenShiftServiceConnection) + - script: 'oc project $(OpenShiftProject)' + failOnStderr: true + displayName: 'Set OpenShift Project Context' + - script: 'oc process -f ./deploy/aro/openshift-templates/mobileshoppingagg-deploy-template.yml -p IMAGE_REGISTRY_PROJECT_NAME=$(SourceImageRegistryProjectName) -p BASKET_API_URL=$(MongoConnectionString) -p CATALOG_API_URL=$(CatalogApiUrl) -p ORDERING_API_URL=$(OrderingApiUrl) -p IDENTITY_API_URL=$(IdentityApiUrl) -p BASKET_API_GRPC_URL=$(BasketApiGrpcUrl) -p CATALOG_API_GRPC_URL=$(CatalogApiGrpcUrl) -p ORDERING_API_GRPC_URL=$(OrderingApiGrpcUrl) -p CATALOG_API_HC_URL=$(CatalogApiHc) -p ORDERING_API_HC_URL=$(OrderingApiGrpcUrl) -p IDENTITY_API_HC_URL=$(IdentityApiHc) -p BASKET_API_HC_URL=$(BasketApiHc) -p MARKETING_API_HC_URL=$(MarketingApiHc) -p PAYMENT_API_HC_URL=$(PaymentApiHc) -p LOCATION_API_HC_URL=$(LocationsApiHc) -p IDENTITY_URL_EXTERNAL=$(IdentityUrlExternal) | oc apply -f-' + failOnStderr: true + displayName: 'Ensure Mobile Shopping Aggregator OpenShift DeploymentConfig and Service' \ No newline at end of file diff --git a/deploy/aro/openshift-templates/mobileshoppingagg-deploy-template.yml b/deploy/aro/openshift-templates/mobileshoppingagg-deploy-template.yml new file mode 100644 index 000000000..e8a409422 --- /dev/null +++ b/deploy/aro/openshift-templates/mobileshoppingagg-deploy-template.yml @@ -0,0 +1,178 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: ${TEMPLATE_NAME} +objects: +- apiVersion: apps.openshift.io/v1 + kind: DeploymentConfig + metadata: + labels: + app: ${APPLICATION_NAME} + template: ${TEMPLATE_NAME} + name: ${APPLICATION_NAME} + spec: + replicas: 1 + selector: + app: ${APPLICATION_NAME} + deploymentconfig: ${APPLICATION_NAME} + strategy: + type: Rolling + revisionHistoryLimit: 2 + template: + metadata: + labels: + app: ${APPLICATION_NAME} + deploymentconfig: ${APPLICATION_NAME} + spec: + containers: + - env: + - name: urls__basket + value: ${BASKET_API_URL} + - name: urls__catalog + value: ${CATALOG_API_URL} + - name: urls__orders + value: ${ORDERING_API_URL} + - name: urls__identity + value: ${IDENTITY_API_URL} + - name: urls__grpcBasket + value: ${BASKET_API_GRPC_URL} + - name: urls__grpcCatalog + value: ${CATALOG_API_GRPC_URL} + - name: urls__grpcOrdering + value: ${ORDERING_API_GRPC_URL} + - name: CatalogUrlHC + value: ${CATALOG_API_HC_URL} + - name: OrderingUrlHC + value: ${ORDERING_API_HC_URL} + - name: IdentityUrlHC + value: ${IDENTITY_API_HC_URL} + - name: BasketUrlHC + value: ${BASKET_API_HC_URL} + - name: MarketingUrlHC + value: ${MARKETING_API_HC_URL} + - name: PaymentUrlHC + value: ${PAYMENT_API_HC_URL} + - name: LocationUrlHC + value: ${LOCATION_API_HC_URL} + - name: IdentityUrlExternal + value: ${IDENTITY_URL_EXTERNAL} + image: docker-registry.default.svc:5000/${IMAGE_REGISTRY_PROJECT_NAME}/${APPLICATION_NAME}:latest + imagePullPolicy: Always + name: ${APPLICATION_NAME} + ports: + - containerPort: 8080 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + triggers: + - type: ConfigChange + - imageChangeParams: + automatic: true + containerNames: + - ${APPLICATION_NAME} + from: + kind: ImageStreamTag + name: ${APPLICATION_NAME}:latest + namespace: ${IMAGE_REGISTRY_PROJECT_NAME} + type: ImageChange +- apiVersion: v1 + kind: Service + metadata: + labels: + app: ${APPLICATION_NAME} + template: ${TEMPLATE_NAME} + name: ${APPLICATION_NAME} + spec: + ports: + - name: 8080-tcp + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: ${APPLICATION_NAME} + deploymentconfig: ${APPLICATION_NAME} + sessionAffinity: None + type: ClusterIP + status: + loadBalancer: {} +parameters: +- description: The name for the application. + displayName: Application Name + name: APPLICATION_NAME + required: true + value: mobileshoppingagg +- description: The OpenShift project name that is hosting the image registry. + displayName: Image Registry Project Name + name: IMAGE_REGISTRY_PROJECT_NAME + required: true +- description: The template name. + displayName: Template Name + name: TEMPLATE_NAME + required: true + value: mobileshoppingagg-deploy-template +- description: The cluster internal URL of the Basket API endpoint + displayName: Basket API URL + name: BASKET_API_URL + required: true +- description: The cluster internal URL of the Catalog API endpoint + displayName: Catalog API URL + name: CATALOG_API_URL + required: true +- description: The cluster internal URL of the Ordering API endpoint + displayName: Ordering API URL + name: ORDERING_API_URL + required: true +- description: The cluster internal URL of the Identity API endpoint + displayName: Identity API URL + name: IDENTITY_API_URL + required: true +- description: The cluster internal URL of the GRPC Basket API endpoint + displayName: Basket API GROC URL + name: BASKET_API_GRPC_URL + required: true +- description: The cluster internal URL of the GRPC Catalog API endpoint + displayName: Catalog API GRPC URL + name: CATALOG_API_GRPC_URL + required: true +- description: The cluster internal URL of the GRPC Ordering API endpoint + displayName: Ordering API GRPC URL + name: ORDERING_API_GRPC_URL + required: true +- description: The cluster internal URL of the Catalog API Health Check endpoint + displayName: Catalog API Health Check URL + name: CATALOG_API_HC_URL + required: true +- description: The cluster internal URL of the Ordering API Health Check endpoint + displayName: Ordering API Health Check URL + name: ORDERING_API_HC_URL + required: true +- description: The cluster internal URL of the Identity API Health Check endpoint + displayName: Identity API Health Check URL + name: IDENTITY_API_HC_URL + required: true +- description: The cluster internal URL of the Basket API Health Check endpoint + displayName: Basket API Health Check URL + name: BASKET_API_HC_URL + required: true +- description: The cluster internal URL of the Marketing API Health Check endpoint + displayName: Marketing API Health Check URL + name: MARKETING_API_HC_URL + required: true +- description: The cluster internal URL of the Payment API Health Check endpoint + displayName: Payment API Health Check URL + name: PAYMENT_API_HC_URL + required: true +- description: The cluster internal URL of the Location API Health Check endpoint + displayName: Location API Health Check URL + name: LOCATION_API_HC_URL + required: true +- description: The external URL of the Identity endpoint + displayName: Identity URL External + name: IDENTITY_URL_EXTERNAL + required: true \ No newline at end of file