Instructor: In this lesson,
we will learn about cloud automation.
Cloud automation uses tools and processes to manage,
deploy, and secure cloud resources
and applications efficiently.
Cloud automation concepts include containerization
and Infrastructure as Code or IaC.
Containerization allows applications to be packaged
with their dependencies
into isolated units called containers,
ensuring operational consistency
across different environments.
Infrastructure as Code or IaC is a practice
where infrastructure configurations are defined
and managed through code,
enabling consistent and repeatable deployments
of cloud resources.
Let's learn more about containerization
and Infrastructure as Code.
First, we have containerization.
Containerization is a type of virtualization
in which the host operating system
creates separate environments for each application.
In this construction,
applications are packaged with their dependencies
into isolated units called containers,
ensuring consistent operation
across different operating system or OS environments.
How is this different from Type 1
and Type 2 virtualization?
Well, containerization differs
from traditional virtualization
by isolating resources at the operating system level
rather than the hardware level.
In traditional virtualization,
each virtual machine
is its own isolated operating system instance,
requiring the storage
and processing resources of a full operating system.
Containers, by contrast,
share the host operating system
and isolate only the applications themselves,
making them lightweight and resource-efficient.
Next, containerization uses a containerization engine
instead of a hypervisor
as found in traditional virtualization.
Today, containerization is widely used on Linux servers,
supported by containerization engines,
such as Docker, Kubernetes, Parallels Virtuozzo, and OpenVZ
But how does containerization actually work?
Imagine a standard hardware machine
with a Linux operating system installed on it.
Within the Linux operating system,
we can add a containerization engine, like Docker.
This engine can create
and manage multiple containers,
each containing its own application,
while being supported
by the Linux host operating system files.
In this configuration,
each container acts as an isolated unit,
meaning they are logically separate from one another
and cannot communicate directly by default.
So if two containers need to interact,
they must go through a virtual network
with appropriate routing.
This isolation enhances security and efficiency
by keeping each container's environment distinct.
Importantly, each container also includes
all the dependencies it needs to run,
independent of the host operating system's
installed dependencies.
This ensures that a container will run the same way
on any machine,
regardless of the dependencies present
on the host operating system.
Second, we have Infrastructure as Code or IaC.
IaC is an approach to infrastructure management,
where infrastructure components,
like networks, servers, and storage,
are configured and provisioned using code.
In Infrastructure as Code,
configurations are written as code,
often using languages,
like JavaScript Object Notation or JSON
YAML or Yet Another Markup Language,
and implemented through specialized tools,
such as Terraform, CloudFormation, or Ansible.
This coding approach ensures
that infrastructure setups are consistent, repeatable,
and easy to manage across different environments.
But how is Infrastructure as Code different
from traditional manual configuration?
Well, unlike traditional setups
where admins manually configure the infrastructure,
Infrastructure as Code treats infrastructure as software,
allowing automation of the entire process.
This way, Infrastructure as Code or IaC
shifts infrastructure management
from a labor-intensive, error-prone task
to one that is efficient, controlled, versionable, and fast.
In a traditional setup,
provisioning infrastructure might require logging
into each server separately
and configuring them one by one,
which is time-consuming and prone to errors.
With IaC, however,
you can define the entire setup in code just once
and then use that code to automatically deploy
and configure servers
across multiple environments in seconds.
Next, IaC relies on infrastructure automation tools
rather than direct management by administrators.
Today, Infrastructure as Code
or IaC is commonly used on cloud platforms,
supported by tools,
such as Terraform, for multi-cloud setups,
AWS CloudFormation for AWS resources,
and Ansible for configuration management.
But how does IaC actually work?
Well, imagine you need to set up a multi-tier application
across multiple servers.
Instead of manually configuring each server,
you write a YAML configuration file,
specifying the infrastructure components you need,
such as the server instances,
databases, and networking rules.
This configuration file is then run
through an Infrastructure as Code tool,
like AWS CloudFormation,
which provisions and configures
all the resources automatically
according to your configuration file.
This is Infrastructure as Code.
Importantly, IaC also enables version control
for the infrastructure,
just like with software code,
This means that every change is tracked,
allowing teams to roll back configurations if issues arise.
So with IaC,
updates and adjustments to infrastructure are as simple
as modifying the code and reapplying it,
providing a controlled, predictable way
to manage resources across various environments.
Let's conduct a demonstration
of an nginx web server being deployed as a container,
supported by the Docker Containerization Engine.
In this demonstration,
let's first confirm that Docker is installed
and running on this Kali Linux machine
by checking the version.
We'll do this with the docker --version command.
Yep, Docker is installed.
Now we need to pull the nginx image from the Docker Hub.
We'll do this
with the command sudo docker pull nginx.
It's now downloading the image to our local system.
We can take a look at that
with the command sudo docker images,
and we can see that the nginx image is now located
in our local repository.
Our next step is starting up an instance of nginx.
We'll do that with the following command.
We'll use sudo docker run -d -p 8080:80
-: -name securityx,
which will be the name of our instance,
and nginx, which refers to the image in our repository.
This command will run nginx on port 80 inside the container
and map it to port 8080 on our host machine.
And it's up and running.
Now let's check it out.
We can first look at the process as it's running
with the sudo docker ps command,
and we can see
that our nginx image is running a specific instance,
but let's go ahead and see it in action.
I'll open up a Mozilla Firefox tab,
and we're going to navigate to http://localhost:8080.
There it is.
We can see the default nginx welcome page,
confirming that the web server is running
inside our container.
Now let's go ahead and stop the nginx container.
We'll do that with the command sudo docker stop securityx.
And our container has stopped.
We'll confirm that
by looking at the processes, sudo docker ps,
and we can see that there are no processes running.
This is the end of our demonstration.
So remember, cloud automation streamlines the management,
deployment, and security of cloud resources using tools
and processes that create efficiency and consistency.
Two major concepts in cloud automation are containerization
and Infrastructure as Code or IaC.
Containerization packages applications
with all their dependencies
into isolated units called containers,
allowing those containers to run consistently
across multiple environments.
Infrastructure as Code, on the other hand,
uses code to define and manage infrastructure components,
enabling repeatable, consistent,
and fast deployments.
By automating these processes,
cloud automation reduces manual configuration,
minimizes errors, and enhances operational control
across environments.