MTI

DevOps

Course planning

  • 12h
    • 3h - Docker
    • 8h - DevOps
    • 2h - Defense
  • Scoring
    • Project / Defense

Main content

Docker

  • Use case and limit
  • Docker machine
  • Dockerfile
  • Docker compose
  • Multiple container​​

DevOps

  • Theorical principle
  • Use case and limit
  • CI / CD practically
  • Dev != Prod
  • Integration

Create a project for production environment

Secondary content

  • Create a server
  • Node.js (Server)
  • MongoDB / Redis (DB / Cache)
  • Cloud

It's your course, so what you want

  • Test​
  • Script
  • Github's hook
  • React / NextJS

DevOps

Why When How

The Why

Why

  • DevOps = Development & Operations
    • Development
    • QA (Quality Assurance)
    • Technology Operations
  • ​Follow agile process
  • Communication issue before technical

"Ops" issues:

  • System stable
  • Performance of current instance

"Dev" issues:

  • Deliver new features frequently
  • Awareness of code impact

Why

  • ​Classical way of working became as complicated as business growth
  • Heavy validation process
  • Too many teams involve in it
  • Too many cost
  • Manage of multiple environment
  • Hard to deploy new feature oftenly

Why

​4 distincts phases:

  1. Continuous integration
  2. Automated deployment (Test env)
  3. Automated test
  4. Automated deployment (Production env)

DevOps

Why When How

The When

When

Use case:

  • ​Easier to adopt DevOps at the beginning of a project
  • ​For a project which will become heavy
  • When you are not the master of all the production chain
  • When your product has to be well tested

​But:

  • There is also a cost
  • "Time is money"
  • Each person involving in the chain has to be aware of the process (Dev, QA, Ops)

DevOps

Why When How

The How

How

Remember:

2/3 Communication & 1/3 Technical​​​

Communication part

Ops to Dev

  • Explain production environment
  • Change code architecture
  • Show how to install and configure the development environment

Ops has a better vision than a Dev

Dev to Ops

  • Give tools & process which can help to manage and build environment
  • Explain application & functional need to optimize resources, to monitor and to manage error

Dev can optimize work of both part

How

Technical part

Two way of testing

  • TDD (Test Driven Development)
  • BDD (Behavior Driven Development)

Continuous Integration : CI

  • Use to generate code
  • Compile
  • ​Execute unit test / functional test

​And these for each targeted environment

The role of the integration server is to control and to manage the results: test, reliability, code analysis

How

Technical part

Continuous Delivery : CD

This phase means the possibility to deploy a features whenever we want.

This step depends on the previous checks

​We can also stack features in this step, and finally deploy all of them in one go

Continuous Deployment contains these process and methodology which let us do continuous deployment in production

Unfortunately, the continuous deployment process is far from simple to implement because it is dependent on all the players in the company's information system.

Tools

SCM​:

  • Github / Git
  • Bitbucket
  • Gitlab
  • Subversion

CI:

  • Jenkins
  • Travis CI
  • Circle CI
  • Solano CI

Deployment:

  • Capistrano
  • Otto
  • ElasticBox
  • Juju

Cloud / LaaS / PaaS:

  • AWS
  • Azure
  • OpenStack
  • Heroku

Config:

  • Chef
  • Puppet
  • Ansible
  • Vagrant

Testing:

  • Mocha
  • JUnit
  • JMeter
  • Gatling

Collaboration:

  • Trello
  • Jira
  • Slack
  • TeamFoundation

Containerization:

  • Docker
  • Nomad
  • Kubernetes
  • Swarm

Docker


docker

​Dockerfile

​docker-machine

​docker-compose​

Docker

Build a container

​docker build -t username/projectname /path/to/dockerfile

Run an image (Basic)

​docker run username/projectname

Run an image (Interactive, publish port, named image)

​docker run -i --name=imagename -p 80:8080 username/projectname

Stop an image

​docker stop imagename

Remove an image

​docker rm imagename

List all image

​docker ps -a

Dockerfile

Dockerfile

Whenever possible, use current Official Repositories as the basis

​FROM <image>:<tag>

Use RUN to execute specific command

​RUN <cmd>

​Expose  ​is used to expose container's port to the host

​EXPOSE <port>

​Use ENTRYPOINT and CMD to start the container with explicit cmd / parameters

​ENTRYPOINT ​["entry_1", "entry_2", ...]
CMD["cmd_1", "cmd_2", ...]

docker-machine

docker-machine is a Service like process

On windows

docker-machine stop
docker-machine start
docker-machine restart

You can (auto) configure docker-machine environment

​docker-machine env

​​You may have to configure your shell as well (Windows example)

​eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

On linux / Ubuntu / redhat / fedora

(sudo) (systemctl) stop docker
(sudo) (systemctl) start docker
(sudo) (systemctl) restart docker

docker-compose

docker-compose lets you build and run multiple containers as you can do with a script

​​run docker-compose.yml with docker-compose up

web:
   build /path/to/dockerfile 
   ports:
      - "80:8080"
   links:
      redis
redis:
   image: redis:latest​
​   ports:
​      - "6379:6379"

https://github.com/adrienfenech/nodejs_server

Play with it:

  • Create Dockerfile for this server
  • Build it
  • Run it
  • Test it
  • ​"docker-compose" it
Made with Slides.com