Infrastructure as code
Image building with Packer
Every EC2 instance, EKS node and autoscaled server starts from a machine image. Teams that build those images themselves, patched, hardened and tested, ship faster and more safely than teams that configure servers after they boot. Packer is the standard tool for this, and "how do you patch 300 servers?" is a common interview question whose best answer is "we don't; we build a new image and replace them". This topic covers why to bake images, how Packer templates work, how to build good images, and how to run an image pipeline from build to rollout and clean-up.
After this topic you can
- Explain golden images and when to bake or configure at boot
- Build, test and scan AMIs with Packer in a pipeline
- Roll new images out to Auto Scaling groups and EKS nodes safely
Lessons
-
1Why build images
- Golden images and immutable infrastructure
- Bake versus fry
- Where images are used
-
2Packer basics
- Template structure
- The workflow and what amazon-ebs does
-
3Building good images
- Hardening and clean-up
- Testing and scanning
- Speed and reproducibility
-
4Pipelines and rollout
- An image pipeline
- Rolling out a new image
- Lifecycle and alternatives
-
5Interview questions and model answers
- "How do you patch 300 EC2 instances?"
- "Bake or fry?"
- "Walk me through what Packer does when building an AMI."
- "What do you clean up before creating an image?"
- "How do other accounts use your AMIs?"
- "How do you roll a new AMI out to EKS nodes?"
- "Packer or EC2 Image Builder?"