Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi tier app #53

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions labs/shipped-application-level-policy/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Shipped - Define and Enforce Application-level Policies


Application-level polices are rules that monitor your application on a running container. You create these rules to monitor memory management, disk read and write management, task management, network management and load balancing. Alerts are generated when thresholds exceed your specifications.

![](posts/files/shipped-application-level-policy/assets/1.PNG)

For this lab, we have created a sample program in golang that intentionally leaked memory. We will define a policy to manage the memory.

First fork <a href="https://github.com/CiscoCloud/aie-burnit" target="_blank">aie-burnit</a>. When done, contents are copied from CiscoCloud to your public repo.
Click <a href="https://help.github.com/articles/fork-a-repo/#fork-an-example-repository" target="_blank">here</a> to learn how to fork GitHub.

14 changes: 14 additions & 0 deletions labs/shipped-application-level-policy/2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Create a Project and Add Services

1. Log in to <a href="https://ciscoshipped.io">Shipped UI</a>.

2. Click **Create New Application**.

3. Enter your new project name, for example, applicationPolicy, click **Start Composing**.
4. Click **Add an existing repository**, and search for aie-burnit.

![](posts/files/shipped-application-level-policy/assets/2.PNG)

1. Click **Save Project** to trigger a build for services that are added.

![](posts/files/shipped-application-level-policy/assets/3.PNG)
46 changes: 46 additions & 0 deletions labs/shipped-application-level-policy/3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Create Environment

1. Click <b>New Environment</b>.
1. Enter the name for the environment, Test, for example.
1. Click **Save**.

## Deploy the Service

1. Select aie-burnit service from the left side, and choose the environment (Test), then click **Deploy Build**.
Your app started running.

![](posts/files/shipped-application-level-policy/assets/5.PNG)

1. Click **Settings** then click **Alerting Thresholds**.

![](posts/files/shipped-application-level-policy/assets/6.PNG)

1. Scroll down and click **Add New Policy**.

![](posts/files/shipped-application-level-policy/assets/7.PNG)

1. Enter a name for the policy.

![](posts/files/shipped-application-level-policy/assets/8.PNG)

1. Select a metric, apply a condition to it, and select an action when the condition is met.

![](posts/files/shipped-application-level-policy/assets/9.PNG)

1. Click **Add**.
The policy is added. This policy indicates that when memory use is greater than 75%, then Scale Up the container from 1 to 2. When memory use is greater than 75% within 2 containers, then scale up by another 1 container, that is, from 2 to 3 containers. Scaling up will stop from here because 3 is the maximum container specified.

![](posts/files/shipped-application-level-policy/assets/10.PNG)

The following example shows a policy with an alarm condition. When memory use greater than 75%, then trigger the alarm.

![](posts/files/shipped-application-level-policy/assets/11.PNG)

You can scale the percentage by moving the green dot in the spiderweb chart as shown.

![](posts/files/shipped-application-level-policy/assets/12.PNG)

There are two set of dots, move the inner green dots (highlighted) to set the minimum threshold and the outer green dots (highlighted) to set the maximum threshold value. The values are auto updated as you move these dots

1. Click **Save** and go back to environment.

26 changes: 26 additions & 0 deletions labs/shipped-application-level-policy/4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## aie-burnit Usage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should add snapshot of deploy page with link to open aie-burnit app.
It not very cleat how memory setting page is opened.

We have deployed app up and running on test env.

![](assets/13.PNG)

We can specify the no of MB's by which we can start memory leak in app to see how policy response to our app.

So we are adding 2 and click on update button, once done we will click on resume (it resume app with memory leak.)

![](assets/14.PNG)

As we can see memory leak has been increasing. As Memory leak reached 75% of policy, we will get alert, in shipped ui.

We can see alert under Run page >

![](assets/15.PNG)

After reach to threshold we have stopped memory leak and capture the below output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we we need to highlight
2/2 instances are running and service scaled up from 1-2 instances.


![](assets/16.PNG)


Below are the related metrics graphs

![](assets/17.PNG)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions labs/shipped-multi-tier/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Shipped - Multi-tier Application

Shipped enables you to build a multi-tier application to allow any application developed and distributed among more than one tier. The multi-tier app logically separates the different application-specific tier. This division allows each tier to be separately developed, tested, executed, and reused.

Shipped provides a sample multi-tier app containing two services: vote-api and vote-ui.

