Professional Documents
Culture Documents
Lecture 8
‹#›
Review - React
● React is a JavaScript library for building user interfaces.
‹#›
Review - Redux
Redux is a predictable state container for JavaScript apps.
‹#›
Review - Docker
Docker is a technology designed to simplify the
development, deployment and run applications through
the use of containers.
‹#›
Review – Node.JS
Node.Js is a run-time environment that executes
JavaScript code outside of a browser.
‹#›
Review - Nginx
Nginx is a web server which can also be used as a
reverse proxy, load balancer, mail proxy and HTTP
cache.
‹#›
Sharks
Demo
‹#›
Outline
● Continuous Delivery
● Slide taken from
http://www.slideshare.net/winggundamth/joomla-
continuous-delivery-with-docker
‹#›
Lecture 8
● Why use continuous integration?
● EBS
● EC2
‹#›
Why Continuous Delivery?
‹#›
‹#›
‹#›
‹#›
Continuous delivery
‹#›
Continuous Integration
‹#›
Continuous Delivery versus Continuous Integration
Continuous Integration
Continuous Delivery
Source: https://confluence.atlassian.com/bamboo/understanding-the-bamboo-ci-server-289277285.html
● Continuous delivery includes the deployment of the code ‹#›
● Continuous integration is just the automated building of the code.
What is Continuous Integration?
Source: https://confluence.atlassian.com/bamboo/understanding-the-bamboo-ci-server-289277285.html
● When you commit your code to the code repository like bitbucket or github, the
repository server automatically notifies the continuous integration server.
● The continuous integration server running on a different machine will
automatically do the following (build process):
● Compile the code
● Run unit tests
● Run integration test ‹#›
● Package the code
What is Continuous Integration?
Source: https://confluence.atlassian.com/bamboo/understanding-the-bamboo-ci-server-289277285.html
● Finally continuous integration systems can also automatically deploy your code
onto:
● A private server
● A public server
● The cloud
● Etc.
‹#›
Continuous Integration Software
● Bamboo
● By Atlassian
● Jenkins
● Large complex system
● Drone IO
● Simple
● Etc.
‹#›
Why use Docker for Continuous
Delivery?
● Typical Continuous Integration without Docker involved:
‹#›
Why use Docker for Continuous Delivery?
Benefits:
● Nullify the issue of inconsistent environment setups
● Any machine that is running a Docker can use a
Docker Image
● Save time on build and set up processes
● Allow developers to run tests in parallel
● Separation of concerns in DevOps: developers can
focus on developing apps and system administrators
can focus on deployment
● Improved Version Control by committing changes to
your Docker images for standardizing environments
‹#›
Drone IO
● Drone is a Continuous Integration platform built on Docker
● docker pull drone/drone
‹#›
Where can I get Drone?
● The easiest way to use Drone is to use the hosted Drone service
from the Drone web site:
● https://drone.io/
● This effective means you will get a drone server in the cloud
‹#›
Where can I get Drone?
● Drone is also an open source project, so you can download the
code from the open source project and install it anywhere for free.
‹#›
Main configuration file
● The main configuration file for Drone is .drone.yml which needs to be placed in the root of
your directory.
● The slides for coding Drone is obtained from the following web site
● http://readme.drone.io/usage/overview/
‹#›
Hooks
● Once activated, every commit and pull request automatically send
a hook from your CVS (Concurrent Version System) to Drone
● The hooks instruct Drone to execute a new build using the
instructions in the .drone.yml file.
build:
image: golang
commands:
- python get
- python build
- python test
‹#›
Cloning
● Hooks specify commit details including branch and commit hash.
Drone will automatically clone and checkout the commit into the
build workspace:
‹#›
Commands
● Drone previously cloned your source code into the build
workspace.
● The build workspace is mounted into your Docker container at
runtime as a volume.
● This means your code is cloned outside of the build container but
your build commands are run inside of the build container.
build:
image: golang
commands:
- python get
- python build
- python test ‹#›
Services
● Drone supports launching separate, ephemeral Docker containers as part of the
build process. This is useful, for example, if you require a database for running
your unit tests.
build:
image: golang
commands:
- python get
- python build
- python test
compose:
database:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=mysecretpassword
‹#›
Deployments
● Drone supports a large number of publish and deployment capabilities through
external plugins. Plugins are Docker containers that are automatically
downloaded, attach to your build, and execute a very specific publish or
deployment task.
● The code is only deployed if all the tests are passed
● Example .drone.yml configuration with the Docker publish plugin:
build:
image: golang
commands:
- python get
- python build
- python test
publish:
docker:
username: octocat
password: password
email: octocat@github.com ‹#›
repo: octocat/hello-world
Testing JavaScript Code
‹#›
Jasmine
● Jasmine is a behavior-driven development framework for testing
JavaScript code.
● And it has a clean, obvious syntax so that you can easily write
tests.
‹#›
A suite of tests
● In Jasmine you use describe to define a suite of tests.
Description for the whole suite of tests
false.
● Jasmine will then pass or fail the spec.
expect(message).toMatch(/bar/);
expect(message).not.toMatch(/quux/);
});
‹#›
toBeDefined Matcher
expect(a.foo).toBeDefined();
expect(a.bar).not.toBeDefined();
});
‹#›
Jasmine’s Default Matchers
expect(array).toContain(member);
expect(fn).toThrow(string);
expect(fn).toThrowError(string);
expect(instance).toBe(instance);
expect(mixed).toBeDefined();
expect(mixed).toBeFalsy();
expect(mixed).toBeNull();
expect(mixed).toBeTruthy();
expect(mixed).toBeUndefined();
expect(mixed).toEqual(mixed);
expect(mixed).toMatch(pattern);
expect(number).toBeCloseTo(number, decimalPlaces);
expect(number).toBeGreaterThan(number);
expect(number).toBeLessThan(number);
expect(number).toBeNaN();
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledTimes(number);
expect(spy).toHaveBeenCalledWith(...arguments);
Please see this URL to get examples that use the above: ‹#›
http://jasmine.github.io/2.5/introduction.html
Setup and Teardown
The beforeEach and afterEach functions are called before each spec is executed and after
each spec is executed respectively.
beforeEach(function() {
foo += 1;
});
afterEach(function() {
foo = 0;
});
beforeAll (function() {
foo = 1;
});
afterAll (function() {
foo = 0;
});
beforeEach(function() {
foo = {
setBar: function(value) {
bar = value; It says we are interested in monitoring the
} function calls to the setBar function of the foo
};
spyOn(foo, 'setBar'); object
foo.setBar(123);
foo.setBar(456);
}); Checks whether foo.setBar has
been called at least once
it("tracks that the spy was called", function() {
expect(foo.setBar).toHaveBeenCalled();
});
‹#›
Lets Get Back to Talking
about Cloud Computing!
‹#›
Amazon Web Services
(AWS)
● Amazon Web Services (AWS) is by far the most
popular provider of cloud services.
● AWS offers the largest range of services
● Over 700
‹#›
AWS History
● Amazon was arguably the first company to offer an
extensive and thorough set of cloud-base services
● Amazon started as an on-line bookstore in 1995
● Expanded to CDs, DVDs, computer hardware, etc.
‹#›
‹#›
Regions and Edge Locations
● Regions
● Used to run applications and workloads to reduce latency to end-users.
● Basically where the work gets done.
● Edge locations
● Helps lower latency and improve performance by caching data closer to the
user.
‹#›
● Only Route 53 and CloudFront services are provided at edge locations
AWS Regions & Availability Zones
‹#›
Security Groups
● AWS provides security groups, which act like built-in
firewalls for your virtual servers.
● When you launch an instance, you associate one or more
security groups with the instance.
● You can control how accessible your instances are by
configuring security group rules – from totally public to
completely private, or somewhere in between.
‹#›
AWS Multi-tier Security Groups
‹#›
Amazon Simple Storage Service
(S3)
● Storage for the internet
● Designed to make web-scale computing easier for
developers.
● Data can be accessed from anywhere
● For example S3 can be used to store pictures for a web
site.
● S3 is designed for 99.999999999% durability and 99.99%
availability of objects over a given year.
● Highly scalable, reliable, fast and inexpensive
● Dropbox stores data on S3.
‹#›
Amazon Simple Storage Service (S3)
● To store an object on S3 you upload the file you want to store into a bucket.
● Think of objects as files
● You can set permissions on the object as well as any metadata
● Buckets are logical containers for objects
● Limit of 100 buckets per account
● Store an unlimited number of objects per bucket
● You can choose the geographical region where Amazon stores the S3 bucket ‹#›
and its contents.
S3 Pricing
‹#›
Amazon Elastic Block Store(EBS)
● Block level storage volumes for use with Amazon EC2 (Amazon
Elastic Compute Cloud) instances
● Your EC2 instance (virtual machine) can mount EBS volumes and
use it to store the operating system and/or data.
● EBS snapshots are durable and can be stored in S3
● EBS is particularly suited for applications that require
● Database
● File system
‹#›
Amazon Elastic Block Store (EBS)
● EBS volumes are highly available and reliable storage which can
be attached to any running instance in the same availability zone.
● EBS volumes persist independently from the life of the instance.
● When EBS volumes are not attached to an EC2 instance, you pay
only for the cost of the storage. ‹#›
Amazon Elastic Block
Store (EBS)
● Can use EBS to create RAID configuration for a server
● You can use RAID 0 or RAID 1+0 (RAID 10)
‹#›
EBS Use Case
● The EBS service is a virtual hard drive connected through
the network.
● Before EBS existed the local HDD of the virtual machine
instance was used for storage.
● However, the storage was ephemeral, meaning it will
expensive.
● EBS decouples the lifecycle of the data persistence from
the lifecycle of an EC2 instance.
‹#›
EBS pricing
● $0.10 per GB/month for standard EBS volume
● $0.10 per 1 million IO requests
● $0.125 per GB-month for IOPS EBS volume
‹#›
EBS Best Practices
becomes unavailable.
● For 20GB or less volumes the expected annual failure rate is 0.1%
- 0.5% compared to commodity HDD which typically have failure
rate of 4%
● EBS can be configured to take periodic snapshots of your volumes
‹#›
onto S3.
EBS versus S3
requirements.
● Pay for only what you use.
● Choose Linux or Windows
● Deploy across regions and availability zones for reliability
‹#›
Amazon Machine Image(AMI)
● Standard images
● Community images
‹#›
Infrastructure and Applications
‹#›
EC2 Instance Types
‹#›
http://aws.amazon.com/ec2/instance-types/
Billing Models
‹#›
Spot Instance Price History
‹#›