acammies
2018-04-10 8f75582e133d7375a691e1e33c1657df5060f3f3
Merge pull request #125 from rht-labs/exercise2/openshift-configs

Exercise2/openshift configs
2 files added
2 files modified
82 ■■■■■ changed files
exercises/2-attack-of-the-pipelines/README.md 76 ●●●●● patch | view | raw | blame | history
exercises/README.md 6 ●●●● patch | view | raw | blame | history
exercises/images/exercise2/ansible-success.png patch | view | raw | blame | history
exercises/images/jenkins-docker-star-wars.jpg patch | view | raw | blame | history
exercises/2-attack-of-the-pipelines/README.md
@@ -306,7 +306,76 @@
### Part 3 - Add configs to cluster 
> _In this exercise; we will use the OpenShift Applier to drive the creation of cluster content required by the app such and MongoDB and the Apps Build / Deploy Config_
4. TODO - waiting for Justins example before proceeding here
4. On your terminal navigate to the root of the `todolist-fe` application. The app contains a hidden folder called `.openshift-applier`. Move (cd .openshift-applier) into this directory and you should see a familiar looking directory structure for an ansible playbook.
```
.openshift-applier
├── README.md
├── apply.yml
├── inventory
│   ├── group_vars
│   │   └── all.yml
│   └── hosts
├── params
│   ├── build
│   ├── dev
│   └── test
├── requirements.yml
└── templates
    ├── todolist-api-build.yml
    └── todolist-api-deploy.yml
```
where the following
    * the `apply.yml` file is the entrypoint.
    * the `inventory` contains the objects to populate the cluster with.
    * the `params` contains the variables we'll apply to the `templates`
    * the `templates` required by the app. These include the Build, Deploy configs as well as the services, health checks and other app definitions.
4. There are a few updates to these manifests we need to make before applying the cluster content. In the `apply.yml` update the namespace `<YOUR_NAME>` variables accordingly.
```yaml
    ci_cd_namespace: donal-ci-cd
    dev_namespace: donal-dev
    test_namespace: donal-test
```
4. In the `params` folder update the `dev` and `test` files with the correct `<YOUR_NAME>` as you've done above. Example for the `dev` file
```bash
PIPELINES_NAMESPACE=donal-ci-cd
NAME=todolist-fe
DEPLOYER_USER=jenkins
APP_TAG=latest
NAMESPACE=donal-dev
```
4. With those changes in place we can now run the playbook. First install the `openshift-applier` dependency and then run the playbook. This will populate the cluster with all the config needed for the front end app.
```bash
$ ansible-galaxy install -r requirements.yml --roles-path=roles
$ ansible-playbook apply.yml -i inventory/
```
![ansible-success](../images/exercise2/ansible-success.png)
4. Back on your terminal navigate to the root of the `todolist-api` application. Open the `.openshift-applier` directory. The same layout of the frontend app should be visible with one noticeable difference; the api requires a `MongoDB` to connect to at runtime.
4. In the `apply.yml` update the namespace `<YOUR_NAME>` variables accordingly. For example:
```yaml
    ci_cd_namespace: donal-ci-cd
    dev_namespace: donal-dev
    test_namespace: donal-test
```
4. In the `params` folder update the `dev` and `test` files with the correct `<YOUR_NAME>` as you've done above. Example for the `dev` file:
```bash
PIPELINES_NAMESPACE=donal-ci-cd
NAME=todolist-api
DEPLOYER_USER=jenkins
APP_TAG=latest
NAMESPACE=donal-dev
```
4. Finally; run the applier and install it's dependencies to run the content into the cluster
```bash
$ ansible-galaxy install -r requirements.yml --roles-path=roles
$ ansible-playbook apply.yml -i inventory/
```
### Part 4 - Build > Bake > Deploy 
> _In this exercise; we take what we have working locally and get it working in OpenShift_
@@ -333,7 +402,7 @@
#### Part 4a - Build
5. With the BuildConfig and DeployConfig in place from previous steps; Log into Jenkins and create a `New Item` which is jenkins speak for a new job configuration. ![new-item](../images/exercise2/new-item.png)
5. With the BuildConfig and DeployConfig in place for both our apps (`*-fe` & `*-api`) from previous steps; Log into Jenkins and create a `New Item`. This is just jenkins speak for a new job configuration. ![new-item](../images/exercise2/new-item.png)
5. Name this job `dev-todolist-fe-build` and select `Freestyle Job`. All our jobs will take the form of `<ENV>-<APP_NAME>-<JOB_PURPOSE>`. ![freestyle-job](../images/exercise2/freestyle-job.png)
@@ -532,11 +601,12 @@
- Pipeline Tasks
    * Add pipeline for <master> branch for each project.
    * Use `test-` instead of `dev-` across all config and names
    * Do the `.openshift-applier` steps as part of the pipeline.
- Promote build
    * Create a _promote-to-uat_ phase after the <master> branch deploy
    * Create a `uat` env using the OpenShift Applier as seen before
    * Tag and promote the image without rebuilding after the `test-**-deploy`
- MongoDB tasks
- MongoDB tasks
    * Add MongoDB Stateful set for the UAT environment (or test)
    * Inject MongoDB config into the NodeJS app using config map & secrets.
    * Improve the security of the DB by making the user /passwords randomly generated
exercises/README.md
@@ -1,9 +1,9 @@
# Enablement Material
> Red Hat Open Innovation Labs Enablement Material. 
![jenkins-docker-star-wars](../images/exercise1/jenkins-docker-star-wars.jpg)
![jenkins-docker-star-wars](./images/jenkins-docker-star-wars.jpg)
This is a collection of practices and exercises to take a learner through a four day simulated residency experience. Learners can expect to be exposed to labs practices such as [Event Storming](https://rht-labs.github.io/practice-library/practices/event-storming/), [Social Contract](https://rht-labs.github.io/practice-library/practices/social-contract/) and [Impact Mapping](https://rht-labs.github.io/practice-library/practices/impact-mapping/) amoung many more which can be found in our (Practice Library)[https://rht-labs.github.io/practice-library/]. Learners will also be exposed to `Labs CI/CD` - how we use OpenShift & Ansible in conjunction with Jenkins to automate build and deploy of a sample todolist application and it's required infrastructure.
This is a collection of practices and exercises to take a learner through a four day simulated residency experience. Learners can expect to be exposed to labs practices such as [Event Storming](https://rht-labs.github.io/practice-library/practices/event-storming/), [Social Contract](https://rht-labs.github.io/practice-library/practices/social-contract/) and [Impact Mapping](https://rht-labs.github.io/practice-library/practices/impact-mapping/) amoung many more which can be found in our [Practice Library](https://rht-labs.github.io/practice-library/). Learners will also be exposed to `Labs CI/CD` - how we use OpenShift & Ansible in conjunction with Jenkins to automate build and deploy of a sample todolist application and it's required infrastructure.
## Learner pre-requisites
 - OCP CLI v3.9
@@ -12,7 +12,7 @@
 - Git Installed
 - Access to an OpenShift cluster `oc login -u <username> -p <password> <cluster_url>`
> Or Download the tools-container containing most of these (TODO)
> (TODO) Download the tools-container containing required Ansible and OpenShift tooling pre-installed
______
exercises/images/exercise2/ansible-success.png
exercises/images/jenkins-docker-star-wars.jpg