<table>
<thead>
<th>
Service Name
</th>
<th>
Technology
</th>
<th>
Details
</th>
</thead>
<tbody>
<tr>
<td>
<a href="https://github.com/CiscoCloud/vote-api" target="_blank">vote-api</a>
</td>
<td>
golang
</td>
<td>
$host_api_url/data<br/>
/GET <br/>
/POST
Request Body {"count" : "1"}<br/>
<a href="https://github.com/CiscoCloud/vote-api" target="_blank">more detail</a>
</td>
</tr>
<tr>
<td> <a href="https://github.com/CiscoCloud/vote-ui" target="_blank">vote-ui</a></td>
<td>express js</td>
<td>Consume the above rest api into ui application. for <a href="https://github.com/CiscoCloud/vote-ui" target="_blank">more detail</a></td>
</tr>
<tr>
<td>vote-db</td>
<td>postgres</td>
<td>Creating DB from datastore in shipped.</td>
</tr>
</tbody>
</table>


## Prerequisite

Fork <a href="https://github.com/CiscoCloud/vote-api" target="_blank">vote-api</a> and <a href="https://github.com/CiscoCloud/vote-ui" target="_blank">vote-ui</a> from Cisco Cloud. When done, contents are copied from Cisco Cloud to your public repo.

Click <a href="https://help.github.com/articles/fork-a-repo/#fork-an-example-repository" target="_blank">here</a> to learn how to fork GitHub.

22 changes: 22 additions & 0 deletions labs/shipped-multi-tier/2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Create a Project and Add Services


1. Log in to <a href="https://ciscoshipped.io">Shipped UI</a>.
2. Click **Create New Application**.
3. Enter your new project name, for example, multitierapp, click **Start Composing**.
4. Click **Add an existing repository**, and search for vote-api and vote-ui.

![](posts/files/shipped-multi-tier/assets/1.png)

6. Click **Datastores** and select **Postgres**.
7. Click **Add Service**.

![](posts/files/shipped-multi-tier/assets/2.png)

1. Click **Save Project** to trigger a build for all the services added.






98 changes: 98 additions & 0 deletions labs/shipped-multi-tier/3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
## Create an Environment for Deployment


1. Click <b>New Environment</b>.
1. Enter the name for the environment, Test for example.
1. Click **Save**.

![](posts/files/shipped-multi-tier/assets/4.png)

You are now ready to deploy *Postgres*, *vote-api*, and *vote-ui* services. The order of service deployment is important. Because Postgres has a set of default environment variables that other two services depend on, therefore it is the first to be deployed. After Postgres is deployed, you can copy those variables and apply them to vote-api and vote-ui.

### Deploy Postgres


1. Click the **Deployment** tab.

![](posts/files/shipped-multi-tier/assets/deploy-postgres.png)

1. Select **Postgres** and the environment (Test), click **Deploy Build**.

1. Copy the environment variables of Postgress, which you need to set for vote-api and vote-ui.

2. Click **Settings**.
3. Scroll down to the **Deployment Configurations** section.
4. Copy the environment variables.

![](posts/files/shipped-multi-tier/assets/postgres-settings.png)


### Deploy vote-api

1. Click **Back to Environments**.

![](posts/files/shipped-multi-tier/assets/vote-api.png)

1. Click the vote-api icon, then **Settings**.

3. Scroll down to the **Deployment Configurations** section.
4. Click **Add New variable**, and enter the key value pair.

In addition to the variables copied from Postgres, you also need to set the API endpoint so the UI application will read the same variables.

**Note**: Do not change the key value.

The following example shows the vote-api variables.

![](posts/files/shipped-multi-tier/assets/vote-api-cfg.png)


<table><tr>
<td>Key</td>
<td>Value</td>
</tr>
<tr>
<td>SEED_PORT</td>
<td>4001</td>
</tr>
<tr>
<td>HOST_VOTE_API</td>
<td>http://test--multitierapp--vote-api--254b61.gce.shipped-cisco.com</td>
</tr>
<tr>
<td>HOST_VOTE_UI</td>
<td>http://test--multitierapp--vote-ui--247fa6.gce.shipped-cisco.com</td>
</tr>
<tr>
<td>SEED_HOST</td>
<td>test--multitierapp--postgres--d1329f-0.service.consul</td>
</tr>
<tr>
<td>HOST_POSTGRES</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just need to copy single environment variable. HOST_POSTGRES

Once Dinesh fix is pushed, avoid asking user to copy SEED_HOST, PORT etc.

<td>http://test--multitierapp--postgres--d1329f.gce.shipped-cisco.com</td>
</tr>
</table>

