Stay at home to “Stay Safe”
A big shout out to everyone,directly and indirectly involved in mitigating COVID-19. Its a tragedy, but I am sure ,the world will overcome it. (We are born fighters)
Packer = Is a free and open source tool for creating golden images for multiple platforms from a single source configuration.
Packer is given to the world by HashiCorp.
Yes its the same company, which has given us wonderful tools such as Terraform, Consul, Vagrant & Vault
Reference = https://packer.io/
Gold Mine for all Packer Tool related information
Lives Here= https://github.com/hashicorp/packer
Current Version = 1.5.5
Written in= GOLANG (One of the finest programming language’s out there)
- What is Packer used for?
- Why Packer — 101 ? Is Packer & Terraform same?
- Packer for containers?
All questions will be answered (Patience, the only virtue a human being should posses)
Packer is an open source tool for creating identical machine images for multiple platforms from a single source configuration
Q) What is a machine image?
A) A virtual machine image is a template for creating new instances. You can choose images from a catalog to create images or save your own images from running instances. … The images can be plain operating systems or can have software installed on them, such as databases, application servers, or other applications
Q) What is AMI?
A) An Amazon Machine Image is a special type of virtual appliance that is used to create a virtual machine within the Amazon Elastic Compute
Packer is lightweight, runs on every major operating system, and is highly performant, creating machine images for multiple platforms in parallel.
Packer does not replace configuration management like Chef or Puppet or Ansible . In fact, when building images, Packer is able to use tools like Chef or Puppet to install software onto the image.
A machine image is a single static unit that contains a pre-configured operating system and installed software which is used to quickly create new running machines.
Machine image formats change for each platform. Some examples include AMIs for EC2, VMDK/VMX files for VMware, OVF exports for VirtualBox, etc
In Packer 101, we will try to create Machine Image for Amazon Web Services & Container Image for Docker
Lets get our Hands dirty (The article is completely Hands-On). Just follow along with me
- Install Packer
- Creating Machine Images for Amazon Web Services
- Creating Container Image for Docker
- PC Configuration
RAM = 16 GB
HDD = 50 GB
This is my machine configuration. Anything around 2vcpu, 2gb ram and 40 GB HDD space will be fine
3. Kernel version
4. Downloaded latest version of Packer
Here’s the link
5. Unzip the downloaded zip file
move packer binary to /usr/local/bin
9. Pakcer commands
creating a directory
Packer works on JSON files
Templates are JSON files which define one or more builds by configuring the various components of Packer. Packer is able to read a template and use that information to create multiple machine images in parallel.
I want to create AMI for Amaon Web Serivces, hence giving the access_key & secret_key
Q) What is access_key?
A) Access Keys are used to sign the requests you send to Amazon S3. Like the Username/Password pair you use to access your AWS Management Console, Access Key Id and Secret Access Key are used for programmatic (API) access to AWS services..
Q) What is builders?
A) Builders are components of Packer that are able to create a machine image for a single platform.
Builders read in some configuration and use that to run and generate a machine image. A builder is invoked as part of a build in order to create the actual resulting images. Example builders include VirtualBox, VMware, and Amazon EC2. Builders can be created and added to Packer in the form of plugins
Here the builder type I am using is amazon-ebs.
The amazon-ebs Packer builder is able to create Amazon AMIs backed by EBS volumes for use in EC2
Note — Do enter your access_key & secret_key.
You can also use AWS CLI to populate your credentials
The packer validate Packer command is used to validate the syntax and configuration of a template
14. The packer build command takes a template and runs all the builds within it in order to generate a set of artifacts
Here you can see Amazon Machine Image is created successfully