From 5eb182cbb287de1589c13ccab45a6847c0f09c74 Mon Sep 17 00:00:00 2001 From: Eric Sauer Date: Mon, 5 Feb 2018 13:27:19 -0500 Subject: [PATCH] Adding final openshift-applier inventory for sprint-boot pipeline --- README.md | 4 +++ basic-spring-boot/README.md | 26 ++++++++++--------- .../dev/params => files/builds/params.dev} | 0 .../{build => files/builds}/template.yml | 0 .../params => files/deployments/params.dev} | 0 .../params => files/deployments/params.prod} | 0 .../params => files/deployments/params.stage} | 0 .../deployments}/template.yml | 0 .../{ => files}/projects/projects.yml | 0 .../inventory/group_vars/seed-hosts.yml | 22 ++++++++++++++++ basic-spring-boot/inventory/hosts | 2 ++ basic-tomcat/README.md | 1 + blue-green-spring/README.md | 5 ++-- 13 files changed, 46 insertions(+), 14 deletions(-) rename basic-spring-boot/{build/dev/params => files/builds/params.dev} (100%) rename basic-spring-boot/{build => files/builds}/template.yml (100%) rename basic-spring-boot/{deploy/dev/params => files/deployments/params.dev} (100%) rename basic-spring-boot/{deploy/prod/params => files/deployments/params.prod} (100%) rename basic-spring-boot/{deploy/stage/params => files/deployments/params.stage} (100%) rename basic-spring-boot/{deploy => files/deployments}/template.yml (100%) rename basic-spring-boot/{ => files}/projects/projects.yml (100%) create mode 100644 basic-spring-boot/inventory/group_vars/seed-hosts.yml create mode 100644 basic-spring-boot/inventory/hosts diff --git a/README.md b/README.md index e19f0204..138e4688 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,7 @@ Typically the things required to build a pipeline sample include: - etc. See our [basic spring boot](./basic-spring-boot) example for a very simple reference architecture. + +## Automated Deployments + +These pipeline quickstarts include an Ansible inventory through which they can be automatically deployed and managed using the [OpenShift Applier](https://github.com/redhat-cop/casl-ansible/tree/master/roles/openshift-applier) role. diff --git a/basic-spring-boot/README.md b/basic-spring-boot/README.md index 0e62ef46..774ecbc0 100644 --- a/basic-spring-boot/README.md +++ b/basic-spring-boot/README.md @@ -7,28 +7,30 @@ This example demonstrates how to implement a full end-to-end Jenkins Pipeline fo * "One Click" instantiation of a Jenkins Pipeline using OpenShift's Jenkins Pipeline Strategy feature * Promotion of an application's container image within an OpenShift Cluster (using `oc tag`) * Promotion of an application's container image to a separate OpenShift Cluster (using `skopeo`) - Coming Soon! +* Automated rollout using the [openshift-appler](https://github.com/redhat-cop/casl-ansible/tree/master/roles/openshift-applier) Ansible role. -## Quickstart +## Automated Quickstart -Run the following commands to instantiate this example. +This quickstart can be deployed quickly using Ansible. Here are the steps. +1. Clone [this repo](https://github.com/redhat-cop/container-pipelines.git) and the [casl-ansible](https://github.com/redhat-cop/casl-ansible.git) repo. +2. Log into an OpenShift cluster, then run the following command. ``` -cd ./basic-spring-boot -oc create -f projects/projects.yml -oc process openshift//jenkins-ephemeral | oc apply -f- -n basic-spring-boot-dev -oc process -f deploy/template.yml --param-file=deploy/dev/params | oc apply -f- -oc process -f deploy/template.yml --param-file=deploy/stage/params | oc apply -f- -oc process -f deploy/template.yml --param-file=deploy/prod/params | oc apply -f- -oc process -f build/template.yml --param-file build/dev/params | oc apply -f- +$ oc login +$ ansible-playbook -i container-pipelines/basic-spring-boot/inventory/ casl-ansible/playbooks/openshift-cluster-seed.yml --connection=local ``` +At this point you should have 3 projects deployed (`basic-spring-boot-dev`, `basic-spring-boot-stage`, and `basic-spring-boot-prod`) with our [Spring Rest](https://github.com/redhat-cop/spring-rest.git) demo application deployed to all 3. + ## Architecture +The following breaks down the architecture of the pipeline deployed, as well as walks through the manual deployment steps + ### OpenShift Templates The components of this pipeline are divided into two templates. -The first template, `build/template.yml` is what we are calling the "Build" template. It contains: +The first template, `files/builds/template.yml` is what we are calling the "Build" template. It contains: * A `jenkinsPipelineStrategy` BuildConfig * An `s2i` BuildConfig @@ -36,7 +38,7 @@ The first template, `build/template.yml` is what we are calling the "Build" temp The build template contains a default source code repo for a java application compatible with this pipelines architecture (https://github.com/redhat-cop/spring-rest). -The second template, `deploy/template.yml` is the "Deploy" template. It contains: +The second template, `files/deployments/template.yml` is the "Deploy" template. It contains: * A tomcat8 DeploymentConfig * A Service definition @@ -62,7 +64,7 @@ https://github.com/redhat-cop/spring-rest * OpenShift 3.5+ is required. * Access to GitHub -## Implementation Instructions +## Manual Deployment Instructions ### 1. Create Lifecycle Stages diff --git a/basic-spring-boot/build/dev/params b/basic-spring-boot/files/builds/params.dev similarity index 100% rename from basic-spring-boot/build/dev/params rename to basic-spring-boot/files/builds/params.dev diff --git a/basic-spring-boot/build/template.yml b/basic-spring-boot/files/builds/template.yml similarity index 100% rename from basic-spring-boot/build/template.yml rename to basic-spring-boot/files/builds/template.yml diff --git a/basic-spring-boot/deploy/dev/params b/basic-spring-boot/files/deployments/params.dev similarity index 100% rename from basic-spring-boot/deploy/dev/params rename to basic-spring-boot/files/deployments/params.dev diff --git a/basic-spring-boot/deploy/prod/params b/basic-spring-boot/files/deployments/params.prod similarity index 100% rename from basic-spring-boot/deploy/prod/params rename to basic-spring-boot/files/deployments/params.prod diff --git a/basic-spring-boot/deploy/stage/params b/basic-spring-boot/files/deployments/params.stage similarity index 100% rename from basic-spring-boot/deploy/stage/params rename to basic-spring-boot/files/deployments/params.stage diff --git a/basic-spring-boot/deploy/template.yml b/basic-spring-boot/files/deployments/template.yml similarity index 100% rename from basic-spring-boot/deploy/template.yml rename to basic-spring-boot/files/deployments/template.yml diff --git a/basic-spring-boot/projects/projects.yml b/basic-spring-boot/files/projects/projects.yml similarity index 100% rename from basic-spring-boot/projects/projects.yml rename to basic-spring-boot/files/projects/projects.yml diff --git a/basic-spring-boot/inventory/group_vars/seed-hosts.yml b/basic-spring-boot/inventory/group_vars/seed-hosts.yml new file mode 100644 index 00000000..b71b557f --- /dev/null +++ b/basic-spring-boot/inventory/group_vars/seed-hosts.yml @@ -0,0 +1,22 @@ +openshift_cluster_content: +- object: projects + content: + - name: "create environments" + file: "{{ inventory_dir }}/../files/projects/projects.yml" + file_action: create +- object: deployments + content: + - name: "deploy dev environment" + template: "{{ inventory_dir }}/../files/deployments/template.yml" + params: "{{ inventory_dir }}/../files/deployments/params.dev" + - name: "deply stage environment" + template: "{{ inventory_dir }}/../files/deployments/template.yml" + params: "{{ inventory_dir }}/../files/deployments/params.stage" + - name: "deply prod environment" + template: "{{ inventory_dir }}/../files/deployments/template.yml" + params: "{{ inventory_dir }}/../files/deployments/params.prod" +- object: builds + content: + - name: "deploy build pipeline to dev" + template: "{{ inventory_dir }}/../files/builds/template.yml" + params: "{{ inventory_dir }}/../files/builds/params.dev" diff --git a/basic-spring-boot/inventory/hosts b/basic-spring-boot/inventory/hosts new file mode 100644 index 00000000..05c07035 --- /dev/null +++ b/basic-spring-boot/inventory/hosts @@ -0,0 +1,2 @@ +[seed-hosts] +localhost diff --git a/basic-tomcat/README.md b/basic-tomcat/README.md index b65dec1f..137616e0 100644 --- a/basic-tomcat/README.md +++ b/basic-tomcat/README.md @@ -7,6 +7,7 @@ This example demonstrates how to implement a full end-to-end Jenkins Pipeline fo * "One Click" instantiation of a Jenkins Pipeline using OpenShift's Jenkins Pipeline Strategy feature * Promotion of an application's container image within an OpenShift Cluster (using `oc tag`) * Promotion of an application's container image to a separate OpenShift Cluster (using `skopeo`) +* Automated rollout using the [openshift-appler](https://github.com/redhat-cop/casl-ansible/tree/master/roles/openshift-applier) Ansible role. ## Quickstart diff --git a/blue-green-spring/README.md b/blue-green-spring/README.md index 0096af64..a90cdd4a 100644 --- a/blue-green-spring/README.md +++ b/blue-green-spring/README.md @@ -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 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 sample demonstrates the following capabilities: @@ -11,6 +11,7 @@ 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. ## Quickstart @@ -105,7 +106,7 @@ This template should be instantiated once in each of the lower level namespaces 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` +* Two `Service's` * Three `Route's` a blue route, green route and main route that switches between the two deployments/services. * Two `ImageStream's` * Two `DeploymentConfig's`