Skip to content

Commit

Permalink
blue-green-spring updates (#22)
Browse files Browse the repository at this point in the history
* Fix typos and formatting

* Fix links to openshift-applier after move to new repo

* Fix formatting of Requirements commands

* Add steps to install role via Ansible Galaxy
  • Loading branch information
bparry02 authored and sabre1041 committed Mar 19, 2018
1 parent e27c732 commit 5633d41
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
37 changes: 23 additions & 14 deletions blue-green-spring/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A Sample OpenShift Pipeline for Blue Green deployments

This example demonstrates how to implement a full end-to-end Jenkins Pipeline for a Java application in a Blue/Green deployment in the OpenShift Container Platform. The pipleine will create two instances of the applicaiton in the Production namespace. There will be three routes in the namespace; a blue, green and blue-green route. The blue-green route will switch to the latest deployment when the pipeline completes. This allows for tesing of the new deployment prior to switching live traffic. Also, the previous deployment can be used to compmare the previous deployment.
This example demonstrates how to implement a full end-to-end Jenkins Pipeline for a Java application in a Blue/Green deployment in the OpenShift Container Platform. The pipleine will create two instances of the application in the Production namespace. There will be three routes in the namespace; a blue, green and blue-green route. The blue-green route will switch to the latest deployment when the pipeline completes. This allows for tesing of the new deployment prior to switching live traffic. Also, the previous deployment can be used to compare the previous deployment.

This sample demonstrates the following capabilities:

Expand All @@ -11,23 +11,32 @@ This sample demonstrates the following capabilities:
* Tagging images with the current version of the artifact defined in the pom.xml file
* Promotion of an application's container image to a blue/green production configuration
* Switching production routes between blue and green deployments after confirmation
* Automated rollout using the [openshift-appler](https://github.com/redhat-cop/casl-ansible/tree/master/roles/openshift-applier) Ansible role.
* Automated rollout using the [openshift-applier](https://github.com/redhat-cop/openshift-applier/tree/master/roles/openshift-applier) Ansible role.

## Quickstart

### Requirements
1. [OpenShift Applier](https://github.com/redhat-cop/casl-ansible)
`git clone git@github.com:redhat-cop/casl-ansible.git`
`git checkout v3.6.1`
2. [Ansible](https://www.ansible.com/)
`sudo dnf install ansible`
1. [Ansible](https://www.ansible.com/)

```
sudo dnf install ansible
```

### Installation
Run the following commands to instantiate this example.
```
ansible-playbook -i inventory/hosts ../casl-ansible/playbooks/openshift-cluster-seed.yml --connection=local
```
The above command will create all the necessary projects and OpenShift objects as well as a Jenkins instance that will build, promote and deploy the application.
1. Clone this repository
2. `cd container-pipelines/blue-green-spring`
3. Run ansible-galaxy to install required Ansible roles

```
ansible-galaxy install -r requirements.yml --roles-path=roles
```

4. Run the following Ansible playbook to install all the necessary projects and OpenShift objects as well as a Jenkins instance that will build, promote and deploy the application.

```
ansible-playbook -i inventory/hosts roles/openshift-applier/playbooks/openshift-cluster-seed.yml --connection=local
```

## Architecture

Expand Down Expand Up @@ -81,7 +90,7 @@ https://github.com/malacourse/simple-spring-boot-web

For the purposes of this demo, we are going to create four stages for our application to be promoted through.

- 'spring-boot-web-build'
- `spring-boot-web-build`
- `spring-boot-web-dev`
- `spring-boot-web-stage`
- `spring-boot-web-prod`
Expand All @@ -102,9 +111,9 @@ A _deploy template_ is provided at `files/deployment/template.yml` that defines
* A `DeploymentConfig`
* A `RoleBinding` to allow Jenkins to deploy in each namespace.

This template should be instantiated once in each of the lower level namespaces (dev, stage,qa) that our app will be deployed to. For this purpose, we have created a param file to be fed to `oc process` to customize the template for each environment.
This template should be instantiated once in each of the lower level namespaces (dev, stage) that our app will be deployed to. For this purpose, we have created a param file to be fed to `oc process` to customize the template for each environment.

A production blue/green_deploy template_ is provided at `deploy/simple-spring-boot-template-prod.yml` that defines all of the resources required to run the openjdk8 application. It includes:
A production blue/green _deploy template_ is provided at `deploy/simple-spring-boot-template-prod.yml` that defines all of the resources required to run the openjdk8 application. It includes:

* Two `Service's`
* Three `Route's` a blue route, green route and main route that switches between the two deployments/services.
Expand Down
2 changes: 1 addition & 1 deletion blue-green-spring/pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ node('maven') {
openshiftVerifyDeployment(deploymentConfig: "${env.APP_NAME}-${newState}", namespace: "${STAGE3}", verifyReplicaCount: true)
println "Application ${env.APP_NAME}-${newState} is now in Production!"

input "Switch ${env.STAGE3} form ${currentState} to ${newState} deployment?"
input "Switch ${env.STAGE3} from ${currentState} to ${newState} deployment?"

// Switch Route to new active c
sh "oc patch route ${env.APP_NAME} --patch '{\"spec\": { \"to\": { \"name\": \"${env.APP_NAME}-${newState}\"}}}' -n ${env.STAGE3}"
Expand Down
8 changes: 8 additions & 0 deletions blue-green-spring/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is the Ansible Galaxy requirements file to pull in the correct roles
# to support the operation of CASL provisioning/runs.

# From 'openshift-applier'
- name: openshift-applier
scm: git
src: https://github.com/redhat-cop/openshift-applier
version: v3.7.2

0 comments on commit 5633d41

Please sign in to comment.