Implementation of Manual Approval in Continuous Delivery using Kubernetes and Jenkins

8/13/2019

Currently I am trying to implement examples for both continuous delivery and deployment using Kubernetes and Jenkins. I have successfully implemented continuous deployment. Automatically, my REST API is deploying to my Kubernetes cluster via Jenkins. Both test and prod namespaces are deploying.

Now I am trying to implement continuous delivery by making a manual user approval before releasing to prod namespace. Means implement a manual approval by implementing one switch in between test and prod environments.

For more clarity I am adding here screenshots I got while I am exploring,

Continuous Delivery & Continuous Deployment Difference in Manual Approval

enter image description here

enter image description here

Here my confusion is that, when I am implementing the delivery, how I can add the user interaction? Do I need to change any parameter in my deployment.yaml or service.yaml? Or do I need to change anything when I am creating my Jenkins pipeline job in Jenkins UI?

I am new to the continuous delivery side. Can anyone suggest any documentation or tutorials or any method to explore please?

-- Jacob
continuous-delivery
jenkins
kubernetes

2 Answers

8/13/2019

We are using a shared library in Jenkins. We will pause the pipeline for 1 day and send mail to Approval DL mention in AD with the link. If not approval timely we will terminate deployment.

Approval has to login jenkins using the link to the approval of the deployment. (we thought about direct approval link but it is a security risk.)

timeout(time: 1, unit: "DAY")
{
  log("Send an email to approvers@example.net with link)
  sendEmail()
  def inputResult = input (
  id: "123", 
  message: "I approve this deployment",
  )
}
-- yogesh kunjir
Source: StackOverflow

8/13/2019

You can use the Jenkins Input Step to do something like this. Input step coupled with a try/catch will enable you fairly good control over success/failure of the job also.

The example below is from CloudBees support portal and uses the input box, captures the input and uses that input value to set the success/failure of the current build

def userInput
try {
    userInput = input(
        id: 'Proceed1', message: 'Was this successful?', parameters: [
        [$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']
        ])
} catch(err) { // input false
    def user = err.getCauses()[0].getUser()
    userInput = false
    echo "Aborted by: [${user}]"
}

node {
    if (userInput == true) {
        // do something
        echo "this was successful"
    } else {
        // do something else
        echo "this was not successful"
        currentBuild.result = 'FAILURE'
    } 
}
-- Vishal Biyani
Source: StackOverflow