DATA SHEET Simplifi ed CICD with Jenkins and Git on...

14
1 Simplified CICD with Jenkins and Git on the ZeroStack Platform DATA SHEET @ZeroStackInc sales@zerostack.com www.zerostack.com In the technical article we will walk through an end to end workflow of starting from virtually nothing and establishing a CICD environment using Jenkins and Git, both of which are very popular Open source technologies. Prerequisites: Some knowledge of Git or other version control software. Some knowledge of Jenkins. If you know nothing about Jenkins this link provides a good introduction. Access to a ZeroStack Environment. Summary: This article walks through the following: 1. How to create a Git server from the zApp store. The Git Server will be used to host a code repo. 2. How to create a Jenkins Master server from the zApp store. 3. How to configure the Jenkins master to spin up worker VMs in ZeroStack. 4. How to create a GIT repo of an application in the git server 5. How to build and deploy the application via Jenkin’s CICD process 6. How to make changes to the source code and see the Jenkins automated CICD process kick in. The Steps: Step 1: Login as Cloud Admin and create a project in the “default” business Unit. The reason for doing so, it because the Jenkins plugin does not yet support multiple business units and, hence, can only point to the default BU.

Transcript of DATA SHEET Simplifi ed CICD with Jenkins and Git on...

Page 1: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

1

Simplifi ed CICD with Jenkinsand Git on the ZeroStack Platform

DATA SHEET

@ZeroStackInc [email protected] www.zerostack.com

In the technical article we will walk through an end to end workfl ow of starting from virtually nothing and establishing a CICD environment using Jenkins and Git, both of which are very popular Open source technologies.

Prerequisites:• Some knowledge of Git or other version control software.• Some knowledge of Jenkins. If you know nothing about Jenkins this link provides a good introduction.• Access to a ZeroStack Environment.

Summary:This article walks through the following:1. How to create a Git server from the zApp store. The Git Server will be used to host a code repo.2. How to create a Jenkins Master server from the zApp store.3. How to confi gure the Jenkins master to spin up worker VMs in ZeroStack.4. How to create a GIT repo of an application in the git server5. How to build and deploy the application via Jenkin’s CICD process6. How to make changes to the source code and see the Jenkins automated CICD process kick in.

The Steps:Step 1:Login as Cloud Admin and create a project in the “default” business Unit. The reason for doing so, it because theJenkins plugin does not yet support multiple business units and, hence, can only point to the default BU.

Page 2: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

2

Step 2:Create and add a user to the cicd_demo project.

Step 3:Confi gure a private network for the project and connect it to an external gateway so that the Jenkins, Git andworkload VMs can be assigned fl oating IP addresses.

Create a router between the private network and the pre-existing external network:

Page 3: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

3

The fi nal networking setup should look as follows in your topology view:

Step 4:Create a Security Group that exposes HTTP port 8000.

Page 4: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

4

Step 5:Create a new key-pair and save the private key that is downloaded by the browser. (you could also import anexisting key pair).

Save the private Key that is generated by the system.

Page 5: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

5

Step 6:Navigate to the zApp store from where both images and the two application templates would be deployed. First download the OS images that would be used by the application templates to deploy the apps. These include the following:

a. Your fl avor of the OS where Jenkins would run (we chose Ubuntu 14.04 LTS loaded with the Jenkins software and Java for this demo)

b. A vanilla Ubuntu 14.04 image to deploy GIT as well as run our application

Navigate to zApp Store and then to “images” and select the right image and import it. Alternatively you could upload your own OS image.

Select the appropriate application properties in the next step:

Page 6: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

6

Upon successful deployment you can see the deployed app on the “Apps” tab in the project view:

Clicking on the application will show its progress in the summary view. Note that even if the application status is shown as completed it often takes more time for the Git VM completely bootstrap and initialize (approximately 15 minutes.) Bulk of the time is spent in downloading the bits from the internet.

Next, deploy the Jenkins Application template as follows:

Select the appropriate properties for the application:

Page 7: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

7

Now that you have deployed both Git and Jenkins templates you should see 2 applications listed under the “Apps” view of your project:

Select the Jenkins Application card to see details of the application stack. You will see all the components that make up this application, including the network artifacts as well as the VM. Selecting “Show More” will show you the fl oating IP assigned to the Jenkins Server.

Page 8: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

8

Use the IP address listed in the application output to connect to the Jenkins server and confi gure it. The Jenkins application for this demo instance would be reachable at http://10.20.26.236:8080

Now that you have successfully deployed Jenkins server you need to confi gure Jenkins to provision your ZeroStack Project as the place to confi gure new worker VMs. Select “Confi gure System” as shown below:

Page 9: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

9

Use the IP address listed in the application output to connect to the Jenkins server and confi gure it. The Jenkins application for this demo instance would be reachable at http://10.20.26.236:8080

Page 10: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

10

Test your connection to ensure that Jenkins can successfully provision worker VMs on your project.

Select the Advanced button (just below Test Connection in the image above) to confi gure additional options for the cloud:

Page 11: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

11

Now Click on the “Add” Cloud Instance Templates to add the confi guration of worker templates.

Add the image you would like Jenkins workers to be created from, the VM fl avor, the network from where IP addresses should be assigned (this would be the private network created at the beginning of this process). Add the SSH private key that would be used by the worker VMs to connect to target deployment VMs using password-less SSH.

Page 12: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

12

Select the “SSH user name with private key” option. Provide the username that would be used for passwordless ssh login. In this case its “ubuntu”. Provide the private key that was generated by the system in step 5. Click the “add” button.

Once you are taken back to the main confi guration page click on the “Advanced” button to further confi gure the worker template. One of the pieces of data needed could be a bootstrap script that needs to be injected into the worker VM at the time of its creation. If your environment has such a need then you can do so by creating a script fi le that would be executed at bootstrap. Perform the steps below:

Page 13: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

13

For this demo, the worker nodes would be used to build and install a GoLang binary. As a result it would need GNU make and the Golang packages. The following script does the job for our demo. Your specifi c case could be different depending on what application are being deployed in the worker nodes:

#!/bin/shset -e -x

apt-get --yes --quiet updateapt-get --yes --quiet install make golang

Give a name to your script and save it:

Return to the Jenkins confi guration screen and click on the “Advanced” button to complete confi guration of worker template.

Page 14: DATA SHEET Simplifi ed CICD with Jenkins and Git on …go.zerostack.com/.../images/SolutionBrief_ZeroStack_SimplifiedCICD.pdf1 Simplifi ed CICD with Jenkins and Git on the ZeroStack

@ZeroStackInc [email protected] www.zerostack.com

Data Sheet: Simplifi ed CICD with Jenkins and Git on the ZeroStack Platform

14

Now we are ready to spawn worker VMs via Jenkins. This can be done automatically or via the “Manage Nodes” option.