{"__v":2,"_id":"57ffcf1c7c80de0e00c56863","category":{"__v":2,"_id":"56ccf29a431ada1f00e85aae","pages":["56ccf3498c4a331d002c1e1e","56ccf35a8c4a331d002c1e21"],"project":"55c6bec1b9aa4e0d0016c2c3","version":"55c6bec1b9aa4e0d0016c2c6","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-24T00:00:26.717Z","from_sync":false,"order":4,"slug":"code-labs","title":"Code Labs"},"parentDoc":null,"project":"55c6bec1b9aa4e0d0016c2c3","user":"57ffca3ec79e7a2400e5fa57","version":{"__v":8,"_id":"55c6bec1b9aa4e0d0016c2c6","project":"55c6bec1b9aa4e0d0016c2c3","createdAt":"2015-08-09T02:45:21.683Z","releaseDate":"2015-08-09T02:45:21.683Z","categories":["55c6bec2b9aa4e0d0016c2c7","56c14bc5826df10d00e82230","56cceed8723ad71d00cae46c","56ccf29a431ada1f00e85aae","56ccf3c28fa8b01b00b82018","56ce1e6ee538330b0021ac5d","56f97e9a4c612020008f2eaf","5734fafd146eb82000597261"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-13T18:14:52.286Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"In this codelab, you will create a cohesive workflow which takes source code and builds, tests, and promotes it to production. This will be accomplished via 3 pipelines:\n\n* Bake & Deploy to Test\n* Validate Test\n* Promote to Prod\n\n\n## Part 0: Environment Setup\nWe are assuming you have completed [configuring Spinnaker](http://www.spinnaker.io/v1.0/docs/target-deployment-configuration#section-openstack) with OpenStack. In this example, we will be using Jenkins to trigger our pipelines.\n\n## Part 1: Bake & Deploy to Test\n\nIn this first exercise, you’ll set up a pipeline, named Bake & Deploy to Test, which builds an OpenStack image, deploys it as a server group to a test cluster, then destroys the previous server group in that cluster (also called the \"Highlander\" strategy). We will be triggering this pipeline with a Jenkins continuous integration job.\n\nThe workflow is shown in the figure below.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/86efad9-workflow.png\",\n        \"workflow.png\",\n        792,\n        340,\n        \"#d8a89e\"\n      ]\n    }\n  ]\n}\n[/block]\n### Create a Spinnaker Application\n\nNavigate to Spinnaker at [http://localhost:9000](http://localhost:9000).\n\nFrom the Spinnaker home page, create a new Spinnaker Application by clicking on the *Actions* drop down at the upper right and clicking on *Create Application*.\n\nIn the *New Application* dialog:\n\n* Enter \"codelab\" for *Name*.\n* Enter your email for *Owner Email*.\n* Click in the *Accounts* field and choose “my-openstack-account”.\n* Click the *Create* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/59ec1e0-Create_app.png\",\n        \"Create app.png\",\n        595,\n        508,\n        \"#3c646c\"\n      ]\n    }\n  ]\n}\n[/block]\n### Create a Security Group\nFirst we create a security group for your cluster. Navigate to the \"SECURITY GROUPS\" tab and click the *Create Security Group* button:\n\n* Enter \"test\" for *Stack*.\n* Enter \"http\" for *Detail*.\n* Enter a relevant description for *Description*.\n* Enter your preferred region for *Region*.\n* Enter your preferred port forwarding specifications in the *Ingress* section.\n* Click the *Create* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/cd8226e-Security_Group_1-red.png\",\n        \"Security Group 1-red.png\",\n        897,\n        799,\n        \"#ebebec\"\n      ]\n    }\n  ]\n}\n[/block]\n### Create a Load Balancer\n\nNavigate to the \"Load Balancers\" tab and click the *Create Load Balancer* button:\n\n* Enter “test” for *Stack*.\n* Enter \"lb\" in the *Detail* field.\n* Select your preferred subnet in the *Subnet* dropdown.\n* Select your preferred network in the *Network* dropdown.\n* Select \"codelab-test-http\" in the *Security Groups* dropdown.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1557d89-Load_1.png\",\n        \"Load 1.png\",\n        894,\n        921,\n        \"#3c566c\"\n      ],\n      \"sizing\": \"smart\"\n    }\n  ]\n}\n[/block]\n* Edit the *Listeners* section to your preference.\n* Click the *Create* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/2f13989-Load_2.png\",\n        \"Load 2.png\",\n        889,\n        915,\n        \"#e6e6e6\"\n      ],\n      \"sizing\": \"smart\"\n    }\n  ]\n}\n[/block]\n\n### Setup Pipeline: Bake & Deploy to Test Pipeline\n\nThe purpose of this pipeline is to generate a OpenStack image from a package, and then deploy the image on server groups in the test cluster. We want this pipeline to be kicked off every time the Jenkins continuous integration job completes.\n\nCreate a new pipeline by navigating to the PIPELINES tab and clicking the *New* button\n\n* Name the pipeline “Bake & Deploy to Test”.\n* Click the *Create Pipeline* button. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/adf0bd3-BakeDeploy_1.png\",\n        \"BakeDeploy 1.png\",\n        594,\n        219,\n        \"#f1f2f2\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Configure the pipeline\n\nThe first step in setting up a pipeline is to configure the pipeline. In particular, we need to specify an automated trigger that will kick off the pipeline. We will be using Jenkins.\n\nWe want this pipeline to kick off every time our Jenkins job completes. In the Automated Triggers section of the pipelines form:\n\n* Click *Add Trigger*.\n* Select “Jenkins” from the drop down menu for *Type*.\n* Specify your Jenkins instance for the *Master* field.\n* Specify your job name for the *Job* field.\n\nRefer to the figure below for an illustration of what the pipeline’s Configuration form looks like when we’re done.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3d25779-Trigger_1.png\",\n        \"Trigger 1.png\",\n        2264,\n        1270,\n        \"#f9f9f9\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Setup Bake stage\n\nThe purpose of our “Bake” stage is to create a OpenStack image with the package that was built by the Jenkins job that triggered this pipeline.\n\n* Click *Add stage*.\n* Select “Bake” in the *Type* drop down.\n* Select your preferred region in the \"Regions\" field.\n* Enter the package you wish to include in the *Package* field.\n* Select your preferred base image as in the *Base OS* field.\n* Click the \"Save Changes\" button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/236c0f4-Bake_red.png\",\n        \"Bake red.png\",\n        1131,\n        928,\n        \"#dadcd5\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Setup Deploy stage\n\nThe purpose of the “Deploy” stage is to take the OpenStack image constructed in the “Bake” stage and deploy it into a test environment.\n\n* Click *Add stage*.\n* Select “Deploy” in the *Type* drop down.\n* In the *Server group* section, click *Add server group*.\n* In the dialog that appears, click *Continue without a template*.\n* In the Location section, enter “test” in the *Stack* field.\n* In the Instance Settings section, choose your preferred type in the drop down.\n* In the Cluster Size section, enter your size preferences.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/569a883-deploycluster_red.png\",\n        \"deploycluster red.png\",\n        895,\n        919,\n        \"#eeeee6\"\n      ]\n    }\n  ]\n}\n[/block]\n* In the Access section, input the load balancer and security group we created earlier.\n* Click the \"Add\" button.\n* Save this stage of the pipeline.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/58a14f3-Deploycluster_2_red.png\",\n        \"Deploycluster 2 red.png\",\n        898,\n        917,\n        \"#e8e8e8\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Destroy previous server group\n\nIn this tutorial use case, on successive deployments of new server groups to the test cluster, we don’t need the previous server group anymore.\n\n* Click *Add Stage*.\n* Select “Destroy Server Group” for *Type*.\n* Check the region of the previous test server group that you want to destroy.\n* Enter codelab-test for the *Cluster*.\n* Select “Previous Server Group” for *Target*.\n* Click *Save Changes*.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/49d1557-Destroy.png\",\n        \"Destroy.png\",\n        1131,\n        944,\n        \"#3a6580\"\n      ]\n    }\n  ]\n}\n[/block]\n\nThe pipeline is now complete. Take a moment to review the stages of this pipeline that you just built.\n\n### Trying it out\n\nNow let’s run this pipeline. We trigger it by manually running a Build of the Jenkins job.\n\n* Navigate to your Jenkins console.\n* Click on the your previously configured job.\n* Click *Build Now*.\n\nIt may take a while for the polling to trigger the job, but soon in the PIPELINES tab you can see progress, status and details.\n\nThe first time this pipeline is run, the Destroy Server Group stage will fail, because the selector for “Previous Server Group” will find nothing (no server groups presently in the test cluster). The Deploy stage, however, does succeed, so a test cluster will be created.\n\nTry running it again, either by running another Build of the Jenkins job, or by manually triggering from the PIPELINES tab (click *Start Manual Execution*). It will succeed all the way, and your pipeline execution details will look like below:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/l0YV502iSb2vru5qKlbO_1-pipelines.png\",\n        \"1-pipelines.png\",\n        \"1408\",\n        \"607\",\n        \"#3e596c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\nYou can now see in the CLUSTERS tab that a new server group has been deployed to the test cluster, and the previous server group is destroyed (i.e. does not exist).\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/00c5282-ClustersFixed.png\",\n        \"ClustersFixed.png\",\n        1131,\n        514,\n        \"#fafafa\"\n      ]\n    }\n  ]\n}\n[/block]\n## Part 2: Validate Test\n\nThe second pipeline, named “Validate Test”, is a simple one-stage placeholder to represent some gating function before pushing to prod.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/BeAjt9mQHoSel669bsIA_2-workflow.png\",\n        \"2-workflow.png\",\n        \"928\",\n        \"291\",\n        \"#90a7b7\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\nFurthermore, we configure the prod deployment to implement the red/black strategy (a.k.a. blue/green), which means that upon verifying health of the new server group it will immediately disable the previous server group in the same cluster. Here we disable rather than destroy, so that rollbacks can be quickly accomplished simply by re-enabling the old server group.\n\n### Setup Pipeline: Validate Test\n\nCreate a new pipeline by navigating to the PIPELINES tab and clicking *Configure*, then *Create New ...*\n\n* Name the pipeline “Validate Test”.\n* Click the *Create Pipeline* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/438906d-ValidateTest.png\",\n        \"ValidateTest.png\",\n        596,\n        255,\n        \"#f3f3f2\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Configure the pipeline\n\nWe want this pipeline to kick off when the Bake & Deploy to Test pipeline completes.\n\n* Click *Add Trigger*.\n* Select “Pipeline” from the drop down menu for *Type*.\n* Select your application.\n* Select the “Bake & Deploy to Test” pipeline.\n* Check “successful”.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8419821-Triggerpipe.png\",\n        \"Triggerpipe.png\",\n        1128,\n        914,\n        \"#f9f9f9\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Setup Manual Judgment stage\n\nWe stop and wait for human confirmation to continue:\n\n* Click *Add stage*.\n* Select “Manual Judgment” in the *Type* drop down.\n* Specify *Instructions*, for example “Validate the test cluster”.\n* Click *Save Changes*.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/d573901-ManualJudge.png\",\n        \"ManualJudge.png\",\n        1128,\n        1041,\n        \"#395e75\"\n      ]\n    }\n  ]\n}\n[/block]\n## Part 3: Promote to Prod\n\nThe third pipeline, “Promote to Prod”, takes the image that was deployed in the test cluster, and deploys that image to the prod environment, thereby promoting it.\n\n### Create a Load Balancer\n\nWe create a load balancer for the prod cluster. Navigate to the LOAD BALANCERS tab and click the *Create Load Balancer* button:\n\n* Enter “prod” for *Stack*.\n* Enter \"lb\" for *Detail*.\n* Select your preferred subnet in the Subnet dropdown.\n* Select your preferred network in the Network dropdown.\n* Select \"codelab-test-http\" in the Security Groups dropdown.\n* Click the *Create* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7daec63-LB2.png\",\n        \"LB2.png\",\n        896,\n        948,\n        \"#3b556d\"\n      ]\n    }\n  ]\n}\n[/block]\n### Setup Pipeline: Promote to Prod Pipeline\n\nCreate a new pipeline by navigating to the PIPELINES tab and clicking *Configure*, then *Create New ...*\n\n* Name the pipeline “Promote to Prod”.\n* Click the *Create Pipeline* button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/cf1a0b5-PipelineProd.png\",\n        \"PipelineProd.png\",\n        597,\n        257,\n        \"#f2f3f2\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Configure the pipeline\n\nWe want this pipeline to kick off when the Validate Test pipeline completes.\n\n* Click *Add Trigger*.\n* Select “Pipeline” from the drop down menu for *Type*.\n* Select your application.\n* Select the “Validate Test” pipeline.\n* Check “successful”.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9JDp2SAQgSrGi1E3cgIF_2-configuration-2.png\",\n        \"2-configuration-2.png\",\n        \"1136\",\n        \"916\",\n        \"#39657c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Setup Find Image stage\n\nIn the “Find Image from Cluster” stage, we select the image that was deployed in the test cluster.\n\nClick the *Add stage* button:\n\n* Select “Find Image from Cluster” for the stage *Type*.\n* Check the region of the test server group to pick the image from.\n* Enter codelab-test for the *Cluster*.\n* Choose “Newest” for the *Server Group Selection*.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/864f5e4-find-image.png\",\n        \"find-image.png\",\n        1129,\n        946,\n        \"#dddfda\"\n      ]\n    }\n  ]\n}\n[/block]\n#### Setup the Deploy stage\n\nWe deploy the image that was picked, to the prod cluster.\n\n* Click *Add stage*.\n* Select “Deploy” in the *Type* drop down.\n* In the *Server group* section, click *Add server group*.\n* In the dialog that appears, click *Continue without a template*.\n* In the Basic Settings section, enter “prod” in the *Stack* field.\n* (Optional) Select a deployment strategy. Default is none.\n* Select your preferred option in the Instance Type drop down.\n* In the Access section, add the prod load balancer and the security group we previously created.\n* Click the *Add* button.\n* Click *Save Changes* to save your prod pipeline.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ec59a10-ProdDeploy2.png\",\n        \"ProdDeploy2.png\",\n        897,\n        1154,\n        \"#3b546b\"\n      ]\n    }\n  ]\n}\n[/block]\n\n\n\n### Trying it out\n\nNow let’s run through it all. Run a Build in Jenkins.\n\nWhen the Bake & Deploy to Test pipeline completes, the Validate Test pipeline will trigger and wait for user input.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Pgq9zrZ7RRr4byBPh8kA_2-validation.png\",\n        \"2-validation.png\",\n        \"1413\",\n        \"924\",\n        \"#3b566f\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\nClick *Continue*. This will trigger the Promote to Prod pipeline:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/V3xrMZLoQzWnEA1W3d04_2-pipelines-all.png\",\n        \"2-pipelines-all.png\",\n        \"1411\",\n        \"1010\",\n        \"#3e596c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\nIn the CLUSTERS tab, you can see that a server group has been deployed to the prod cluster.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/61633ee-Clusters2.png\",\n        \"Clusters2.png\",\n        1131,\n        544,\n        \"#455e71\"\n      ]\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"openstack-source-to-prod","type":"basic","title":"OpenStack Source To Prod"}

OpenStack Source To Prod


In this codelab, you will create a cohesive workflow which takes source code and builds, tests, and promotes it to production. This will be accomplished via 3 pipelines: * Bake & Deploy to Test * Validate Test * Promote to Prod ## Part 0: Environment Setup We are assuming you have completed [configuring Spinnaker](http://www.spinnaker.io/v1.0/docs/target-deployment-configuration#section-openstack) with OpenStack. In this example, we will be using Jenkins to trigger our pipelines. ## Part 1: Bake & Deploy to Test In this first exercise, you’ll set up a pipeline, named Bake & Deploy to Test, which builds an OpenStack image, deploys it as a server group to a test cluster, then destroys the previous server group in that cluster (also called the "Highlander" strategy). We will be triggering this pipeline with a Jenkins continuous integration job. The workflow is shown in the figure below. [block:image] { "images": [ { "image": [ "https://files.readme.io/86efad9-workflow.png", "workflow.png", 792, 340, "#d8a89e" ] } ] } [/block] ### Create a Spinnaker Application Navigate to Spinnaker at [http://localhost:9000](http://localhost:9000). From the Spinnaker home page, create a new Spinnaker Application by clicking on the *Actions* drop down at the upper right and clicking on *Create Application*. In the *New Application* dialog: * Enter "codelab" for *Name*. * Enter your email for *Owner Email*. * Click in the *Accounts* field and choose “my-openstack-account”. * Click the *Create* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/59ec1e0-Create_app.png", "Create app.png", 595, 508, "#3c646c" ] } ] } [/block] ### Create a Security Group First we create a security group for your cluster. Navigate to the "SECURITY GROUPS" tab and click the *Create Security Group* button: * Enter "test" for *Stack*. * Enter "http" for *Detail*. * Enter a relevant description for *Description*. * Enter your preferred region for *Region*. * Enter your preferred port forwarding specifications in the *Ingress* section. * Click the *Create* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/cd8226e-Security_Group_1-red.png", "Security Group 1-red.png", 897, 799, "#ebebec" ] } ] } [/block] ### Create a Load Balancer Navigate to the "Load Balancers" tab and click the *Create Load Balancer* button: * Enter “test” for *Stack*. * Enter "lb" in the *Detail* field. * Select your preferred subnet in the *Subnet* dropdown. * Select your preferred network in the *Network* dropdown. * Select "codelab-test-http" in the *Security Groups* dropdown. [block:image] { "images": [ { "image": [ "https://files.readme.io/1557d89-Load_1.png", "Load 1.png", 894, 921, "#3c566c" ], "sizing": "smart" } ] } [/block] * Edit the *Listeners* section to your preference. * Click the *Create* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/2f13989-Load_2.png", "Load 2.png", 889, 915, "#e6e6e6" ], "sizing": "smart" } ] } [/block] ### Setup Pipeline: Bake & Deploy to Test Pipeline The purpose of this pipeline is to generate a OpenStack image from a package, and then deploy the image on server groups in the test cluster. We want this pipeline to be kicked off every time the Jenkins continuous integration job completes. Create a new pipeline by navigating to the PIPELINES tab and clicking the *New* button * Name the pipeline “Bake & Deploy to Test”. * Click the *Create Pipeline* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/adf0bd3-BakeDeploy_1.png", "BakeDeploy 1.png", 594, 219, "#f1f2f2" ] } ] } [/block] #### Configure the pipeline The first step in setting up a pipeline is to configure the pipeline. In particular, we need to specify an automated trigger that will kick off the pipeline. We will be using Jenkins. We want this pipeline to kick off every time our Jenkins job completes. In the Automated Triggers section of the pipelines form: * Click *Add Trigger*. * Select “Jenkins” from the drop down menu for *Type*. * Specify your Jenkins instance for the *Master* field. * Specify your job name for the *Job* field. Refer to the figure below for an illustration of what the pipeline’s Configuration form looks like when we’re done. [block:image] { "images": [ { "image": [ "https://files.readme.io/3d25779-Trigger_1.png", "Trigger 1.png", 2264, 1270, "#f9f9f9" ] } ] } [/block] #### Setup Bake stage The purpose of our “Bake” stage is to create a OpenStack image with the package that was built by the Jenkins job that triggered this pipeline. * Click *Add stage*. * Select “Bake” in the *Type* drop down. * Select your preferred region in the "Regions" field. * Enter the package you wish to include in the *Package* field. * Select your preferred base image as in the *Base OS* field. * Click the "Save Changes" button. [block:image] { "images": [ { "image": [ "https://files.readme.io/236c0f4-Bake_red.png", "Bake red.png", 1131, 928, "#dadcd5" ] } ] } [/block] #### Setup Deploy stage The purpose of the “Deploy” stage is to take the OpenStack image constructed in the “Bake” stage and deploy it into a test environment. * Click *Add stage*. * Select “Deploy” in the *Type* drop down. * In the *Server group* section, click *Add server group*. * In the dialog that appears, click *Continue without a template*. * In the Location section, enter “test” in the *Stack* field. * In the Instance Settings section, choose your preferred type in the drop down. * In the Cluster Size section, enter your size preferences. [block:image] { "images": [ { "image": [ "https://files.readme.io/569a883-deploycluster_red.png", "deploycluster red.png", 895, 919, "#eeeee6" ] } ] } [/block] * In the Access section, input the load balancer and security group we created earlier. * Click the "Add" button. * Save this stage of the pipeline. [block:image] { "images": [ { "image": [ "https://files.readme.io/58a14f3-Deploycluster_2_red.png", "Deploycluster 2 red.png", 898, 917, "#e8e8e8" ] } ] } [/block] #### Destroy previous server group In this tutorial use case, on successive deployments of new server groups to the test cluster, we don’t need the previous server group anymore. * Click *Add Stage*. * Select “Destroy Server Group” for *Type*. * Check the region of the previous test server group that you want to destroy. * Enter codelab-test for the *Cluster*. * Select “Previous Server Group” for *Target*. * Click *Save Changes*. [block:image] { "images": [ { "image": [ "https://files.readme.io/49d1557-Destroy.png", "Destroy.png", 1131, 944, "#3a6580" ] } ] } [/block] The pipeline is now complete. Take a moment to review the stages of this pipeline that you just built. ### Trying it out Now let’s run this pipeline. We trigger it by manually running a Build of the Jenkins job. * Navigate to your Jenkins console. * Click on the your previously configured job. * Click *Build Now*. It may take a while for the polling to trigger the job, but soon in the PIPELINES tab you can see progress, status and details. The first time this pipeline is run, the Destroy Server Group stage will fail, because the selector for “Previous Server Group” will find nothing (no server groups presently in the test cluster). The Deploy stage, however, does succeed, so a test cluster will be created. Try running it again, either by running another Build of the Jenkins job, or by manually triggering from the PIPELINES tab (click *Start Manual Execution*). It will succeed all the way, and your pipeline execution details will look like below: [block:image] { "images": [ { "image": [ "https://files.readme.io/l0YV502iSb2vru5qKlbO_1-pipelines.png", "1-pipelines.png", "1408", "607", "#3e596c", "" ] } ] } [/block] You can now see in the CLUSTERS tab that a new server group has been deployed to the test cluster, and the previous server group is destroyed (i.e. does not exist). [block:image] { "images": [ { "image": [ "https://files.readme.io/00c5282-ClustersFixed.png", "ClustersFixed.png", 1131, 514, "#fafafa" ] } ] } [/block] ## Part 2: Validate Test The second pipeline, named “Validate Test”, is a simple one-stage placeholder to represent some gating function before pushing to prod. [block:image] { "images": [ { "image": [ "https://files.readme.io/BeAjt9mQHoSel669bsIA_2-workflow.png", "2-workflow.png", "928", "291", "#90a7b7", "" ] } ] } [/block] Furthermore, we configure the prod deployment to implement the red/black strategy (a.k.a. blue/green), which means that upon verifying health of the new server group it will immediately disable the previous server group in the same cluster. Here we disable rather than destroy, so that rollbacks can be quickly accomplished simply by re-enabling the old server group. ### Setup Pipeline: Validate Test Create a new pipeline by navigating to the PIPELINES tab and clicking *Configure*, then *Create New ...* * Name the pipeline “Validate Test”. * Click the *Create Pipeline* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/438906d-ValidateTest.png", "ValidateTest.png", 596, 255, "#f3f3f2" ] } ] } [/block] #### Configure the pipeline We want this pipeline to kick off when the Bake & Deploy to Test pipeline completes. * Click *Add Trigger*. * Select “Pipeline” from the drop down menu for *Type*. * Select your application. * Select the “Bake & Deploy to Test” pipeline. * Check “successful”. [block:image] { "images": [ { "image": [ "https://files.readme.io/8419821-Triggerpipe.png", "Triggerpipe.png", 1128, 914, "#f9f9f9" ] } ] } [/block] #### Setup Manual Judgment stage We stop and wait for human confirmation to continue: * Click *Add stage*. * Select “Manual Judgment” in the *Type* drop down. * Specify *Instructions*, for example “Validate the test cluster”. * Click *Save Changes*. [block:image] { "images": [ { "image": [ "https://files.readme.io/d573901-ManualJudge.png", "ManualJudge.png", 1128, 1041, "#395e75" ] } ] } [/block] ## Part 3: Promote to Prod The third pipeline, “Promote to Prod”, takes the image that was deployed in the test cluster, and deploys that image to the prod environment, thereby promoting it. ### Create a Load Balancer We create a load balancer for the prod cluster. Navigate to the LOAD BALANCERS tab and click the *Create Load Balancer* button: * Enter “prod” for *Stack*. * Enter "lb" for *Detail*. * Select your preferred subnet in the Subnet dropdown. * Select your preferred network in the Network dropdown. * Select "codelab-test-http" in the Security Groups dropdown. * Click the *Create* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/7daec63-LB2.png", "LB2.png", 896, 948, "#3b556d" ] } ] } [/block] ### Setup Pipeline: Promote to Prod Pipeline Create a new pipeline by navigating to the PIPELINES tab and clicking *Configure*, then *Create New ...* * Name the pipeline “Promote to Prod”. * Click the *Create Pipeline* button. [block:image] { "images": [ { "image": [ "https://files.readme.io/cf1a0b5-PipelineProd.png", "PipelineProd.png", 597, 257, "#f2f3f2" ] } ] } [/block] #### Configure the pipeline We want this pipeline to kick off when the Validate Test pipeline completes. * Click *Add Trigger*. * Select “Pipeline” from the drop down menu for *Type*. * Select your application. * Select the “Validate Test” pipeline. * Check “successful”. [block:image] { "images": [ { "image": [ "https://files.readme.io/9JDp2SAQgSrGi1E3cgIF_2-configuration-2.png", "2-configuration-2.png", "1136", "916", "#39657c", "" ] } ] } [/block] #### Setup Find Image stage In the “Find Image from Cluster” stage, we select the image that was deployed in the test cluster. Click the *Add stage* button: * Select “Find Image from Cluster” for the stage *Type*. * Check the region of the test server group to pick the image from. * Enter codelab-test for the *Cluster*. * Choose “Newest” for the *Server Group Selection*. [block:image] { "images": [ { "image": [ "https://files.readme.io/864f5e4-find-image.png", "find-image.png", 1129, 946, "#dddfda" ] } ] } [/block] #### Setup the Deploy stage We deploy the image that was picked, to the prod cluster. * Click *Add stage*. * Select “Deploy” in the *Type* drop down. * In the *Server group* section, click *Add server group*. * In the dialog that appears, click *Continue without a template*. * In the Basic Settings section, enter “prod” in the *Stack* field. * (Optional) Select a deployment strategy. Default is none. * Select your preferred option in the Instance Type drop down. * In the Access section, add the prod load balancer and the security group we previously created. * Click the *Add* button. * Click *Save Changes* to save your prod pipeline. [block:image] { "images": [ { "image": [ "https://files.readme.io/ec59a10-ProdDeploy2.png", "ProdDeploy2.png", 897, 1154, "#3b546b" ] } ] } [/block] ### Trying it out Now let’s run through it all. Run a Build in Jenkins. When the Bake & Deploy to Test pipeline completes, the Validate Test pipeline will trigger and wait for user input. [block:image] { "images": [ { "image": [ "https://files.readme.io/Pgq9zrZ7RRr4byBPh8kA_2-validation.png", "2-validation.png", "1413", "924", "#3b566f", "" ] } ] } [/block] Click *Continue*. This will trigger the Promote to Prod pipeline: [block:image] { "images": [ { "image": [ "https://files.readme.io/V3xrMZLoQzWnEA1W3d04_2-pipelines-all.png", "2-pipelines-all.png", "1411", "1010", "#3e596c", "" ] } ] } [/block] In the CLUSTERS tab, you can see that a server group has been deployed to the prod cluster. [block:image] { "images": [ { "image": [ "https://files.readme.io/61633ee-Clusters2.png", "Clusters2.png", 1131, 544, "#455e71" ] } ] } [/block]