Scd Chapter 9 Fall 2024.Docx
Scd Chapter 9 Fall 2024.Docx
DevOps Practices
Definition: IaC is the practice of managing and provisioning computing infrastructure through
machine-readable configuration files rather than through physical hardware configuration or
interactive configuration tools. It treats infrastructure as code, enabling consistent, repeatable
deployments.
● Advantages of IaC:
o Consistency: By defining infrastructure as code, every deployment is consistent
with minimal risk of configuration drift (differences in environment settings).
o Reproducibility: IaC scripts can reproduce environments across development,
testing, and production.
o Scalability: IaC allows infrastructure to dynamically scale based on demand.
o Version Control: Changes to infrastructure can be versioned, enabling rollback if
needed.
● Types of IaC:
o Declarative (What): Describes the desired end-state, letting the tool decide the
best way to reach it. Example: Terraform.
o Imperative (How): Specifies the exact steps to configure the infrastructure.
Example: Ansible.
3. IaC Tools
● Terraform:
o Definition: An open-source IaC tool by HashiCorp that allows users to define and
provision data center infrastructure using a declarative language (HCL -
HashiCorp Configuration Language).
o Example: Provisioning infrastructure across AWS, Google Cloud, and Azure with
a single script.
o Core Concepts:
▪ Providers: Plugins for managing resources from different platforms (e.g.,
AWS, GCP).
▪ Modules: Collections of resources that can be reused.
▪ State: Terraform stores the state of managed infrastructure in a file,
allowing it to track changes and apply incremental updates.
o Benefits: Multi-cloud support, modular configuration, and easy rollbacks.
● Ansible:
o Definition: An open-source automation tool that provides configuration
management, application deployment, and task automation.
o Example: Using Ansible Playbooks to configure web servers, set up databases,
and deploy applications.
o Core Concepts:
▪ Playbooks: YAML files that define a series of tasks to execute on remote
hosts.
▪ Roles: Reusable, modular units of code that contain related playbooks and
tasks.
▪ Inventory: A list of hosts Ansible manages, organized by groups.
o Benefits: Agentless, easy to set up, suitable for configuration management and
application deployment.
● Containerization:
o Definition: A lightweight form of virtualization that packages applications and
their dependencies into isolated containers.
o Example: A development team uses Docker to containerize an application,
allowing it to run consistently across development, testing, and production
environments.
o Benefits: Eliminates "it works on my machine" issues, enhances portability, and
optimizes resource usage.
● Orchestration:
o Definition: Orchestration is managing, coordinating, and scaling multiple
containers to ensure applications run smoothly across different environments.
o Example: Using Kubernetes to automatically scale and load balance a web
service across several containers.
o Benefits: Provides high availability, optimizes resource usage, and simplifies
complex deployments.
● Docker:
o Definition: Docker is an open-source platform that allows developers to automate
the deployment of applications inside lightweight, portable containers.
o Core Concepts:
▪ Docker Images: Immutable templates with application code and
dependencies.
▪ Docker Containers: Run instances of Docker images, isolated from the
host system.
▪Dockerfile: A script defining how to build an image (e.g., instructions to
install software).
▪ Docker Compose: A tool to define and manage multi-container Docker
applications.
o Example: Dockerizing a Python web app and deploying it with a Dockerfile and
Docker Compose for a consistent environment setup.
o Benefits: Increases consistency across environments, simplifies dependency
management, and enhances portability.
● Kubernetes (K8s):
o Definition: Kubernetes is an open-source orchestration platform designed to
automate the deployment, scaling, and management of containerized applications.
o Core Concepts:
▪ Pods: The smallest unit in Kubernetes, typically containing one or more
containers.
▪ Services: Defines a policy to access pods, providing load balancing and
discovery.
▪ ReplicaSets: Ensures a specified number of pod replicas are running.
▪ Deployments: Defines the desired state for applications and manages
updates.
▪ Namespaces: Logical clusters within a physical cluster, providing
resource isolation.
o Example: A company deploys a microservices architecture on Kubernetes, where
each microservice runs in its own pod, allowing independent scaling.
o Benefits: Provides scalability, high availability, and fault tolerance.