Skip to content
Permalink
Browse files

Merge pull request #39 from microsoft/staging

Added Lab 3
  • Loading branch information...
sabbour committed Sep 10, 2019
2 parents 5629efb + 32e75ed commit 8475f51350234693219aa623abab0f4a8c1092c3
4 _entries/01-01 prerequisites.md 100644 → 100755
@@ -47,7 +47,7 @@ Select **Show advanced settings**

![Select show advanced settings](media/cloudshell/1-mountstorage-advanced.png)

Set the **Storage account** and **File share** names to your resource group name (all lowercase, without any special characters), then hit **Create storage**
Set the **Storage account** and **File share** names to your resource group name (all lowercase, without any special characters). Leave other settings unchanged, then hit **Create storage**

![Azure Cloud Shell](media/cloudshell/2-storageaccount-fileshare.png)

@@ -86,5 +86,3 @@ The OpenShift CLI (oc) is now installed.

#### GitHub Account
You'll need a personal GitHub account. You can sign up for free [here](https://github.com/join).
=======

4 _entries/02 lab rating app.md 100644 → 100755
@@ -1,9 +1,9 @@
---
sectionid: lab-ratingapp
sectionclass: h1
title: Lab 1 - Rating App
title: Lab 1 - Go Microservices
type: nocount
is-parent: yes
---

Now that you have your environment provisioned and the prerequisites fulfilled, it is time to start working on the labs.
Now that you have your environment provisioned and the prerequisites fulfilled, it is time to start working on the labs.
2 _entries/02-02 project.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: createproject
sectionclass: h2
title: Create project
title: Create Project
parent-id: lab-ratingapp
---

2 _entries/02-03 mongodb.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: mongodb
sectionclass: h2
title: Deploy mongoDB
title: Deploy MongoDB
parent-id: lab-ratingapp
---

2 _entries/02-04 api.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: ratingsapi
sectionclass: h2
title: Deploy ratings API
title: Deploy Ratings API
parent-id: lab-ratingapp
---

2 _entries/02-05 web.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: ratingsweb
sectionclass: h2
title: Deploy ratings frontend
title: Deploy Ratings frontend
parent-id: lab-ratingapp
---

2 _entries/02-06 networkpolicy.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: networkpolicy
sectionclass: h2
title: Create network policy
title: Create Network Policy
parent-id: lab-ratingapp
---

2 _entries/02-07 scaling.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: scaling
sectionclass: h2
title: Scaling
title: Scaling ARO Cluster
parent-id: lab-ratingapp
---

4 _entries/03 lab cluster app.md 100644 → 100755
@@ -1,7 +1,7 @@
---
sectionid: lab-clusterapp
sectionclass: h1
title: Lab 2 - OSToy!
title: Lab 2 - ARO Internals
type: nocount
is-parent: yes
---
---
2 _entries/03-02 deployment.md 100644 → 100755
@@ -59,7 +59,7 @@ Equivalently you can also create this new project using the web UI by selecting

### Download YAML configuration

Download the Kubernetes deployment object yamls from the following locations to your local drive in a directory of your choosing (just remember where you placed them for the next step).
Download the Kubernetes deployment object yamls from the following locations to your Azure Cloud Shell, in a directory of your choosing (just remember where you placed them for the next step).

{% collapsible %}

0 _entries/03-05 storage.md 100644 → 100755
No changes.
0 _entries/03-06 conf-sec-env.md 100644 → 100755
No changes.
0 _entries/03-07 networking.md 100644 → 100755
No changes.
@@ -0,0 +1,7 @@
---
sectionid: lab-cicd
sectionclass: h1
title: Lab 3 - CI/CD
type: nocount
is-parent: yes
---
@@ -0,0 +1,43 @@
---
sectionid: lab3-cdcd-demo-overview
sectionclass: h2
title: CI/CD Demo Overview
parent-id: lab-cicd
---

### CI/CD

With Continuous Integration and Continuous Delivery, you can accelerate the development and deliver of your microservices. Azure Red Hat OpenShift provides seamless supports to open source DevOps & CICD tools, like Jenkins, Nexus, GitHub and SonarQube.

### The OpenShift CI/CD Demo

In this lab, you'll deploy a complete CI/CD demo on Azure Red Hat OpenShift.

Following components will be deployed onto your Azure Red Hat OpenShift cluster.

- A sample Java application, the source code is available at https://github.com/OpenShiftDemos/openshift-tasks
- A sample OpenShift Pipeline, a pre-defined CI/CD pipeline on ARO.
- Jenkins, open source CI/CD engine and automation server.
- Nexus, software artifact repository.
- SonarQube, code quality platform.
- Gogs, a self-hosted Git service.
- PostgreSQL, open source RDBMS database.
- Eclipse Che, web based Eclipse IDE.

The following diagram shows the steps included in the deployment pipeline:

![CI/CD Demo Diagram](/media/cicd-pipeline-diagram.png)

On every pipeline execution, the code goes through the following steps:

- Code is cloned from Gogs, built, tested and analyzed for bugs and bad patterns
- The WAR artifact is pushed to Nexus Repository manager
- A container image (tasks:latest) is built based on the Tasks application WAR artifact deployed on WildFly
- The Tasks app container image is pushed to the internal image registry
- The Tasks container image is deployed in a fresh new container in DEV project
- If tests successful, the pipeline is paused for the release manager to approve the release to STAGE
- If approved, the DEV image is tagged in the STAGE project
- The staged image is deployed in a fresh new container in the STAGE project

