SLIDE 36: Section: Deployment Strategies
Getting Code to Production Safely
#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .error-icon{fill:#552222;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .error-text{fill:#552222;stroke:#552222;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-thickness-normal{stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .marker{fill:#666;stroke:#666;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .marker.cross{stroke:#666;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 p{margin:0;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster-label text{fill:#333;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster-label span{color:#333;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster-label span p{background-color:transparent;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .label text,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 span{fill:#000000;color:#000000;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node rect,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node circle,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node ellipse,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node polygon,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .rough-node .label text,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node .label text,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .image-shape .label,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .icon-shape .label{text-anchor:middle;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .rough-node .label,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node .label,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .image-shape .label,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .icon-shape .label{text-align:center;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node.clickable{cursor:pointer;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .arrowheadPath{fill:#333333;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .flowchart-link{stroke:#666;fill:none;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edgeLabel{background-color:white;text-align:center;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edgeLabel p{background-color:white;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster text{fill:#333;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .cluster span{color:#333;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 rect.text{fill:none;stroke-width:0;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .icon-shape,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .image-shape{background-color:white;text-align:center;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .icon-shape p,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .image-shape p{background-color:white;padding:2px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .icon-shape .label rect,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 .node .neo-node{stroke:#999;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node rect,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].cluster rect,#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node polygon{stroke:url(#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node path{stroke:url(#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552-gradient);stroke-width:1px;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node circle{stroke:url(#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-6994bbe4-5792-453a-a49d-e97eca2cd552 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}CI/CD PipelineDeployment StrategiesRollbacksFeature FlagsDatabase Migrations
Why Deployment Matters:
Key Insight:
Deployment is not the end of development. It is the beginning of production. How you deploy determines how fast you can recover from mistakes.
SLIDE 37: CI/CD Pipeline: Overview
From Code to Production
#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .error-icon{fill:#552222;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .error-text{fill:#552222;stroke:#552222;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-thickness-normal{stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .marker{fill:#666;stroke:#666;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .marker.cross{stroke:#666;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 p{margin:0;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster-label text{fill:#333;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster-label span{color:#333;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster-label span p{background-color:transparent;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .label text,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 span{fill:#000000;color:#000000;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node rect,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node circle,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node ellipse,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node polygon,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .rough-node .label text,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node .label text,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .image-shape .label,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .icon-shape .label{text-anchor:middle;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .rough-node .label,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node .label,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .image-shape .label,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .icon-shape .label{text-align:center;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node.clickable{cursor:pointer;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .arrowheadPath{fill:#333333;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .flowchart-link{stroke:#666;fill:none;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edgeLabel{background-color:white;text-align:center;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edgeLabel p{background-color:white;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster text{fill:#333;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .cluster span{color:#333;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 rect.text{fill:none;stroke-width:0;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .icon-shape,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .image-shape{background-color:white;text-align:center;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .icon-shape p,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .image-shape p{background-color:white;padding:2px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .icon-shape .label rect,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 .node .neo-node{stroke:#999;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node rect,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].cluster rect,#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node polygon{stroke:url(#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node path{stroke:url(#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7-gradient);stroke-width:1px;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node circle{stroke:url(#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-5036f505-e49a-419a-b4b5-b28f9f6607b7 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}Code CommitBuildUnit TestsIntegration TestsSecurity ScanDeploy to StagingE2E TestsDeploy to Production
Pipeline Stages:
SLIDE 38: CI/CD Pipeline: Build Artifacts
What Gets Deployed
Immutable Artifacts:
Build once, deploy everywhere.
Same artifact goes to staging and production.
Artifact Types:
Artifact Versioning:
# Semantic versioning
myapp:1.2.3
# Git SHA
myapp:abc123def
# Timestamp + SHA (recommended)
myapp:20250115-abc123
SLIDE 39: CI/CD Pipeline: Build Artifacts (continued)
Container Image Best Practices:
# Bad: Latest tag, unclear version
FROM python:latest
COPY . /app
# Good: Pinned base image, multi-stage build
FROM python:3.11.5-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
FROM python:3.11.5-slim
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY . .
USER nonroot
CMD ["python", "app.py"]
Image Scanning:
# In CI pipeline
-name: Scan image for vulnerabilities
run:|
trivy image myapp:${{ github.sha }}
# Fail if critical vulnerabilities found
trivy image --exit-code 1 --severity CRITICAL myapp:${{ github.sha }}
SLIDE 40: CI/CD Pipeline: Testing Strategy
What to Test Before Production
Testing Pyramid:
/\
/ \
/ E2E \ Few, slow, expensive
/______\
/ \
/Integration\ More, medium speed
/______________\
/ \
/ Unit Tests \ Many, fast, cheap
/____________________\
Test Distribution:
SLIDE 41: CI/CD Pipeline: Testing Strategy (continued)
Pre-Production Checks:
# CI pipeline stages
stages:
-name: unit-tests
script: pytest tests/unit --parallel
timeout: 10m
-name: integration-tests
script: pytest tests/integration
timeout: 20m
services:
- postgres:15
- redis:7
-name: security-scan
script:|
bandit -r src/
safety check
trivy image $IMAGE
-name: deploy-staging
script: kubectl apply -f k8s/ --context staging
-name: e2e-tests
script: cypress run --env baseUrl=$STAGING_URL
timeout: 30m
-name: deploy-production
script: kubectl apply -f k8s/ --context production
when: manual # Require human approval
SLIDE 42: Deployment Strategies: Overview
Ways to Release New Code
Choosing a Strategy:
SLIDE 43: Deployment Strategies: Recreate
Stop Old, Start New
#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .error-icon{fill:#552222;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .error-text{fill:#552222;stroke:#552222;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-thickness-normal{stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .marker{fill:#666;stroke:#666;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .marker.cross{stroke:#666;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 p{margin:0;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster-label text{fill:#333;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster-label span{color:#333;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster-label span p{background-color:transparent;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .label text,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 span{fill:#000000;color:#000000;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node rect,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node circle,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node ellipse,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node polygon,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .rough-node .label text,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node .label text,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .image-shape .label,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .icon-shape .label{text-anchor:middle;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .rough-node .label,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node .label,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .image-shape .label,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .icon-shape .label{text-align:center;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node.clickable{cursor:pointer;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .arrowheadPath{fill:#333333;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .flowchart-link{stroke:#666;fill:none;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edgeLabel{background-color:white;text-align:center;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edgeLabel p{background-color:white;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster text{fill:#333;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .cluster span{color:#333;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 rect.text{fill:none;stroke-width:0;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .icon-shape,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .image-shape{background-color:white;text-align:center;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .icon-shape p,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .image-shape p{background-color:white;padding:2px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .icon-shape .label rect,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 .node .neo-node{stroke:#999;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node rect,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].cluster rect,#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node polygon{stroke:url(#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node path{stroke:url(#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110-gradient);stroke-width:1px;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node circle{stroke:url(#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-ea60aff5-22e3-47db-9f6d-618557ef1110 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}v1 Runningv1 Stoppedv2 Startingv2 Running
How It Works:
1. Stop all instances of v1
2. Start all instances of v2
3. Downtime during transition
Kubernetes Implementation:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas:3
strategy:
type: Recreate # Stop all, then start all
template:
spec:
containers:
-name: myapp
image: myapp:v2
When to Use:
- Development/staging environments
- Database schema changes requiring downtime
- Applications that cannot run two versions simultaneously
SLIDE 44: Deployment Strategies: Rolling Update
Gradual Replacement
#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .error-icon{fill:#552222;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .error-text{fill:#552222;stroke:#552222;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-thickness-normal{stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .marker{fill:#666;stroke:#666;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .marker.cross{stroke:#666;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 p{margin:0;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster-label text{fill:#333;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster-label span{color:#333;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster-label span p{background-color:transparent;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .label text,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 span{fill:#000000;color:#000000;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node rect,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node circle,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node ellipse,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node polygon,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .rough-node .label text,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node .label text,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .image-shape .label,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .icon-shape .label{text-anchor:middle;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .rough-node .label,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node .label,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .image-shape .label,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .icon-shape .label{text-align:center;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node.clickable{cursor:pointer;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .arrowheadPath{fill:#333333;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .flowchart-link{stroke:#666;fill:none;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edgeLabel{background-color:white;text-align:center;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edgeLabel p{background-color:white;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster text{fill:#333;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .cluster span{color:#333;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 rect.text{fill:none;stroke-width:0;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .icon-shape,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .image-shape{background-color:white;text-align:center;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .icon-shape p,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .image-shape p{background-color:white;padding:2px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .icon-shape .label rect,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 .node .neo-node{stroke:#999;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node rect,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].cluster rect,#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node polygon{stroke:url(#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node path{stroke:url(#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889-gradient);stroke-width:1px;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node circle{stroke:url(#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-2ebcb967-60d1-40d4-8746-9e16e6d18889 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}v1 v1 v1v2 v1 v1v2 v2 v1v2 v2 v2
How It Works:
1. Start new instance (v2)
2. Wait for health check
3. Stop old instance (v1)
4. Repeat until all replaced
Kubernetes Implementation:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas:3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge:1 # Max extra pods during update
maxUnavailable:0 # Always maintain capacity
template:
spec:
containers:
-name: myapp
image: myapp:v2
SLIDE 45: Deployment Strategies: Rolling Update (continued)
Rolling Update Parameters:
Health Check Requirements:
spec:
containers:
-name: myapp
image: myapp:v2
readinessProbe:
httpGet:
path: /health/ready
port:8080
initialDelaySeconds:5
periodSeconds:5
livenessProbe:
httpGet:
path: /health/live
port:8080
initialDelaySeconds:10
periodSeconds:10
New pods only receive traffic after passing readiness check.
SLIDE 46: Deployment Strategies: Blue-Green
Two Identical Environments
#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .error-icon{fill:#552222;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .error-text{fill:#552222;stroke:#552222;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-thickness-normal{stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .marker{fill:#666;stroke:#666;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .marker.cross{stroke:#666;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 p{margin:0;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster-label text{fill:#333;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster-label span{color:#333;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster-label span p{background-color:transparent;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .label text,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 span{fill:#000000;color:#000000;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node rect,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node circle,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node ellipse,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node polygon,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .rough-node .label text,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node .label text,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .image-shape .label,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .icon-shape .label{text-anchor:middle;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .rough-node .label,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node .label,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .image-shape .label,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .icon-shape .label{text-align:center;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node.clickable{cursor:pointer;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .arrowheadPath{fill:#333333;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .flowchart-link{stroke:#666;fill:none;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edgeLabel{background-color:white;text-align:center;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edgeLabel p{background-color:white;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster text{fill:#333;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .cluster span{color:#333;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 rect.text{fill:none;stroke-width:0;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .icon-shape,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .image-shape{background-color:white;text-align:center;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .icon-shape p,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .image-shape p{background-color:white;padding:2px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .icon-shape .label rect,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 .node .neo-node{stroke:#999;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node rect,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].cluster rect,#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node polygon{stroke:url(#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node path{stroke:url(#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0-gradient);stroke-width:1px;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node circle{stroke:url(#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-d3fb944a-dd17-45df-8c48-76a022656bb0 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}Load BalancerBlue: v1 ActiveGreen: v2 Standby
After switch:
#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .error-icon{fill:#552222;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .error-text{fill:#552222;stroke:#552222;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-thickness-normal{stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .marker{fill:#666;stroke:#666;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .marker.cross{stroke:#666;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 p{margin:0;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster-label text{fill:#333;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster-label span{color:#333;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster-label span p{background-color:transparent;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .label text,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 span{fill:#000000;color:#000000;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node rect,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node circle,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node ellipse,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node polygon,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .rough-node .label text,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node .label text,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .image-shape .label,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .icon-shape .label{text-anchor:middle;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .rough-node .label,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node .label,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .image-shape .label,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .icon-shape .label{text-align:center;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node.clickable{cursor:pointer;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .arrowheadPath{fill:#333333;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .flowchart-link{stroke:#666;fill:none;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edgeLabel{background-color:white;text-align:center;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edgeLabel p{background-color:white;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster text{fill:#333;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .cluster span{color:#333;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 rect.text{fill:none;stroke-width:0;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .icon-shape,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .image-shape{background-color:white;text-align:center;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .icon-shape p,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .image-shape p{background-color:white;padding:2px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .icon-shape .label rect,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 .node .neo-node{stroke:#999;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node rect,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].cluster rect,#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node polygon{stroke:url(#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node path{stroke:url(#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620-gradient);stroke-width:1px;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node circle{stroke:url(#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-15aa7459-7bdd-49ca-a2e8-e1ade5215620 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}Load BalancerBlue: v1 StandbyGreen: v2 Active
How It Works:
1. Blue environment runs v1 (production)
2. Deploy v2 to Green environment
3. Test v2 on Green
4. Switch load balancer to Green
5. Blue becomes standby (instant rollback available)
SLIDE 47: Deployment Strategies: Blue-Green (continued)
Implementation with Kubernetes:
# Blue deployment (current production)
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-blue
labels:
version: blue
spec:
replicas:3
template:
metadata:
labels:
app: myapp
version: blue
---
# Green deployment (new version)
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-green
labels:
version: green
spec:
replicas:3
template:
metadata:
labels:
app: myapp
version: green
---
# Service selector determines active version
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp
version: blue # Change to 'green' to switch
SLIDE 48: Deployment Strategies: Blue-Green (continued)
Blue-Green Trade-offs:
Database Considerations:
Challenge: Both Blue and Green need database access
Solutions:
1. Backward compatible schema changes only
2. Expand-contract migrations
3. Separate read replicas per environment
When to Use:
- Critical applications requiring instant rollback
- When you can afford double infrastructure
- When testing in production-like environment is essential
SLIDE 49: Deployment Strategies: Canary
Gradual Traffic Shift
#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .error-icon{fill:#552222;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .error-text{fill:#552222;stroke:#552222;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-thickness-normal{stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .marker{fill:#666;stroke:#666;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .marker.cross{stroke:#666;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 p{margin:0;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster-label text{fill:#333;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster-label span{color:#333;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster-label span p{background-color:transparent;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .label text,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 span{fill:#000000;color:#000000;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node rect,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node circle,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node ellipse,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node polygon,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .rough-node .label text,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node .label text,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .image-shape .label,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .icon-shape .label{text-anchor:middle;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .rough-node .label,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node .label,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .image-shape .label,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .icon-shape .label{text-align:center;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node.clickable{cursor:pointer;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .arrowheadPath{fill:#333333;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .flowchart-link{stroke:#666;fill:none;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edgeLabel{background-color:white;text-align:center;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edgeLabel p{background-color:white;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster text{fill:#333;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .cluster span{color:#333;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 rect.text{fill:none;stroke-width:0;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .icon-shape,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .image-shape{background-color:white;text-align:center;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .icon-shape p,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .image-shape p{background-color:white;padding:2px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .icon-shape .label rect,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 .node .neo-node{stroke:#999;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node rect,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].cluster rect,#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node polygon{stroke:url(#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node path{stroke:url(#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416-gradient);stroke-width:1px;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node circle{stroke:url(#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-a82a0994-172e-4f96-b03c-645cf5dbd416 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}Load Balancerv1: Stablev2: Canary95%5%
Canary Progression:
Rollback Trigger:
If at any stage:
- Error rate increases > 0.1%
- P99 latency increases > 10%
- Business metrics degrade
Then: Route 100% back to stable
SLIDE 50: Deployment Strategies: Canary (continued)
Implementation with Istio:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: myapp
spec:
hosts:
- myapp
http:
-route:
-destination:
host: myapp
subset: stable
weight:95
-destination:
host: myapp
subset: canary
weight:5
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: myapp
spec:
host: myapp
subsets:
-name: stable
labels:
version: v1
-name: canary
labels:
version: v2
SLIDE 51: Deployment Strategies: Canary (continued)
Automated Canary Analysis:
class CanaryAnalyzer:
def __init__(self, stable_metrics, canary_metrics):
self.stable = stable_metrics
self.canary = canary_metrics
def analyze(self):
# Compare error rates
error_increase = (
self.canary.error_rate - self.stable.error_rate
) / self.stable.error_rate
if error_increase > 0.1: # 10% increase
return CanaryResult.ROLLBACK, "Error rate too high"
# Compare latency
latency_increase = (
self.canary.p99_latency - self.stable.p99_latency
) / self.stable.p99_latency
if latency_increase > 0.2: # 20% increase
return CanaryResult.ROLLBACK, "Latency too high"
return CanaryResult.PROCEED, "Metrics healthy"
Tools for Canary:
SLIDE 52: Deployment Strategies: Shadow/Dark Launch
Testing with Production Traffic
#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:#000000;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .error-icon{fill:#552222;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .error-text{fill:#552222;stroke:#552222;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-thickness-normal{stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .marker{fill:#666;stroke:#666;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .marker.cross{stroke:#666;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 svg{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 p{margin:0;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .label{font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:#000000;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster-label text{fill:#333;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster-label span{color:#333;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster-label span p{background-color:transparent;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .label text,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 span{fill:#000000;color:#000000;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node rect,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node circle,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node ellipse,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node polygon,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node path{fill:#eee;stroke:#999;stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .rough-node .label text,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node .label text,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .image-shape .label,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .icon-shape .label{text-anchor:middle;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .rough-node .label,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node .label,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .image-shape .label,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .icon-shape .label{text-align:center;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node.clickable{cursor:pointer;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .root .anchor path{fill:#666!important;stroke-width:0;stroke:#666;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .arrowheadPath{fill:#333333;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edgePath .path{stroke:#666;stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .flowchart-link{stroke:#666;fill:none;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edgeLabel{background-color:white;text-align:center;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edgeLabel p{background-color:white;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .edgeLabel rect{opacity:0.5;background-color:white;fill:white;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .labelBkg{background-color:rgba(255, 255, 255, 0.5);}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster rect{fill:hsl(0, 0%, 98.9215686275%);stroke:#707070;stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster text{fill:#333;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .cluster span{color:#333;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Display","Segoe UI",Helvetica,"Apple Color Emoji","Noto Sans Arabic","Noto Sans Hebrew",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:hsl(-160, 0%, 93.3333333333%);border:1px solid #707070;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#000000;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 rect.text{fill:none;stroke-width:0;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .icon-shape,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .image-shape{background-color:white;text-align:center;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .icon-shape p,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .image-shape p{background-color:white;padding:2px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .icon-shape .label rect,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .image-shape .label rect{opacity:0.5;background-color:white;fill:white;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 .node .neo-node{stroke:#999;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node rect,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].cluster rect,#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node polygon{stroke:url(#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].swimlane.cluster rect{filter:none;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node path{stroke:url(#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4-gradient);stroke-width:1px;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node .neo-line path{stroke:#999;filter:none;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node circle{stroke:url(#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].node circle .state-start{fill:#000000;}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].icon-shape .icon{fill:url(#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 [data-look="neo"].icon-shape .icon-neo path{stroke:url(#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#mermaid-764f44e9-40d0-4fae-b837-72cc5daceaf4 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}Requestv1: Responds to Userv2: Processes SilentlyUserLogs/Metrics Only
How It Works:
1. Production traffic goes to v1 (user gets v1 response)
2. Copy of traffic also goes to v2
3. v2 processes but response is discarded
4. Compare v1 and v2 behavior
Use Cases:
SLIDE 53: Deployment Strategies: Shadow/Dark Launch (continued)
Shadow Traffic Implementation:
async def handle_request(request):
# Primary path: respond to user
primary_task = asyncio.create_task(
call_primary_service(request)
)
# Shadow path: fire and forget
if should_shadow(request):
asyncio.create_task(
call_shadow_service(request)
)
# Only wait for primary
response = await primary_task
return response
def should_shadow(request):
# Shadow 10% of traffic
return hash(request.id) % 100 < 10
Comparison Analysis:
def compare_responses(primary, shadow):
metrics.record("shadow_latency_diff",
shadow.latency - primary.latency)
if primary.result != shadow.result:
metrics.increment("shadow_mismatch")
log.warning("Shadow mismatch",
primary=primary.result,
shadow=shadow.result)
SLIDE 54: Rollbacks: When and How
Undoing Bad Deployments
When to Rollback:
Rollback Decision Tree:
SLIDE 55: Rollbacks: Implementation
Kubernetes Rollback:
# View rollout history
kubectl rollout history deployment/myapp
# Rollback to previous version
kubectl rollout undo deployment/myapp
# Rollback to specific revision
kubectl rollout undo deployment/myapp --to-revision=3
# Check rollback status
kubectl rollout status deployment/myapp
Automated Rollback:
# Argo Rollouts with automatic rollback
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: myapp
spec:
strategy:
canary:
steps:
-setWeight:5
-pause:{duration: 10m}
-analysis:
templates:
-templateName: success-rate
args:
-name: service-name
value: myapp
-setWeight:50
-pause:{duration: 30m}
-setWeight:100
# Automatic rollback on failure
abortScaleDownDelaySeconds:30
SLIDE 56: Rollbacks: Implementation (continued)
Analysis Template for Auto-Rollback:
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
-name: service-name
metrics:
-name: success-rate
interval: 1m
count:5
successCondition: result[0] >= 0.99
failureLimit:3
provider:
prometheus:
address: http://prometheus:9090
query:|
sum(rate(http_requests_total{
service="{{args.service-name}}",
status!~"5.."
}[5m])) /
sum(rate(http_requests_total{
service="{{args.service-name}}"
}[5m]))
If success rate drops below 99% in 3 consecutive checks, automatic rollback triggers.
SLIDE 57: Rollbacks: Database Considerations
The Hardest Part of Rollbacks
The Problem:
Solution: Backward Compatible Migrations
Phase 1: Add new columns (v2 deploy)
- Add first_name, last_name columns
- v1 code ignores them, still works
Phase 2: Dual write (v2 code)
- Write to both old and new columns
- Read from new columns
- Rollback safe: v1 reads old columns
Phase 3: Migrate data
- Backfill new columns from old
- Verify data consistency
Phase 4: Remove old columns (after rollback window)
- Only after v1 is no longer needed
SLIDE 58: Feature Flags: Concept
Decouple Deployment from Release
Without Feature Flags:
Deploy = Release
New code immediately visible to all users
With Feature Flags:
Deploy: Code goes to production (inactive)
Release: Feature flag enabled (visible to users)
def get_recommendations(user_id):
if feature_flags.is_enabled("new_recommendation_algo", user_id):
return new_recommendation_algo(user_id)
else:
return old_recommendation_algo(user_id)
Benefits:
SLIDE 59: Feature Flags: Implementation
Basic Feature Flag System:
class FeatureFlags:
def __init__(self, config_source):
self.config = config_source
def is_enabled(self, flag_name, user_id=None, default=False):
flag = self.config.get(flag_name)
if flag is None:
return default
# Global kill switch
if not flag.get("enabled", False):
return False
# Check rollout percentage
rollout_percent = flag.get("rollout_percent", 100)
if user_id:
# Consistent hashing for user
user_bucket = hash(f"{flag_name}:{user_id}") % 100
if user_bucket >= rollout_percent:
return False
# Check user allowlist
if user_id and user_id in flag.get("allowlist", []):
return True
return True
SLIDE 60: Feature Flags: Implementation (continued)
Flag Configuration:
{
"new_checkout_flow": {
"enabled": true,
"rollout_percent": 10,
"allowlist": ["user_123", "user_456"],
"blocklist": [],
"description": "New streamlined checkout experience",
"owner": "checkout-team",
"created_at": "2025-01-15",
"expires_at": "2025-03-15"
},
"dark_mode": {
"enabled": true,
"rollout_percent": 100,
"segments": ["premium_users"],
"description": "Dark mode UI",
"owner": "frontend-team"
}
}
Usage Patterns:
# Simple on/off
if feature_flags.is_enabled("maintenance_mode"):
return maintenance_page()
# User-specific rollout
if feature_flags.is_enabled("new_search", user_id=user.id):
return new_search(query)
else:
return old_search(query)
# Operational flag
cache_ttl = feature_flags.get_value("cache_ttl_seconds", default=300)
SLIDE 61: Feature Flags: Best Practices
Managing Feature Flags Well
Flag Lifecycle:
Flag Hygiene:
# Bad: Flag that lives forever
if feature_flags.is_enabled("new_payment_system"): # Added 2 years ago
# This is now the only code path
process_payment_new()
else:
# Dead code, never executed
process_payment_old()
# Good: Remove flag after full rollout
def process_payment():
# New payment system is now the standard
process_payment_impl()
SLIDE 62: Feature Flags: Best Practices (continued)
Flag Naming Conventions:
# Bad: Unclear purpose
"flag_123"
"test_feature"
"johns_experiment"
# Good: Clear, descriptive
"checkout_single_page_flow"
"search_ml_ranking_v2"
"payments_stripe_integration"
Flag Documentation:
FEATURE_FLAGS = {
"search_ml_ranking_v2": {
"description": "Use ML-based search ranking instead of keyword matching",
"owner": "search-team",
"slack": "#search-team",
"jira": "SEARCH-1234",
"rollout_plan": "1% week 1, 10% week 2, 50% week 3, 100% week 4",
"rollback_procedure": "Disable flag, no deployment needed",
"cleanup_date": "2025-03-01",
}
}
Production Practice:
Review flags monthly. Remove flags at 100% for more than 2 weeks. Set expiration dates.
SLIDE 63: Deployment: Anti-Patterns
Common Mistakes to Avoid
Anti-Pattern 1: Big Bang Deployments
Bad:
- Accumulate 3 months of changes
- Deploy everything at once
- Pray nothing breaks
Good:
- Deploy multiple times per day
- Small, incremental changes
- Easy to identify what broke
Anti-Pattern 2: No Rollback Plan
Bad:
def deploy():
kubectl_apply(new_version)
# Hope for the best
Good:
def deploy():
record_previous_version()
kubectl_apply(new_version)
if not health_check_passes():
rollback_to_previous()
alert_team()
SLIDE 64: Deployment: Anti-Patterns (continued)
Anti-Pattern 3: Deploy Database and Code Together
Bad:
1. Deploy code expecting new column
2. Run migration adding column
3. 30 seconds of errors
Good:
1. Run migration adding column
2. Wait for replication
3. Deploy code using new column
Anti-Pattern 4: Feature Flags Without Cleanup
Bad:
if feature_flags.is_enabled("new_flow"): # Added 2019
if feature_flags.is_enabled("new_flow_v2"): # Added 2020
if feature_flags.is_enabled("new_flow_v3"): # Added 2021
# Actual code buried under 3 flags
Good:
# Clean up flags after full rollout
# Maximum 2 active flags per code path
Anti-Pattern 5: No Deployment Windows
Bad: Deploy Friday at 5pm, go home
Good: Deploy Tuesday morning, monitor all day
SLIDE 65: Deployment: Summary
Key Takeaways
CI/CD Pipeline:
- Build immutable artifacts
- Test before deploy (unit, integration, e2e)
- Scan for security vulnerabilities
- Automate everything
Deployment Strategies:
- Rolling updates for most services
- Blue-green for critical with instant rollback needs
- Canary for high-risk changes
- Shadow for validation without user impact
SLIDE 66: Deployment: Summary (continued)
Rollbacks:
- Every deployment must be rollback-ready
- Automate rollback triggers based on metrics
- Database changes must be backward compatible
- Test rollback procedure regularly
Feature Flags:
- Separate deployment from release
- Gradual rollout (1% → 10% → 50% → 100%)
- Clean up flags after full rollout
- Document ownership and expiration
Coming Up Next: Section - Security in Production