DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with...

14
1 DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform 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, is because the Jenkins plugin does not yet support multiple business units and, hence, can only point to the default BU. @ZeroStackInc sales@zerostack.com www.zerostack.com

Transcript of DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with...

Page 1: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

1

DATA SHEETSimplified CICD with Jenkins and Git on the ZeroStack Platform

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, is because the Jenkins plugin does not yet support multiple business units and, hence, can only point to the default BU.

@ZeroStackInc [email protected] www.zerostack.com

Page 2: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

2

@ZeroStackInc [email protected] www.zerostack.com

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

Step 3: Configure a private network for the project and connect it to an external gateway so that the Jenkins, Git and workload VMs can be assigned floating IP addresses.

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

Page 3: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

3

@ZeroStackInc [email protected] www.zerostack.com

The final 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 Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

4

@ZeroStackInc [email protected] www.zerostack.com

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

Save the private Key that is generated by the system.

Page 5: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

5

@ZeroStackInc [email protected] www.zerostack.com

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 flavor 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.an existing key pair).

Select the appropriate application properties in the next step:

Page 6: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

6

@ZeroStackInc [email protected] www.zerostack.com

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 Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

7

@ZeroStackInc [email protected] www.zerostack.com

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 floating IP assigned to the Jenkins Server.

Page 8: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

8

@ZeroStackInc [email protected] www.zerostack.com

Use the IP address listed in the application output to connect to the Jenkins server and configure 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 configure Jenkins to provision your ZeroStack Project as the place to configure new worker VMs. Select “Configure System” as shown below:

Page 9: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

9

@ZeroStackInc [email protected] www.zerostack.com

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

Page 10: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

10

@ZeroStackInc [email protected] www.zerostack.com

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 configure additional options for the cloud:

Page 11: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

11

@ZeroStackInc [email protected] www.zerostack.com

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

Add the image you would like Jenkins workers to be created from, the VM flavor, 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 Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

12

@ZeroStackInc [email protected] www.zerostack.com

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 configuration page click on the “Advanced” button to further configure 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 file that would be executed at bootstrap. Perform the steps below:

Page 13: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

13

@ZeroStackInc [email protected] www.zerostack.com

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 specific case could be different depending on what application are being deployed in the worker nodes:

#!/bin/sh set -e -x

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

Give a name to your script and save it:

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

Page 14: DATA SHEET Simplified CICD with Jenkins and Git on the ... · DATA SHEET Simplified CICD with Jenkins and Git on the ZeroStack Platform In the technical article we will walk through

14

@ZeroStackInc [email protected] www.zerostack.com

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