JENNIFER THOMAS: Have you heard the phrase, change
is the only constant in life?
While that may be accurate for most things,
you don't want it to be true for your infrastructure.
Let's take a look at how Critter Junction learned the hard way
about adopting immutable infrastructure.
[MUSIC PLAYING]
Mutable means capable of change.
In this case, we're talking about the idea
of cloud resources that are made to never have manual changes.
For our friends at Critter Junction,
they started with virtual machines
that hosted their web servers.
Their VMs were originally designed
to be mutable because of the short-term flexibility
it gave them.
Each VM could more precisely fit the apps that ran on it,
and it was easy to run custom updates for each machine.
The team often became attached to individual machines, which
was occasionally useful if they needed to fix
specific problems quickly.
For example, they ran a VM with NGINX
in version 1 of their web server,
with data written locally.
When they wanted to switch to Apache, it was easy for them
to perform an upgrade on the server
directly and run version 2.
On the surface, this seems great.
They were using an existing server
and didn't have to worry about moving the data around
to other machines or creating a new machine.
But in the real world, things can go wrong.
The Apache upgrade could have failed for a number of reasons,
like networking issues.
In their case, some of the servers
updated quickly, while others got hung up on installations.
They were left with some servers running version 2 successfully,
some that upgraded the app but couldn't run it,
and some servers that were still running version 1.
Many of their VMs were failing in slightly different ways.
And they were now facing complexity
with user traffic being routed to different running
versions of their web server, an inability
to roll back to a previous version,
and undocumented update statuses,
making it impossible to track versions.
Instead of changing each of their existing VMs,
they should have changed their environment to be immutable.
Once a VM is deployed, it can't be modified.
No updates, no patches, no configuration changes.
If you want to change application code
or apply a patch, you instead would build a new image
and deploy it as a replacement.
Because new environments can be spawned
in the cloud in a matter of minutes,
immutable infrastructure is easy to architect and deploy.
After some long hours restoring version 1 of their application,
here's how Critter Junction handled their next deployment.
Instead of making changes in place to each machine,
they created a brand new VM image with Apache
and version 2 of their app, and moved any locally written data
to an attached persistent disk.
After some testing to make sure the new image was working,
they spun up multiple servers using the new image.
Now they could safely switch traffic to their new VMs
and shut down the instances running version 1.
On Google Cloud, it looked like this for their team.
They used Cloud Build to set up continuous integration
with their repository, automating billing and testing.
VMs were specified using image families
so they could have multiple versions of their images
and deprecate the newest versions if they
needed to roll back.
And they specified all of their resources using
Cloud Deployment Manager in order
to automatically provision it.
This is the same pattern as working with containers--
create a complete runtime environment
and deliver that as an image.
With containers, the runtime environment
is a program and the files it needs to run.
With immutable infrastructure, you're
delivering a whole operating system, configured as needed,
along with the programs and their files.
In both cases, you continuously deliver versioned images.
Creating immutable infrastructure
gave Critter Junction protection from configuration drift,
since they now know the exact state of their machines
and can avoid any unexpected surprises.
In addition, they can now easily track versions, roll back
releases, and have a more consistent testing process,
thanks to the documented differences
between their environments.
Immutable infrastructure might sound at odds
with agile architecture.
But in reality, it gives you agility
because you know the specifics and code
status for every resource in your environment.
Stay tuned to find out what's in store for Critter Junction.
And remember-- always be architecting.
[MUSIC PLAYING]