Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ContainerCon North America – Cloud Anti-Patterns

ContainerCon North America – Cloud Anti-Patterns

Casey West

August 23, 2016
Tweet

More Decks by Casey West

Other Decks in Technology

Transcript

  1. Cloud Anti-Patterns
    @caseywest
    1 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  2. A word about consent…
    Please do:
    Take pictures, tweet, take notes.
    Please don't:
    Record or live stream without my explicit consent.
    2 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  3. Cloud Anti-Patterns
    • Twitter @caseywest
    • Email [email protected]
    • Web http://caseywest.com
    3 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  4. Thanks, Pivotal
    4 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  5. Act One
    The five stages of cloud-native
    5 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  6. The five stages of cloud-
    native
    1. Denial
    2. Anger
    3. Bargaining
    4. Depression
    5. Acceptance
    6 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  7. Have a seat on the couch
    7 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  8. Whatever makes you comfortable
    8 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  9. Now for some basic ground rules
    9 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  10. Rules
    We will talk about your delivery
    pipeline
    10 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  11. Rules
    We will talk about your architecture
    11 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  12. Rules
    We will talk about your automation
    12 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide


  13. 13 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  14. "Deploying my apps to 'the cloud' is
    paintful. Why?"
    14 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  15. Denial
    15 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  16. Denial
    Containers are just like tiny virtual
    machines
    16 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  17. Denial
    We don't need to automate
    continuous delivery
    17 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  18. Anger
    18 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  19. Anger
    Works on my machine
    19 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  20. Anger
    Dev is just #YOLO-ing shit to
    production
    20 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  21. Bargaining
    21 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  22. Bargaining
    We crammed this monolith into a
    container and called it a microservice
    22 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  23. Bargaining
    "Bi-Modal IT"
    23 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  24. Bargaining
    What if we create "microservices"
    that all talk to the same data source?
    24 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  25. Depression
    25 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  26. Depression
    We made 200 microservices and
    forgot to set up jenkins
    26 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  27. Depression
    We have an automated build pipeline
    but release twice a year
    27 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  28. Acceptance
    28 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  29. Acceptance
    All software sucks
    29 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  30. Acceptance
    Respect CAP Theorem
    30 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  31. Acceptance
    Respect Conway's Law
    31 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  32. Acceptance
    Small batch size works for
    replatforming, too
    32 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  33. Acceptance
    Automate everything
    33 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  34. ⏰'s up
    34 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  35. What have we learned?
    35 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  36. Cloud-native operability is*
    1. Microservices Architecture
    2. Devops Culture
    3. Continuous Delivery
    Pick Any Three
    * Not always true.
    36 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  37. Act Two
    The twelve-factor container
    37 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  38. You must be this tall to
    ride this ride
    38 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  39. Audience Participation
    • Containers?
    • Schedulers?
    • Cloud?
    39 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  40. Docker
    Docker
    Docker
    Docker
    Docker
    Docker
    Docker
    Docker
    40 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  41. The factors
    http://12factor.net
    41 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  42. 1: One codebase
    tracked in revision
    control, many deploys
    42 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  43. Anti-pattern
    Building separate
    images for staging and
    production
    43 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  44. Anti-pattern
    Tags for dev and prod
    44 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  45. Best Practice
    Use the environment
    and/or feature flags
    45 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  46. 2: Explicitly declare and
    isolate dependencies
    46 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  47. 2: Explicitly declare and
    isolate dependencies
    47 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  48. Anti-pattern
    latest
    48 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  49. Best Practice
    Declare version
    numbers of upstream
    dependencies
    49 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  50. Best Practice
    Depend on base images
    for default filesystem
    and runtimes
    50 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  51. 3: Store config in the
    environment
    51 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  52. Anti-pattern
    config.yml
    52 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  53. Anti-pattern
    properties.xml
    53 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  54. Anti-pattern
    Hard-coded feature
    flags
    54 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  55. Best Practice
    This one is literally
    about environment
    variables
    55 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  56. Best Practice
    This one is literally
    about environment
    variables ! ‑
    56 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  57. 4: Treat backing
    services as attached
    resources
    57 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  58. Anti-pattern
    Local disk
    58 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  59. Anti-pattern
    Local disk
    59 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  60. Anti-pattern
    Local disk
    60 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  61. Best Practice
    Connect to network-
    attached services using
    connection info from
    the environment
    61 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  62. 5: Strictly separate
    build and run stages
    62 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  63. Anti-pattern
    Install on deploy
    63 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  64. Best Practice
    Build immutable
    images then run those
    images
    64 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  65. Painfully Obvious Best Practices
    1. Eat when hungry
    2. Sleep when tired
    3. Book Casey West for speaking gigs
    65 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  66. Best Practice
    Respect the lifecycle:
    build, run, destroy
    66 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  67. 6: Execute the app as
    one or more stateless
    processes
    67 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  68. Best Practice
    Schedule LRPs by
    distributing them
    across a cluster of
    physical hardware
    68 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  69. Anti-pattern
    NFS
    69 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  70. Anti-pattern
    NFS
    Need I say more?
    70 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  71. 7: Export services via
    port binding
    71 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  72. Best Practice
    port = Env.fetch(:PORT)
    72 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  73. Best Practice
    my $port = $ENV{PORT};
    73 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  74. Best Practice
    private String getPort() {
    Map env = System.getenv();
    return env.get("PORT");
    }
    74 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  75. Best Practice
    let port = env::var("PORT").unwrap()
    75 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  76. 8: Scale out via the
    process model
    76 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  77. Best Practice
    Horizontally scale by
    adding instances
    77 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  78. 9: Maximize robustness
    with fast startup and
    graceful shutdown
    78 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  79. 10: Keep development,
    staging, and production
    as similar as possible
    79 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  80. Best Practice
    Run containers in
    development
    80 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  81. 11: Treat logs as event
    streams
    81 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  82. Anti-pattern
    Random log files
    #yolo'd all over the file
    system
    82 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  83. Best Practice
    STDOUT
    STDOUT
    STDOUT
    STDOUT
    83 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  84. 12: Run admin/
    management tasks as
    one-off processes
    84 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  85. Anti-pattern
    Custom containers for
    tasks
    85 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  86. Best Practice
    Reuse application
    images with specific
    entrypoints for tasks
    86 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  87. More factors?
    • API first
    • Secrets management
    • Health metrics
    • Global distribution
    87 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  88. You are now cloud-native
    88 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  89. Repeatability
    Reliability
    Resiliency
    89 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide

  90. @caseywest
    Let's be friends
    !
    90 ! @caseywest #containercon #linuxcon #containers #realworld #sorrynotsorry

    View Slide