To learn more about this CI/CD demo, you can visit [this](https://github.com/nichochen/openshift-cd-demo) GitHub Repo.

@@ -0,0 +1,77 @@
---
sectionid: lab3-deploy-cdcd-demo
sectionclass: h2
title: Deploy CI/CD Demo
parent-id: lab-cicd
---

### Clone the GitHub Repo

To deploy the CI/CD demo, you need to download the required deployment files from GitHub repository `https://github.com/nichochen/openshift-cd-demo.git`.

{% collapsible %}
On your Azure Cloud Shell, clone the OpenShift CI/CD demo repository. Currently ARO supports OpenShift 3.11, you'll need to checkout branch `azure-redhat-openshift-3.11`.

```sh
git clone https://github.com/nichochen/openshift-cd-demo.git -b azure-redhat-openshift-3.11 cicd
```
{% endcollapsible %}

### Deploy the demo

{% collapsible %}


Now you can proceed to deploy the demo by running the script file `provision.sh`, which is under the folder `scripts`. In the following command, we specified to install Eclipse Che, and setting the project name suffix as `aro`.

```sh
./cicd/scripts/provision.sh deploy --enable-che --ephemeral --project-suffix aro
```
{% endcollapsible %}

### Verify the deployment

After the deployment is completed, you can verify the newly created resources.

{% collapsible %}

Run the following command to review the list of projects.

```sh
oc get project
```

You'll see following projects are created by the demo provision script.
```sh
$ oc get project
NAME DISPLAY NAME STATUS
cicd-aro CI/CD Active
dev-aro Tasks - Dev Active
openshift Active
stage-aro Tasks - Stage Active
```

Confirm the status of all related containers is `Running` or `Completed`.

```sh
$ oc get pod -n cicd-aro
```

If the deployment finished successfully, you will see something similar to the following output.
```sh
NAME READY STATUS RESTARTS AGE
che-2-l4q5k 1/1 Running 0 2m
cicd-demo-installer-w46dp 0/1 Completed 0 1m
gogs-1-krr7x 1/1 Running 2 2m
gogs-postgresql-1-fftjn 1/1 Running 0 2m
jenkins-2-mqpwv 1/1 Running 0 3m
nexus-2-8wvwx 0/1 Running 0 2m
nexus-2-deploy 1/1 Running 0 2m
sonardb-1-4b6kg 1/1 Running 0 2m
sonarqube-1-844q7 1/1 Running 0 2m
```

From the Azure Red Hat OpenShift web console, you can see the newly created project and resources as well.

{% endcollapsible %}
@@ -0,0 +1,83 @@
---
sectionid: lab3-run_cicd_pipeline
sectionclass: h2
title: Run CI/CD Pipeline
parent-id: lab-cicd
---

### Run the CI/CD Pipeline

A CI/CD pipeline is created by the demo provision script. Please review the pipeline and trigger an execution.

{% collapsible %}

On OpenShift Web Console, Navigate to project `CICD`. From the side navigation menu, select menu item `Builds`, then `Pipelines`.

You will see there is a pipeline, named `tasks-pipeline`. Click on the name of the pipeline, then you will see the pipeline overview page. In the tab `Configuration`, you will see the definition of the pipeline.

![Pipeline Definition](media/cicd-definition.png)

To run the pipeline, click on button `Start Pipeline`, which is on the top right corner. Then Azure Red Hat OpenShift will start a new execution instance for that pipeline.

{% endcollapsible %}

### Monitor the pipeline

After triggering a pipeline execution, please monitor the execution on the web console.

{% collapsible %}

You will see the execution result of each stage of the pipeline.

![Pipeline Execution](media/cicd-pipeline-view.png)

For detail information, you can click on the link `View Log` of a execution instance to review the real time log output. After clicking `View Log`, you will be navigated to the Jenkins login page. Login with OpenShift credentials and grant all the required permissions to Jenkins, then you will see the log output in Jenkins.

![Pipeline Logs](media/cicd-jenkins-log.png)

{% endcollapsible %}

### Approve pipeline task

You may define steps which required user intervention. You can either approve the request in Azure Red Hat OpenShift web console, or in Jenkins. Please allow the pipeline to promote the deployment from project `Dev` to `Stage`.

{% collapsible %}
When the pipeline execution runs to stage 'Promote to STAGE?' You will see the pipeline is paused and asking for your input.

![Approve Pipeline Task](media/cicd-approve.png)

Click on the link `Input Required` , and you will be navigated to Jenkins. Click button `Promote` in Jenkins to approve the task.
{% endcollapsible %}

### Verify the results

After the pipeline execution is completed, please review the execution result on the web console. You also can login to the Jenkins console to check out the detail.

{% collapsible %}
If everything works fine, you will be albe to see all pipeline stages completed successfully, as it shown below. The sample application was built and deployed into project `Dev` and `Stage`.

![CiCD Result](media/cicd-pipeline-result.png)

You can checkout the status of the application pods in project `Dev` and `Stage`. Following are the commands and sample output.
```sh
$ oc get pod -n dev-aro
NAME READY STATUS RESTARTS AGE
tasks-1-build 0/1 Completed 0 9m
tasks-3-59x64 1/1 Running 0 8m
```

```sh
$ oc get pod -n stage-aro
NAME READY STATUS RESTARTS AGE
tasks-4-v8fzt 1/1 Running 0 7m
```

You can also get the Route of your deployment in project `Dev` or `Stage`, then access the deployment with the URL, in a web browser.

```sh
$ oc get route -n dev-aro
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
tasks tasks-dev-aro.apps.xxxxxxxxxxxx.eastus.azmosa.io tasks 8080 None
```
{% endcollapsible %}

0 comments on commit 8475f51

Please sign in to comment.
You can’t perform that action at this time.