diff --git a/deploy/aro/azure-devops-templates/variables.yml b/deploy/aro/azure-devops-templates/variables.yml index 3a3c86277..20cf3409f 100644 --- a/deploy/aro/azure-devops-templates/variables.yml +++ b/deploy/aro/azure-devops-templates/variables.yml @@ -2,6 +2,7 @@ variables: RedisHostname: redis.$(OpenShiftProject).svc RabbitMqHostname: rabbitmq.$(OpenShiftProject).svc SqlHostName: mssql-server-linux.$(OpenShiftProject).svc + MongoConnectionString: mongodb://mongo.$(OpenShiftProjectName).svc PublicHostName: eshop$(EnvironmentName) IdentityApiHostName: identityapi.$(OpenShiftProject).svc IdentityPublicHostName: identity$(EnvironmentName) @@ -18,9 +19,11 @@ variables: LocationsApiHostName: locationsapi.$(OpenShiftProject).svc LocationsApiUrl: http://$(LocationsApiHostName):8080 LocationsApiHc: $(LocationsApiUrl)/hc + CampaignDetailFunctionUri: MarketingApiHostName: marketingapi.$(OpenShiftProject).svc MarketingApiUrl: http://$(MarketingApiHostName):8080 MarketingApiHc: $(MarketingApiUrl)/hc + MarketingDbName: MarketingDb OrderingApiHostName: orderingapi.$(OpenShiftProject).svc OrderingApiUrl: http://$(OrderingApiHostName):8080 OrderingApiHc: $(OrderingApiUrl)/hc diff --git a/deploy/aro/marketing-api/azure-pipelines.yml b/deploy/aro/marketing-api/azure-pipelines.yml new file mode 100644 index 000000000..d70443bb0 --- /dev/null +++ b/deploy/aro/marketing-api/azure-pipelines.yml @@ -0,0 +1,36 @@ +variables: + OpenShiftServiceConnection: 'OpenShift on ARO' +trigger: + branches: + include: + - master + - dev + paths: + include: + - deploy/aro/marketing-api/* + - deploy/aro/openshift-templates/* +stages: + - stage: development + displayName: Development + variables: + OpenShiftProject: development + SourceImageRegistryProjectName: development + EnvironmentName: dev + jobs: + - job: MarketingApiDeployment + displayName: 'Marketing API 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/marketingapi-deploy-template.yml -p IMAGE_REGISTRY_PROJECT_NAME=$(SourceImageRegistryProjectName) -p MONGO_DB_CONNECTION_STRING=$(MongoConnectionString) -p MARKETING_DB_NAME=$(MarketingDbName) -p RABBITMQ_HOSTNAME=$(RabbitMqHostname) -p IDENTITY_URL=$(IdentityApiUrl) -p IDENTITY_URL_EXTERNAL=$(IdentityUrlExternal) -p PIC_BASE_URL=$(PicBaseUrl) | oc apply -f-' + failOnStderr: true + displayName: 'Ensure Marketing API OpenShift DeploymentConfig and Service' \ No newline at end of file diff --git a/deploy/aro/openshift-templates/marketingapi-deploy-template.yml b/deploy/aro/openshift-templates/marketingapi-deploy-template.yml new file mode 100644 index 000000000..06f8a5b3d --- /dev/null +++ b/deploy/aro/openshift-templates/marketingapi-deploy-template.yml @@ -0,0 +1,133 @@ +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: MongoConnectionString + value: ${MONGO_DB_CONNECTION_STRING} + - name: MongoDatabase + value: ${MARKETING_DB_NAME} + - name: EventBusConnection + value: ${RABBITMQ_HOSTNAME} + - name: IdentityUrl + value: ${IDENTITY_URL} + - name: IdentityUrlExternal + value: ${IDENTITY_URL_EXTERNAL} + - name: CampaignDetailFunctionUri + value: + - name: PicBaseUrl + value: ${PIC_BASE_URL} + - name: PATH_BASE + value: /marketing-api + - name: ConnectionString + valueFrom: + secretKeyRef: + key: ConnectionString + name: marketing-db-connection-secret + 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: marketingapi +- 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: marketingapi-deploy-template +- description: The connection string to the MongoDB Marketing database + displayName: MongoDB Connection String + name: MONGO_DB_CONNECTION_STRING + required: true +- description: The Marketing database name + displayName: Marketing Database Name + name: MARKETING_DB_NAME + required: true +- description: The hostname of the RabbitMQ service + displayName: RabbitMQ Hostname + name: RABBITMQ_HOSTNAME + required: true +- description: The cluster internal URL of the Identity endpoint + displayName: Identity URL + name: IDENTITY_URL + required: true +- description: The external URL of the Identity endpoint + displayName: Identity URL External + name: IDENTITY_URL_EXTERNAL + required: true +- description: The public base URL for the catalog pictures + displayName: Pictures Base URL + name: PIC_BASE_URL + required: true \ No newline at end of file