1. Click **Save**.

1. Click **Back to Environments**.
2. Click **Deploy Build**.


### Deploy vote-ui

**Note**: Do not deploy vote-ui until vote-api is first deployed.

1. Click the vote-ui icon, then click **Deploy Build**.

![](posts/files/shipped-multi-tier/assets/vote-ui-deploy.png)

1. Click the green button when the build is done.

![](posts/files/shipped-multi-tier/assets/vote-ui-deploy-sucess.png)

The following screen is displayed.

![](posts/files/shipped-multi-tier/assets/15.png)


Binary file added labs/shipped-multi-tier/assets/1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/10.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/11.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/12.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/13.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/14.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/15.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labs/shipped-multi-tier/assets/3.PNG
Binary file added labs/shipped-multi-tier/assets/4.PNG
Binary file added labs/shipped-multi-tier/assets/5.PNG
Binary file added labs/shipped-multi-tier/assets/6.PNG
Binary file added labs/shipped-multi-tier/assets/7.PNG
Binary file added labs/shipped-multi-tier/assets/8.PNG
Binary file added labs/shipped-multi-tier/assets/9.PNG
17 changes: 17 additions & 0 deletions labs/shipped-multi-tier/assets/byod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div>

<h3>Software Requirements</h3>
<ul>
<li>To work on this lab on your own machine, you must be compatible with <a href="https://www.vagrantup.com/">Vagrant</a>, and <a href=https://www.virtualbox.org/wiki/End-user_documentation">Virtual Box</a>.</li>
<li>Shipped supports Mac OS X, Windows 7 or higher, and Ubuntu 13.04 or higher. </li>

<li>Shipped supports any modern browser, but Chrome gives the best experience.</li>
</ul>


<h3>Hardware Requirements</h3>
<ul>
<li>Total Memory: Minimum 4 GB, but 8 GB is better.</li>
<li>Available Storage: Minimum 20 GB free, but 50 GB of Disk Storage free is better.</a></li>
</ul>
</div>
52 changes: 52 additions & 0 deletions labs/shipped-multi-tier/assets/shipped-multi-tier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"labId": "shipped-multitier-app",
"title": "Shipped 8 - Deploy Multi-tier App Using shipped",
"byod": true,
"time": "30",
"slug": "Set up quickly in Shipped",
"files": [
{"title": "1.md"},
{"title": "2.md"},
{"title": "3.md"}
],
"tags": [
{"title": "Shipped"},
{"title": "Cloud"}
],
"related": [
{
"labId": "shipped-first-time",
"title": "Shipped 1 - Using Shipped the First Time"
},
{
"labId": "shipped-quick-start",
"title": "Shipped 2 - Quick Start"
},
{
"labId": "shipped-import-project",
"title": "Shipped 3 - Shipped import existing project"
},
{
"labId": "shipped-bootstrap-spark",
"title": "Shipped 4 - Bootstrap Project"
},
{
"labId": "shipped-cli-labs",
"title": "Shipped 5 - Shipped Using CLI"
},

{
"labId": "shipped-cicd",
"title": "Shipped 6 - Shipped Continous Integration and Deployment"
},

{
"labId": "shipped-application-level-policy",
"title": "Shipped 7 - Define and enforce application level policies"
},
{
"labId": "shipped-multitier-app",
"title": "Shipped 8 - Deploy Multi-tier App Using shipped"
}
]
}
Binary file added labs/shipped-multi-tier/assets/vote-api-cfg.png
Binary file added labs/shipped-multi-tier/assets/vote-api.png
Binary file added labs/shipped-multi-tier/assets/vote-ui-deploy.png
17 changes: 17 additions & 0 deletions labs/shipped-multi-tier/byod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div>

<h3>Software Requirements</h3>
<ul>
<li>To work on this lab on your own machine, you must be compatible with <a href="https://www.vagrantup.com/">Vagrant</a>, and <a href=https://www.virtualbox.org/wiki/End-user_documentation">Virtual Box</a>.</li>
<li>Shipped supports Mac OS X, Windows 7 or higher, and Ubuntu 13.04 or higher. </li>

<li>Shipped supports any modern browser, but Chrome gives the best experience.</li>
</ul>


<h3>Hardware Requirements</h3>
<ul>
<li>Total Memory: Minimum 4 GB, but 8 GB is better.</li>
<li>Available Storage: Minimum 20 GB free, but 50 GB of Disk Storage free is better.</a></li>
</ul>
</div>
Loading