Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Readiness and Liveness probes #20

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions openshift/meta-templates/deployment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ parameters:
value: '1Gi'
- name: replicas
value: '2'
- name: healthCheckRoute
display: Health Check Route
description: URL Path to Application Health Check End Point
required: true
- name: readinessCheckDelay
display: Readiness Check Delay
description: Deploy Config Readiness Check Time Delay in Seconds (Less than Liveness)
required: true
- name: livenessCheckDelay
display: Liveness Check Delay
description: Deploy Config Liveness Check Time Delay in Seconds (Greater than Readiness)
required: true

objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -64,6 +77,26 @@ objects:
limits:
cpu: ${cpu_limit}
memory: ${memory_limit}
readinessProbe:
failureThreshold: 3
httpGet:
path: ${healthCheckRoute}
port: ${container_port}
scheme: HTTP
initialDelaySeconds: ${readinessCheckDelay}
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
livenessProbe:
failureThreshold: 3
httpGet:
path: ${healthCheckRoute}
port: ${container_port}
scheme: HTTP
initialDelaySeconds: ${livenessCheckDelay}
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
restartPolicy: Always
test: false
triggers:
Expand Down
40 changes: 33 additions & 7 deletions openshift/meta-templates/pipeline-build-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ parameters:
required: true
name: dcMemRequest
value: 128Mi
- description: Deploy Config Health Check URL Path
displayName: Deploy Config Health Check
required: true
name: healthCheckRoute
- description: Deploy Config Readiness Check Time Delay in Seconds (Less than Liveness)
displayName: Deploy Config Readiness Check Time Delay
required: true
name: readinessCheckDelay
value: '120'
- description: Deploy Config Liveness Check Time Delay in Seconds (Greater than Readiness)
displayName: Deploy Config Liveness Check
required: true
name: livenessCheckDelay
value: '70'

#Pipeline Specific
- description: Jenkins Pod Image Name
Expand Down Expand Up @@ -221,6 +235,12 @@ objects:
value: "${namespacePrefix}-prod"
- name: ROUTE_TYPE
value: "${routeType}"
- name: HEALTH_CHECK_ROUTE
value: ${healthCheckRoute}
- name: READINESS_CHECK_DELAY
value: ${readinessCheckDelay}
- name: LIVENESS_CHECK_DELAY
value: ${livenessCheckDelay}
jenkinsfile: |-
try {
timeout(time: 33, unit: 'MINUTES') {
Expand Down Expand Up @@ -282,7 +302,8 @@ objects:
}

stage("Deploy ${APP_NAME}") {
deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${DEV_NAMESPACE}", "${ROUTE_TYPE}", "dev")

deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${DEV_NAMESPACE}", "${ROUTE_TYPE}", "dev", "${HEALTH_CHECK_ROUTE}", "${READINESS_CHECK_DELAY}", "${LIVENESS_CHECK_DELAY}")
}

stage('Promotion gate') {
Expand All @@ -299,7 +320,7 @@ objects:
}

stage("Deploy ${APP_NAME}") {
deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${TEST_NAMESPACE}", "${ROUTE_TYPE}", "test")
deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${TEST_NAMESPACE}", "${ROUTE_TYPE}", "test", "${HEALTH_CHECK_ROUTE}", "${READINESS_CHECK_DELAY}", "${LIVENESS_CHECK_DELAY}")
}

stage('Promotion gate') {
Expand All @@ -316,7 +337,7 @@ objects:
}

stage("Deploy ${APP_NAME}") {
deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${PROD_NAMESPACE}", "${ROUTE_TYPE}", "prod")
deploy("${DEPLOYMENT_CONFIG_PATH}", "${APP_NAME}", "${TOOLS_NAMESPACE}", "${PROD_NAMESPACE}", "${ROUTE_TYPE}", "prod", "${HEALTH_CHECK_ROUTE}", "${READINESS_CHECK_DELAY}", "${LIVENESS_CHECK_DELAY}")
}
}
}
Expand All @@ -337,10 +358,11 @@ objects:
}

// Deploy application to environment
def deploy(String deploymentConfigPath, String appName, String sourceNamespace, String targetNamespace, String routeType, String version) {
def deploy(String deploymentConfigPath, String appName, String sourceNamespace, String targetNamespace,
String routeType, String version, String healthCheckRoute, String readinessCheckDelay, String livenessCheckDelay) {
dir("${appName}") {

deployTemplates("${deploymentConfigPath}", "${appName}", "${sourceNamespace}", "${targetNamespace}", "${routeType}", "${version}")
deployTemplates("${deploymentConfigPath}", "${appName}", "${sourceNamespace}", "${targetNamespace}", "${routeType}", "${version}", "${healthCheckRoute}", "${readinessCheckDelay}", "${livenessCheckDelay}")

sh "echo Wait for service to be up"
timeout(time: 5, unit: 'MINUTES') {
Expand All @@ -367,7 +389,8 @@ objects:
}

// deploy template by Priority: Project Repo Template > OpenShift Template Exists (Skip) > Default Meta Template
def deployTemplates(String deploymentConfigPath, String appName, String sourceNamespace, String targetNamespace, String routeType, String version){
def deployTemplates(String deploymentConfigPath, String appName, String sourceNamespace, String targetNamespace,
String routeType, String version, String healthCheckRoute, String readinessCheckDelay, String livenessCheckDelay){
def templateExists
openshift.withCluster() {
openshift.withProject("${targetNamespace}") {
Expand All @@ -384,7 +407,10 @@ objects:
sh "oc process -f ${deploymentConfigPath} \
-p appName=${appName} \
-p namespace=${sourceNamespace} \
-p TAG=${version} | oc apply -f - -n ${targetNamespace}"
-p TAG=${version} \
-p healthCheckRoute=${healthCheckRoute} \
-p readinessCheckDelay=${readinessCheckDelay} \
-p livenessCheckDelay=${livenessCheckDelay} | oc apply -f - -n ${targetNamespace}"

// Deploy generic route
if(routeType == "private") {
Expand Down