Chapter 12
DevOps, Cloud Deployment and Configuration Management
Bachelors Program in Full Stack Development
Full Stack Project - I
•
Post Graduate
DevOps, Cloud Deployment and Configuration Management
Introduction
A full-stack application is not complete when its source code compiles. It must be built reproducibly, tested continuously, deployed safely, configured consistently, monitored in operation, and recoverable when failures occur. DevOps brings development and operations together through culture, automation, feedback, and shared responsibility. Cloud deployment supplies elastic infrastructure and managed services. Configuration management ensures that environments remain controlled, documented, and repeatable.
For a Full Stack Project, these disciplines determine whether a system can move reliably from a developer’s workstation to production. A technically correct application may still fail because of an incorrect environment variable, incompatible database schema, missing secret, insufficient capacity, or untested deployment process.
Learning Objectives
By the end of this chapter, a learner should be able to:
Explain the principles, culture, and lifecycle of DevOps.
Design a CI/CD pipeline for a full-stack application.
Compare cloud deployment models and service categories.
Apply infrastructure and configuration management principles.
Manage secrets, environments, releases, monitoring, and rollback.
Evaluate reliability, security, cost, and governance trade-offs.
Develop a deployment strategy for a realistic full-stack project.
1. DevOps as an Organizational and Technical System
DevOps is not merely a collection of tools. It is a socio-technical approach that integrates people, processes, and technology to deliver software rapidly and reliably. Traditional structures often separate development, testing, security, and operations. Such separation can create handoff delays, conflicting incentives, and limited accountability after release. DevOps reduces these barriers through cross-functional teams and automated feedback.
The central DevOps principles are:
Shared ownership: Teams are collectively responsible for delivery and service operation.
Automation: Repetitive activities such as testing, provisioning, and deployment are automated.
Continuous feedback: Telemetry, tests, user reports, and incident analysis inform improvement.
Measurement: Delivery performance and service reliability are assessed using evidence.
Learning culture: Incidents are examined without unjustly blaming individuals.
DevOps is closely related to Agile development, but the concepts are not identical. Agile primarily emphasizes iterative product development and customer feedback. DevOps extends this orientation through build automation, infrastructure, deployment, observability, and operational responsibility.
The DevOps lifecycle
A practical lifecycle includes planning, coding, building, testing, releasing, deploying, operating, and monitoring. The lifecycle is continuous rather than strictly linear. Monitoring may reveal a performance problem that changes planning; an operational incident may lead to a new automated test.
Continuous DevOps lifecycle
Figure: Continuous DevOps lifecycle
Figure: The DevOps lifecycle is a feedback loop rather than a one-time sequence.
2. Continuous Integration and Continuous Delivery
Continuous Integration (CI) means that developers integrate changes into a shared repository frequently, with automated validation triggered by each change. A typical CI pipeline performs source checkout, dependency installation, static analysis, unit tests, integration tests, packaging, and artifact publication.
Continuous Delivery means that validated software is maintained in a deployable state and can be released through a controlled process. Continuous Deployment goes further: every change that passes the required controls is automatically deployed to production. Continuous deployment is not universally appropriate; regulated or high-risk systems may require explicit approval.
A pipeline should treat the build output as an immutable artifact. Rebuilding the same source separately for staging and production can produce different dependencies or timestamps. Instead, build once, test the artifact, and promote that same artifact across environments.
Pipeline quality controls
Important controls include:
protected branches and peer review;
dependency and vulnerability scanning;
reproducible dependency locking;
unit, integration, contract, and end-to-end tests;
database migration validation;
artifact signing or provenance recording;
approval gates for production;
automated rollback or roll-forward procedures.
A useful deployment performance model uses four widely applied measures:
Measure
Meaning
Deployment frequency
How often the team deploys successfully
Lead time for changes
Time from code committed to code running in production
Change failure rate
Proportion of deployments causing remediation, rollback, or failure
Mean time to restore
Average time required to restore service after an incident
These measures should not be optimized in isolation. A very high deployment frequency accompanied by frequent outages indicates poor control rather than mature DevOps.
3. Cloud Deployment Models
Cloud computing provides on-demand access to computing, storage, networking, and managed services. Its defining characteristics commonly include resource pooling, measured usage, rapid provisioning, elasticity, and network access.
Service models
Infrastructure as a Service (IaaS): The provider supplies virtual machines, networks, and storage; the customer manages the operating system and applications.
Platform as a Service (PaaS): The provider manages much of the operating environment; the customer deploys application code and configuration.
Software as a Service (SaaS): The provider operates a complete application accessed by users.
Function as a Service (FaaS): Application functions execute in response to events, with infrastructure management largely abstracted.
A full-stack application may use several models simultaneously: a managed database, object storage for files, containerized application services, and a managed identity provider.
Deployment patterns
A conventional web architecture separates the browser client, edge or load-balancing layer, application API, background workers, and database. Static front-end assets may be served through a content delivery network, while APIs run on containers, virtual machines, or managed application platforms.
Important deployment patterns include:
Rolling deployment: Instances are replaced gradually. It reduces interruption but may temporarily run two application versions.
Blue-green deployment: Two production environments exist; traffic switches from the old (blue) environment to the new (green) environment. Rollback is rapid, but duplicated capacity may increase cost.
Canary deployment: A small proportion of traffic reaches the new version first. Metrics determine whether exposure expands.
Recreate deployment: The old version is stopped before the new one starts. It is simple but may cause downtime.
The choice depends on compatibility, cost, risk, database migration strategy, and operational maturity.
Availability and capacity reasoning
If independent components must all be available for a request to succeed, the system availability is approximately the product of component availabilities:
Asystem = A1 × A2 × … × An
Here Ai is the availability of component i, represented as a value between 0 and 1. The approximation assumes statistical independence and a serial dependency: every component must function. For example, an application depending on a database with availability 0.999 and an API tier with availability 0.999 has:
Asystem = 0.999 × 0.999 = 0.998001, or approximately 99.8001%.
Real systems may include redundancy and correlated failures, so this formula is a planning approximation rather than a guarantee.
4. Configuration Management
Configuration management is the disciplined control of settings, dependencies, infrastructure definitions, and environment-specific behavior throughout the software lifecycle. Configuration includes database endpoints, feature flags, port numbers, logging levels, resource limits, and service integration settings.
Four properties are particularly important:
Versionability: Changes can be tracked and reviewed.
Repeatability: The same definition produces equivalent environments.
Traceability: A deployed state can be related to a commit, artifact, and change record.
Separation: Code, ordinary configuration, and sensitive secrets are managed appropriately.
Configuration versus secrets
A database host or log level is ordinary configuration. A password, private key, access token, or encryption key is a secret. Secrets must not be committed to source control, embedded in client-side JavaScript, placed in public images, or printed in logs.
A secure design uses a secret manager or protected deployment variables, limits access according to least privilege, rotates credentials, and records access events. Secret values should be injected at runtime or obtained through workload identity rather than copied into many files.
Environment strategy
Common environments include development, test, staging, and production. They should be similar enough to expose deployment defects, while differing in scale and access controls. Environment-specific values should be externalized rather than maintained through manual edits.
A twelve-factor style application treats configuration as environment-provided data and keeps the application artifact independent of its deployment environment. This improves portability, but environment variables alone are not a complete configuration strategy: complex structured configuration, validation, versioning, and secret rotation still require deliberate design.
Infrastructure as Code
Infrastructure as Code (IaC) expresses networks, compute resources, identity policies, databases, and monitoring rules in declarative or programmatic files. IaC enables review, testing, reuse, and repeatable provisioning.
A robust IaC workflow includes:
define resources in version control;
validate syntax and policy;
preview intended changes;
obtain review for sensitive changes;
apply through an automated identity;
record state and outputs securely;
detect and reconcile unintended drift.
Declarative tools describe the desired state; the tool determines the actions needed to reach it. Imperative scripts specify operational steps directly. Declarative approaches often improve repeatability, although provider limitations and complex migrations may require procedural operations.
5. Containerization and Orchestration
A container packages an application and its user-space dependencies while sharing the host operating system kernel. Containers improve consistency between development and deployment, but they are not identical to virtual machines and do not automatically provide security isolation equivalent to a separate operating system.
A production container should be small, run as a non-root user where possible, contain no secrets, use pinned base images, expose only required ports, and receive health checks. Images should be scanned and rebuilt regularly because base-image vulnerabilities can persist even when application code is unchanged.
Orchestration platforms schedule containers, restart failed instances, expose services, manage configuration, and support rolling updates. They add operational power and complexity. A small project may be better served by a managed application platform, whereas a multi-service organization may justify an orchestrator.
Health checks should distinguish:
Liveness: Whether the process is functioning or should be restarted.
Readiness: Whether the instance can receive traffic.
Startup: Whether a slow-starting service is still initializing.
A liveness check that depends on a failing database can cause unnecessary restarts; readiness is usually more suitable for temporary dependency failure.
6. Database and Release Management
Database changes are a major source of deployment risk because schema changes can affect old and new application versions. A safe migration is usually backward compatible during the transition. The expand-and-contract pattern is effective:
Expand: Add a nullable column, new table, or compatible index.
Migrate: Copy or transform data while both versions remain functional.
Adopt: Deploy application code that uses the new structure.
Contract: Remove obsolete structures only after dependencies are gone.
A migration should be tested against realistic data volumes, monitored for locking and performance effects, and accompanied by a recovery plan. Database backups are not sufficient unless restoration has been tested.
7. Observability, Reliability, and Security
Observability is the ability to infer internal system behavior from external outputs. The principal signals are:
Logs: Timestamped records of events.
Metrics: Numeric time-series measurements such as latency, error rate, and CPU usage.
Traces: Correlated paths of a request across services.
Events: Structured records of significant state changes.
Instrumentation should support diagnosis rather than merely produce volume. Logs should include correlation identifiers, severity, service name, and relevant context while excluding secrets and unnecessary personal data.
Service-level indicators (SLIs) measure user-relevant behavior, such as successful request proportion or latency percentile. A service-level objective (SLO) states a target, such as a defined proportion of successful requests over a period. An error budget represents the permitted unreliability implied by the SLO. If an SLO is 99.9% over a 30-day period, the nominal error budget is:
Error budget = 1 − 0.999 = 0.001
The budget is 0.1% of the measurement window. For a 30-day month approximated as 43,200 minutes:
43,200 × 0.001 = 43.2 minutes. This is an approximation because calendar months differ in length and SLO measurement methods vary.
Security must be integrated into the pipeline. Essential practices include dependency scanning, static analysis, secure headers, input validation, authorization tests, patch management, network segmentation, encryption in transit and at rest, and audit logging. DevSecOps emphasizes that security is a shared, continuous responsibility rather than a final inspection.
A university team develops a collaboration platform with a React client, a REST API, a relational database, and an asynchronous notification worker. Initially, developers deploy manually to a single server. Configuration is stored in local files, database changes are applied by hand, and production failures are difficult to diagnose.
Problem
A release succeeds on one developer’s machine but fails in staging because of a missing environment variable. A later deployment overwrites an incompatible database schema. The team has no reliable rollback, and logs contain access tokens.
Analysis
The technical problems reflect process weaknesses: no immutable artifact, inadequate configuration validation, weak migration discipline, insufficient observability, and poor secret handling. Increasing server capacity would not solve these control failures.
Approach and solution
The team adopts the following design:
Pull requests trigger linting, unit tests, integration tests, and dependency scanning.
A versioned container image is built once and promoted from test to staging.
Configuration is validated at application startup against a defined schema.
Secrets are stored in a managed secret store and injected at runtime.
Infrastructure is defined in reviewed IaC files.
A staging deployment uses a rolling strategy; production uses canary exposure.
Logs are structured, tokens are redacted, and traces carry a request identifier.
A documented rollback procedure is rehearsed quarterly.
Outcome
The team gains repeatable environments, faster diagnosis, safer releases, and evidence for release decisions. The pipeline does not eliminate failure; it makes failure more visible, contained, and recoverable.
Learning points
Deployment reliability depends on both architecture and organizational process.
Configuration errors should be detected before production.
Database compatibility must be planned across versions.
Security controls belong in development and operations.
A rollback plan is valuable only if it has been tested.
9. Governance, Cost, and Ethical Considerations
Cloud systems create governance obligations. Teams must define data classification, retention, access ownership, audit requirements, backup policy, and regional processing constraints. Regulations concerning privacy, financial records, education data, or health information may restrict where data is stored and who may access it.
Least privilege should apply to developers, CI systems, services, and administrators. Production access should be authenticated strongly, time-limited when possible, and audited. Personal data should not appear in debug logs or monitoring labels.
Cloud cost is also an engineering concern. Cost drivers include compute duration, storage, data transfer, managed-service tiers, observability volume, and idle resources. Teams should set budgets, tag resources, delete temporary environments, right-size workloads, and evaluate the cost of redundancy against the cost of downtime.
Automation and AI-assisted coding can accelerate pipeline creation, but generated configurations may contain excessive permissions, insecure defaults, or incorrect assumptions about provider behavior. Human review, automated policy checks, testing, and provenance remain necessary.
10. Best Practices and Common Failure Modes
Best practices
Keep deployment definitions in version control.
Build once and promote immutable artifacts.
Validate configuration before service startup.
Separate secrets from ordinary configuration.
Use least privilege and rotate credentials.
Automate tests proportionately to risk.
Prefer small, reversible releases.
Monitor user-facing indicators, not only infrastructure metrics.
Test backups, rollback, and disaster recovery.
Document ownership, dependencies, and operational procedures.
Common failure modes
Manual production changes: They create undocumented drift.
Environment inconsistency: A system works in development but not in production.
Secrets in repositories: History may preserve them even after deletion.
Unbounded logs: Cost and privacy risk increase without improving diagnosis.
Ignoring migration compatibility: A rollback of application code cannot undo a destructive schema change.
Tool-driven architecture: Complex orchestration is adopted without a corresponding operational need.
Metrics without objectives: Teams collect dashboards but cannot decide whether service quality is acceptable.
Chapter Summary
DevOps integrates development and operations through shared responsibility, automation, measurement, and continuous feedback. CI validates changes, while continuous delivery keeps tested software deployable and continuous deployment releases it automatically when appropriate. Cloud deployment offers IaaS, PaaS, SaaS, and FaaS choices, together with rolling, blue-green, canary, and other release strategies.
Configuration management provides versionability, repeatability, traceability, and controlled separation of code, configuration, and secrets. Infrastructure as Code makes cloud resources reviewable and reproducible. Containers improve packaging consistency, while orchestration introduces both capability and complexity. Safe database delivery requires compatibility-aware migration patterns. Observability, SLOs, security controls, governance, privacy, and cost management are essential parts of production engineering. The mature objective is not merely faster deployment, but dependable and recoverable delivery of value.
Key Terms
DevOps: A socio-technical approach integrating development, operations, automation, and feedback.
Continuous Integration: Frequent integration of code with automated validation.
Continuous Delivery: Maintaining software in a deployable state.
Continuous Deployment: Automatically releasing validated changes to production.
Artifact: A versioned build output used for testing or deployment.
Infrastructure as Code: Managing infrastructure through versioned definitions.
Configuration Management: Controlled management of system settings and environment state.
Secret: Sensitive information such as a password, token, or private key.
Container: A packaged process and its user-space dependencies.
Orchestration: Automated scheduling and management of containers or services.
Rolling Deployment: Gradual replacement of running application instances.
Canary Deployment: Limited initial exposure of a new release.
Blue-Green Deployment: Traffic switching between two production environments.
Observability: Inferring internal system state from logs, metrics, traces, and events.
SLI: A measured indicator of service behavior.
SLO: A target level for a service indicator.
Error Budget: The unreliability permitted by an SLO.
Configuration Drift: Unintended divergence between declared and actual state.
Expand-and-Contract: A compatibility-oriented database migration pattern.
Infrastructure Availability: The proportion of time a service is operational and usable.
Review Questions
Short Answer Questions
Distinguish continuous delivery from continuous deployment.
Why should secrets be separated from ordinary configuration?
What is the purpose of a readiness health check?
Name three principal observability signals.
State two advantages of Infrastructure as Code.
Long Answer Questions
Explain DevOps as a socio-technical system and discuss how it differs from Agile development.
Compare rolling, blue-green, and canary deployments, including their risks and appropriate uses.
Describe a secure CI/CD pipeline for a full-stack application.
Explain the expand-and-contract approach to database migrations.
Discuss how governance, privacy, reliability, and cloud cost should influence deployment design.
Analytical / Application Questions
Design a deployment architecture for a full-stack application with a browser client, API, database, and background worker. Justify your cloud service choices and release strategy.
A team has frequent deployments but a high change failure rate and poor recovery time. Diagnose likely process and technical causes, then propose measurable interventions.
A production release requires a database column rename used by both old and new application versions. Develop a backward-compatible migration and rollback plan.
Multiple Choice Questions with Answers
Question 1
Which practice most directly supports reproducible deployment across environments?
A. Building a new artifact separately in each environment
B. Building once and promoting an immutable artifact
C. Editing production configuration manually
D. Disabling automated tests for speed
Correct Answer: B. Building once and promoting an immutable artifact
Question 2
Which cloud service model gives the customer the greatest responsibility for the operating system?
A. SaaS
B. FaaS
C. PaaS
D. IaaS
Correct Answer: D. IaaS
Question 3
What is the primary purpose of a readiness probe?
A. To determine whether an instance should receive traffic
B. To encrypt application secrets
C. To compile source code
D. To replace database backups
Correct Answer: A. To determine whether an instance should receive traffic
Question 4
If two independent serial components have availabilities 0.99 and 0.98, what is the approximate system availability?
A. 0.9702
B. 0.9850
C. 0.9900
D. 1.9700
Correct Answer: A. 0.9702
Question 5
Which deployment strategy initially sends only a small proportion of traffic to a new version?
A. Recreate
B. Canary
C. Big-bang
D. Snapshot
Correct Answer: B. Canary
Question 6
Which item should normally be stored in a managed secret store rather than source control?
A. A CSS color value
B. A public API documentation URL
C. A database password
D. A non-sensitive log level
Correct Answer: C. A database password
Question 7
What is the first stage of an expand-and-contract database migration?
A. Delete the old schema immediately
B. Expand with a compatible schema change
C. Disable all application traffic permanently
D. Remove the rollback procedure
Correct Answer: B. Expand with a compatible schema change
Question 8
Which metric measures the time required to restore service after an incident?
A. Deployment frequency
B. Lead time for changes
C. Mean time to restore
D. Code coverage
Correct Answer: C. Mean time to restore
Question 9
What is configuration drift?
A. A planned version tag for an artifact
B. Unintended divergence between declared and actual state
C. A method of encrypting network traffic
D. A type of unit test
Correct Answer: B. Unintended divergence between declared and actual state
Question 10
For an SLO of 99.9%, what fraction of the measurement period is the nominal error budget?