From 99a26507342df2c5f7f055025407fa0ee935a784 Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Mon, 24 Feb 2020 15:27:17 -0800 Subject: [PATCH] Added Web MVC deploy template and deploy pipeline --- .../webmvc-deploy-template.yml | 118 ++++++++++++++++++ deploy/aro/web-mvc/azure-pipelines.yml | 36 ++++++ 2 files changed, 154 insertions(+) create mode 100644 deploy/aro/openshift-templates/webmvc-deploy-template.yml create mode 100644 deploy/aro/web-mvc/azure-pipelines.yml diff --git a/deploy/aro/openshift-templates/webmvc-deploy-template.yml b/deploy/aro/openshift-templates/webmvc-deploy-template.yml new file mode 100644 index 000000000..9ecb521d1 --- /dev/null +++ b/deploy/aro/openshift-templates/webmvc-deploy-template.yml @@ -0,0 +1,118 @@ +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: IdentityUrl + value: ${IDENTITY_API_URL} + - name: PurchaseUrl + value: ${WEB_SHOPPING_API_GATEWAY_URL} + - name: MarketingUrl + value: ${MARKETING_API_URL} + - name: IdentityUrlHC + value: ${IDENTITY_API_HC_URL} + - name: SignalrHubUrl + value: ${ORDERING_SIGNALR_HUB_URL} + 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: webmvc +- 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: webmvc-deploy-template +- description: The cluster internal URL of the Identity endpoint + displayName: Identity URL + name: IDENTITY_API_URL + required: true +- description: The URL of the Web Shopping API Gateway endpoint + displayName: Web Shopping API Gateway URL + name: WEB_SHOPPING_API_GATEWAY_URL + required: true +- description: The cluster internal URL of the Marketing API endpoint + displayName: Marketing API URL + name: MARKETING_API_URL + required: true +- description: The health check URL of the Identity API service + displayName: Identity API Health Check URL + name: IDENTITY_API_HC_URL + required: true +- description: The cluster internal URL of the Ordering SignalR Hub endpoint + displayName: Ordering SignalR Hub URL + name: ORDERING_SIGNALR_HUB_URL + required: true \ No newline at end of file diff --git a/deploy/aro/web-mvc/azure-pipelines.yml b/deploy/aro/web-mvc/azure-pipelines.yml new file mode 100644 index 000000000..2c13edb7e --- /dev/null +++ b/deploy/aro/web-mvc/azure-pipelines.yml @@ -0,0 +1,36 @@ +variables: + OpenShiftServiceConnection: 'OpenShift on ARO' +trigger: + branches: + include: + - master + - dev + paths: + include: + - deploy/aro/web-mvc/* + - deploy/aro/openshift-templates/* +stages: + - stage: development + displayName: Development + variables: + OpenShiftProject: development + SourceImageRegistryProjectName: development + EnvironmentName: dev + jobs: + - job: WebMvcDeployment + displayName: 'Web MVC 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/webmvc-deploy-template.yml -p IMAGE_REGISTRY_PROJECT_NAME=$(SourceImageRegistryProjectName) -p IDENTITY_API_URL=$(IdentityApiUrl) -p WEB_SHOPPING_API_GATEWAY_URL=$(WebShoppingApiGatewayUrl) -p MARKETING_API_URL=$(MarketingApiUrl) -p IDENTITY_API_HC_URL=$(IdentityApiHc) -p ORDERING_SIGNALR_HUB_URL=$(OrderingSignalRHubUrl) | oc apply -f-' + failOnStderr: true + displayName: 'Ensure Web SPA OpenShift DeploymentConfig and Service' \ No newline at end of file