INF397 Full Stack Technologies View Schedule Print

Deployment Automation

Example Google Deployment Pipeline

Concepts

  • Containers vs VMs vs Bare metal
  • Infrastructure as Code
  • Artifacts
  • Workflows
  • Blue/Green

Containers vs VMs vs Bare metal

  • Containers: new, lite and provider agnostic
  • VMs: familiar, tested and provider agnostic
  • Bare metal: for when you need all the power you can get

Infrastructure as code

  • Configuration files describe servers, networks, etc
  • Keep config with your code in git
  • Avoid manually modifying servers
  • Small changes rather than big batches

Infrastructure as code

Artifacts

Building your application produces various artifacts:
  • Executable files
  • Compressed resources
  • Images, Fonts, etc

Artifacts are deployed to the production server, not your entire codebase

Deployment Workflows

  • Manual: login to the server, upload the artifacts, start the application
  • Git Push: a git hook on a specific remote triggers the deployment
  • Through CI: service monitors repository and triggers a deployment after a successful build
  • Provider Tool: most hosting environments provide specific tools for deployment

Tools

  • FTP & Rsync
  • Git & SSH
  • Ansible & Terraform
  • Docker swarm & Kubernetes
  • Provider specific options

Example AWS Cloudformation

Cloudformation creates/updates infrastructure based on json definition

  {
    "Resources" : {
      "FileBucket" : {
        "Type" : "AWS::S3::Bucket",
        "Properties" : {
          "AccessControl" : "PublicRead"
        }
      },
      "Ec2Instance" : {
        "Type" : "AWS::EC2::Instance",
        "Properties" : {
          "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
          "ImageId" : "ami-7a11e213"
        }
      },
      "InstanceSecurityGroup" : {
        "Type" : "AWS::EC2::SecurityGroup",
        "Properties" : { "...": "..." }
      }
    }
  }
  

Example AWS Cloudformation

Example git post-recieve hook

Git hooks are scripts that let you react to repository events. The post-recieve hook triggers after a push is recieved

    # hooks/post-recieve
    GIT_WORK_TREE=~/src-full-stack git checkout master -f &&
    cd ~/src-full-stack &&
    npm install &&
    npm run build &&
    echo "Deployed successfully"
  

Example kubernetes config

Kubernetes deploys your code to a docker container cluster

  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: nginx-deployment
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: nginx:1.8
          ports:
          - containerPort: 80
    

Blue/Green deployment

Blue/Green deployment: Process overview

  1. A new deployment is triggered
  2. A new environment is setup (green)
  3. Old version continues serving all requests (blue)
  4. Small amount of traffic is given to the new version (green)
  5. New version (green) is monitored against predefined metrics
  6. If the new version performs well, continue with next server, else rollback

Example Ansible deployment diagram

Benefits

  • Repeatable & reliable
  • Easier management
  • Testable systems and processes
  • Self-documenting systems and processes

Links:

Course Schedule:

week 1 03.02.2017 History of the web Fullstack Principles Development Processes Agile Processes DevOps Basics Git
week 2 10.02.2017 Frontend Overview Backend Overview Network Overview Testing JavaScript Overview JavaScript Tooling
week 3 17.02.2017 Web Architectures RESTful principles SOLID principles Web Components Continuous Integration
week 4 24.02.2017 Databases basics Using APIs Deployment Automation Monitoring In-class project consultations
week 5 17.03.2017 Project presentations
Final Test
Course Retrospective and Q&A