Browse Source

Added environment variables to basketapi deploy pipeline

pull/1259/head
Tim McCarthy 5 years ago
parent
commit
5c6e34b3ce
2 changed files with 121 additions and 4 deletions
  1. +9
    -4
      deploy/aro/basket-api/azure-pipelines.yml
  2. +112
    -0
      deploy/aro/openshift-templates/basketapi-deploy-template.yml

+ 9
- 4
deploy/aro/basket-api/azure-pipelines.yml View File

@ -1,7 +1,5 @@
variables: variables:
AppName: basketapi
OpenShiftServiceConnection: 'OpenShift on ARO' OpenShiftServiceConnection: 'OpenShift on ARO'
SourceImageRegistryProjectName: 'development'
trigger: trigger:
branches: branches:
include: include:
@ -20,6 +18,13 @@ stages:
displayName: Development displayName: Development
variables: variables:
OpenShiftProject: development OpenShiftProject: development
SourceImageRegistryProjectName: $(OpenShiftProject)
EnvironmentName: dev
IdentityApiHostName: identityapi.$(OpenShiftProjectName).svc
RedisHostname: redis.$(OpenShiftProjectName).svc
IdentityPublicHostName: identity$(EnvironmentName)
IdentityUrlExternal: https://$(IdentityPublicHostName)
IdentityApiUrl: http://$(IdentityApiHostName):8080
jobs: jobs:
- job: Configuration_Deployment - job: Configuration_Deployment
displayName: 'Configuration Deployment' displayName: 'Configuration Deployment'
@ -33,6 +38,6 @@ stages:
- script: 'oc project $(OpenShiftProject)' - script: 'oc project $(OpenShiftProject)'
failOnStderr: true failOnStderr: true
displayName: 'Set OpenShift Project Context' displayName: 'Set OpenShift Project Context'
- script: 'oc process -f ./deploy/aro/openshift-templates/webapp-deploy-template.yml -p APPLICATION_NAME=$(AppName) -p IMAGE_REGISTRY_PROJECT_NAME=$(SourceImageRegistryProjectName) | oc apply -f-'
- script: 'oc process -f ./deploy/aro/openshift-templates/basketapi-deploy-template.yml -p IMAGE_REGISTRY_PROJECT_NAME=$(SourceImageRegistryProjectName) -p IDENTITY_URL_EXTERNAL=$(IdentityUrlExternal) -p IDENTITY_URL=$(IdentityApiUrl) -p REDIS_HOSTNAME=$(RedisHostname) | oc apply -f-'
failOnStderr: true failOnStderr: true
displayName: 'Ensure OpenShift DeploymentConfig and Service'
displayName: 'Ensure Basket API OpenShift DeploymentConfig and Service'

+ 112
- 0
deploy/aro/openshift-templates/basketapi-deploy-template.yml View File

@ -0,0 +1,112 @@
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: IdentityUrlExternal
value: ${IDENTITY_URL_EXTERNAL}
- name: IdentityUrl
value: ${IDENTITY_URL}
- name: ConnectionString
value: ${REDIS_HOSTNAME}
- name: EventBusConnection
value: ${RABBITMQ_HOSTNAME}
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: basketapi
- 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: basketapi-deploy-template
- description: The external URL of the Identity endpoint
displayName: Identity URL External
name: IDENTITY_URL_EXTERNAL
required: true
- description: The cluster internal URL of the Identity endpoint
displayName: Identity URL
name: IDENTITY_URL
required: true
- description: The hostname of the Redis service
displayName: Redis Hostname
name: REDIS_HOSTNAME
required: true
- description: The hostname of the RabbitMQ service
displayName: RabbitMQ Hostname
name: RABBITMQ_HOSTNAME
required: true

Loading…
Cancel
Save