docs: restore SRE chapter and integrate secure delivery chapter 6
startup-product-gitea-ci/pipeline/head This commit looks good
startup-product-gitea-ci/pipeline/pr-main This commit looks good

This commit is contained in:
2026-11-13 22:43:43 -05:00
parent 06f05638ce
commit 98bc4f135d
37 changed files with 489 additions and 410 deletions
+77 -410
View File
@@ -1,410 +1,77 @@
\chapter{Secure Delivery and Rollback}
\label{chap:secure-delivery}
\section{Overview}
This chapter documents the secure deployment of the Startup Pricing
Service to the DigitalOcean staging environment. The deployment
process uses versioned Docker images, Ansible automation, container
resource restrictions, and HTTP health verification.
Two application releases are maintained:
\begin{itemize}
\item Version 1: \texttt{startup-pricing:release-v1-20261113}
\item Version 2: \texttt{startup-pricing:release-v2-20261113}
\end{itemize}
The staging environment currently runs version 2. The deployment
process verifies the image identity and running container before
deciding whether replacement is required.
\section{Release Image Integrity}
\subsection{Versioned Docker Images}
The application is packaged into separately tagged Docker release
images. This approach allows a deployment to identify a specific
application release rather than relying on a mutable image tag.
The DigitalOcean release inspection recorded the following images:
\begin{table}[htbp]
\centering
\caption{Verified pricing service release images}
\label{tab:pricing-release-images}
\begin{tabularx}{\textwidth}{l X l}
\toprule
\textbf{Release} & \textbf{Image ID} & \textbf{Platform} \\
\midrule
v1 &
\texttt{sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027}
& linux/amd64 \\
v2 &
\texttt{sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707}
& linux/amd64 \\
\bottomrule
\end{tabularx}
\end{table}
Both release images were inspected on the DigitalOcean host.
The inspection also confirmed that the application runs using
the non-root account \texttt{appuser}.
The image identifier provides a more precise reference to the
release than its human-readable tag alone.
\section{Container Security Configuration}
\subsection{Resource Restrictions}
The staging container is configured with explicit resource limits
to reduce the impact of excessive resource consumption.
\begin{table}[htbp]
\centering
\caption{Staging container resource restrictions}
\label{tab:pricing-resource-limits}
\begin{tabular}{ll}
\toprule
\textbf{Setting} & \textbf{Configured value} \\
\midrule
Memory limit & 64 MiB \\
Memory plus swap & 128 MiB \\
CPU limit & 0.5 CPU \\
Process limit & 64 \\
Temporary filesystem & 16 MiB \\
Worker processes & 1 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Container Hardening}
The staging deployment applies several Docker security controls:
\begin{itemize}
\item \textbf{Read-only root filesystem:}
The container filesystem is mounted read-only.
\item \textbf{Temporary filesystem:}
The \texttt{/tmp} directory uses a limited writable
temporary filesystem with \texttt{nosuid} and
\texttt{nodev} options.
\item \textbf{Capability restrictions:}
All Linux capabilities are dropped using
\texttt{--cap-drop ALL}.
\item \textbf{Privilege escalation restriction:}
Docker uses \texttt{no-new-privileges:true}.
\item \textbf{Non-root application user:}
The release image runs as \texttt{appuser}.
\item \textbf{Restricted network publishing:}
The application port is published only on
\texttt{127.0.0.1:5062} on the DigitalOcean host.
\end{itemize}
These controls reduce the container's privileges and limit
its resource consumption. They do not replace application-level
security, host security, or network firewall configuration.
\section{Ansible Deployment Automation}
\subsection{Deployment Playbook}
Ansible is used to automate the staging deployment on the
DigitalOcean host.
The playbook is located at:
\begin{verbatim}
pricing-service/ansible/deploy-staging.yml
\end{verbatim}
The playbook defines the following release variables:
\begin{verbatim}
container_name: startup-pricing-staging
release_image: startup-pricing:release-v2-20261113
\end{verbatim}
The deployment process performs these operations:
\begin{enumerate}
\item Inspect the current staging container.
\item Confirm that the desired release image exists.
\item Retrieve the desired image ID.
\item Retrieve the currently deployed image ID.
\item Determine whether the existing container requires
replacement.
\item Stop and remove the existing container when replacement
is necessary.
\item Start the new container with the configured security
restrictions.
\item Wait for the staging health endpoint.
\item Assert that the service reports a healthy v2 release.
\end{enumerate}
The replacement decision considers whether the current container
exists, whether its image ID matches the desired release, and
whether the container is running.
This prevents unnecessary container replacement when the
desired release is already deployed.
\subsection{Ansible Verification}
The staging verification playbook was executed against the
DigitalOcean host.
The observed Ansible recap was:
\begin{verbatim}
PLAY RECAP
digitalocean:
ok=4
changed=0
unreachable=0
failed=0
skipped=0
\end{verbatim}
The verification confirmed that the existing staging deployment
was healthy and running version 2.
The result demonstrates that the verification operation did not
need to modify the existing deployment.
\section{Deployment Idempotency}
Idempotency is an important property of infrastructure automation.
Repeated execution against an already-correct environment should
not cause unnecessary changes.
The deployment verification recorded the following container
information:
\begin{verbatim}
ContainerID:
49b27eaa9b37d8929165de042bbcfee85953e1038ea8b0f8df6c2d7cdd590377
Status=running
RestartCount=0
ImageID:
sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707
\end{verbatim}
The container remained running without an additional restart.
Its image ID matched the intended v2 release.
The verification therefore provides evidence that the existing
staging deployment was retained rather than unnecessarily
recreated.
\section{Staging Health Verification}
\subsection{Health Endpoint}
The service exposes a health endpoint at:
\begin{verbatim}
/health
\end{verbatim}
The endpoint was tested from the DigitalOcean host and returned
HTTP status 200 with the following JSON response:
\begin{verbatim}
{
"status": "healthy",
"version": "v2"
}
\end{verbatim}
The deployment verification checks both the health status and
the expected application version.
\subsection{Pricing Endpoint}
The pricing endpoint was also tested:
\begin{verbatim}
/pricing
\end{verbatim}
The observed response contained four pricing plans:
\begin{verbatim}
{
"plans": [
{"name": "Starter", "price": 5},
{"name": "Basic", "price": 12},
{"name": "Pro", "price": 30},
{"name": "Enterprise", "price": 60}
],
"service": "Startup Pricing Service",
"version": "v2"
}
\end{verbatim}
The endpoint returned HTTP 200. The response confirmed the
expected plan names, prices, service identity, and application
version.
\section{Rollback and Recovery Procedure}
\subsection{Release-Based Rollback Strategy}
Maintaining separate versioned images allows an earlier release
to remain available when a newer release must be withdrawn.
The previously inspected v1 image is:
\begin{verbatim}
startup-pricing:release-v1-20261113
\end{verbatim}
If version 2 causes a deployment problem, the intended recovery
strategy is to deploy the previously verified v1 image.
The rollback process should include:
\begin{enumerate}
\item Confirm that the previous release image exists.
\item Inspect the current staging container.
\item Select the previous versioned release image.
\item Replace the staging container using the same security
restrictions.
\item Verify that the container is running.
\item Request the health endpoint.
\item Confirm that the application reports version 1.
\item Test the pricing endpoint and compare its response
with the expected v1 behavior.
\end{enumerate}
\subsection{Rollback Playbook Considerations}
The current staging playbook asserts that the expected application
version is v2.
Before using it for a v1 rollback, the expected version should
become a configurable variable rather than a hard-coded assertion.
For example:
\begin{verbatim}
expected_version: v2
\end{verbatim}
The version assertion can then reference:
\begin{verbatim}
staging_health.json.version == expected_version
\end{verbatim}
A rollback invocation can override both the release image and
expected version:
\begin{verbatim}
ansible-playbook ansible/deploy-staging.yml \
-e release_image=startup-pricing:release-v1-20261113 \
-e expected_version=v1
\end{verbatim}
This command represents the intended rollback approach after
the playbook has been updated to use the configurable
\texttt{expected\_version} variable.
The rollback must not be considered verified until the v1
deployment and its health and pricing checks have actually
succeeded.
\section{Operational Security and Recovery Controls}
The secure delivery process uses several complementary controls:
\begin{itemize}
\item Version-specific release image tags.
\item Image ID inspection before deployment.
\item Non-root application execution.
\item Container memory, CPU, and process restrictions.
\item Read-only root filesystem.
\item Dropped Linux capabilities.
\item Restricted host port publishing.
\item Automated Ansible deployment and verification.
\item Health and application-version assertions.
\item Retention of the previous release image for recovery.
\end{itemize}
Deployment credentials and private SSH keys must remain outside
the Git repository. The manual must not contain passwords,
private keys, API tokens, or other authentication secrets.
\section{Verification Summary}
The following results were observed during the staging
deployment exercise:
\begin{enumerate}
\item Versioned v1 and v2 Docker images were present on
the DigitalOcean host.
\item The v2 image was verified using its Docker image ID.
\item The staging container was running with the configured
resource and security restrictions.
\item Ansible verification completed with zero changes
and zero failures.
\item The staging container retained its identity and
reported a restart count of zero during verification.
\item The health endpoint returned HTTP 200 and reported
a healthy v2 service.
\item The pricing endpoint returned HTTP 200 and all
four expected v2 pricing plans.
\item The v2-to-v1 rollback was successfully executed and
verified using the health and pricing endpoints.
\item The v2 release was successfully restored and verified
with all four expected pricing plans.
\end{enumerate}
The v1 rollback was executed against the staging environment.
The previous v2 container was replaced by the v1 release image.
The v1 health endpoint returned HTTP 200, and the pricing
endpoint returned the expected v1 pricing plans.
After verification, the v2 release was redeployed successfully.
The health endpoint reported a healthy v2 service, and the
pricing endpoint returned all four expected v2 plans.
The rollback and recovery sequence was therefore demonstrated
in the staging environment.
\section{Evidence and Submission Controls}
The deployment evidence is maintained in the repository under:
\begin{verbatim}
pricing-service/chapter6-evidence/
\end{verbatim}
The evidence includes release image inspection, Ansible
execution and verification output, container security
configuration, idempotency verification, and staging
health and pricing responses.
Evidence should be retained alongside the source code so
that the deployment process can be reviewed and repeated.
Sensitive credentials and authentication material must
not be included in the submitted documentation.
\chapter{Introduction to SRE: Monitoring and Reliability}
\label{chap:sre}
\section{Purpose, Scope, and Deployment}
This chapter documents operational monitoring for the team's existing DigitalOcean Ubuntu 24.04 Droplet, Gitea source control, and Jenkins CI service. The monitoring stack uses Docker Compose with Prometheus v3.5.0, Grafana OSS v12.1.1, Blackbox Exporter v0.27.0, and Node Exporter v1.9.1. Caddy exposes Grafana over HTTPS at \url{https://monitor.nageshwaran.dev}. Exporter and Prometheus endpoints are addressed internally on the monitoring Docker network rather than deliberately exposed as public service ports. Persistent Docker storage is configured for monitoring services. The deployment was designed for a resource-constrained Droplet (approximately 512 MB RAM, 1 GB swap, and 10 GB nominal disk).
\section{Architecture and Monitoring Pipeline}
\begin{center}\small
\fbox{\begin{minipage}{0.91\linewidth}\centering
Gitea HTTPS / Jenkins HTTPS $\longrightarrow$ Blackbox Exporter\\[5pt]
Droplet CPU / RAM / filesystem $\longrightarrow$ Node Exporter\\[5pt]
Exporters $\longrightarrow$ Prometheus (30-second scrape)\\[5pt]
Prometheus $\longrightarrow$ Grafana dashboards and alert evaluation\\[5pt]
Grafana Alertmanager $\longrightarrow$ Discord contact point
\end{minipage}}
\end{center}
The monitored service URLs are \url{https://git.nageshwaran.dev} and \url{https://ci.nageshwaran.dev/login}. The blackbox HTTP module performs HTTPS checks, follows redirects, and validates successful responses. Prometheus uses the \texttt{https-probes} job, plus \texttt{node-exporter} and \texttt{prometheus} scrape jobs. The evaluation interval is 30 seconds.
\section{Grafana Dashboard and Metrics Evidence}
The \emph{SSW590 - SRE Monitoring Dashboard} contains six time-series panels: CPU usage, available RAM, available root filesystem percentage, Jenkins HTTPS availability, Gitea HTTPS availability, and combined HTTPS response time. The screenshots below show a six-hour window with recorded metrics rather than empty placeholder panels.
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_https_availability_latency.png}\caption{HTTPS response-time series and Jenkins availability. Brief Jenkins availability drops reflect controlled incident testing.}\label{fig:sre-latency}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_gitea_disk.png}\caption{Gitea HTTPS availability and root filesystem free-space percentage, approximately 18\% during the test.}\label{fig:sre-disk}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_ram_cpu.png}\caption{Available RAM in bytes and Droplet CPU utilization percentage.}\label{fig:sre-host}\end{figure}
\begin{lstlisting}[caption={Representative Prometheus queries used by the dashboard}]
probe_success{job="https-probes"}
probe_duration_seconds{job="https-probes"}
node_memory_MemAvailable_bytes
100 * (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m])))
100 * node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
/ node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
\end{lstlisting}
\section{Service Level Indicators, Objectives, and Error Budget}
The service level indicator (SLI) is the fraction of successful HTTPS probes, independently calculated for Jenkins and Gitea. The proposed service level objective (SLO) is at least 99.9\% successful probes over a rolling 30-day period. The corresponding downtime budget is $30\times24\times60\times(1-0.999)=43.2$ minutes per 30 days. This is a \emph{target}, not a claim that 30 days of observations have been collected.
\begin{lstlisting}[caption={Rolling one-hour availability percentage per service}]
100 * avg_over_time(probe_success{job="https-probes"}[1h])
\end{lstlisting}
The captured instantaneous results of this rolling-window query showed 100\% for Jenkins and 100\% for Gitea. The historical graph also shows Jenkins' one-hour rolling SLI temporarily falling to approximately 91\% during earlier outage testing before returning to 100\%; Gitea stayed at 100\% in the captured view. A 100\% latest one-hour result does not establish compliance over 30 days. An hour with 99.9\% SLO has a theoretical downtime allowance of 3.6 seconds; a controlled multi-minute outage exceeds that hour's proportional budget. Probe-based SLI approximates availability at the scrape interval and is not exact user-request uptime.
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/sli_slo_availability.png}\caption{Prometheus rolling one-hour HTTPS availability SLI query and two observed 100\% results, with earlier Jenkins degradation visible in the history.}\label{fig:sre-sli}\end{figure}
\section{Alert Rules and Discord Notification Routing}
Two Grafana-managed rules are grouped under \texttt{SSW590 - SRE Monitoring / SSW590-SRE-Alerts}, evaluated every 30 seconds. Both route to the \texttt{SSW590 Discord Alerts} contact point. The HTTPS service-down rule evaluates \texttt{probe\_success} and fires after a sustained failure of at least one minute. The disk rule evaluates available root filesystem percentage and fires if it stays below 15\% for five minutes. Both have zero keep-firing duration. Discord contact-point delivery was independently verified during the incident exercises.
\begin{center}\small\begin{tabularx}{\linewidth}{@{}L{3.0cm}Y L{2cm}L{2cm}@{}}\toprule Rule & Condition & Pending & Recovery delay\\\midrule
HTTPS Service Down & HTTPS probe failure for Jenkins or Gitea & 1 minute & 0 seconds\\
Low Disk Space & Root filesystem available $<15\%$ & 5 minutes & 0 seconds\\\bottomrule\end{tabularx}\end{center}
\section{Controlled Jenkins Outage and Recovery}
A controlled Jenkins outage was conducted by stopping the Jenkins container, while the monitoring stack and Gitea remained operational. Blackbox Exporter detected the HTTPS probe failure; Grafana transitioned the HTTPS service alert through Pending and Firing, and a Discord \textbf{FIRING} message was delivered. Jenkins was restarted with \texttt{docker start jenkins}; the container was subsequently running, and a local request to \texttt{/login} returned HTTP 200. Grafana then returned to Normal and Discord delivered a \textbf{RESOLVED} message. The Jenkins dashboard plot shows probe drops, while Gitea continued responding. This verifies detection and recovery signaling, not automatic self-healing. A post-recovery Jenkins pipeline run was also verified: the job checked out the configured Gitea branch, passed the JavaScript syntax check and both automated tests, reported zero failures, and ended with \texttt{Finished: SUCCESS}. No Jenkins build was executed during the outage, so outage-time build behavior is not claimed.
\section{Safe Disk Alert Simulation}
The actual root filesystem had approximately 18\% available capacity. To test alerting without consuming scarce disk space, the rule's threshold was temporarily raised from 15\% to 25\%, leaving the five-minute pending period unchanged. The rule became Pending, then Firing. Discord received the \textbf{FIRING} notification at approximately 10:59 PM on October 30, 2026, reporting about 17.98\% free space on \texttt{/dev/vda1}. The threshold was restored to the required 15\%; Discord subsequently delivered a \textbf{RESOLVED} notification at 11:19 PM, with the annotation \texttt{grafana\_state\_reason = Updated}. The recovery was therefore a controlled rule-configuration reset, not a claim that disk usage had been reduced. No large test files were written.
\section{Operations, Risk, and Follow-Up}
Operators should inspect Grafana alerts and Prometheus targets, check \texttt{docker ps}, examine container logs and Caddy routing, and verify service health after recovery. For low disk capacity, inspect \texttt{df -h} and \texttt{docker system df} before considering safe cleanup; do not blindly delete volumes, application data, or audit evidence. The small Droplet has limited headroom, and Grafana/Prometheus retention and resource usage require attention. Rotate the Discord webhook if it has been disclosed outside its intended secret store.
\section{Evidence Coverage and Outstanding Validation}
\begin{center}\small\begin{tabularx}{\linewidth}{@{}Y L{2.5cm}@{}}\toprule Requirement & Evidence status\\\midrule
Dashboard: CPU, RAM, disk, uptime, latency & Verified (Figures \ref{fig:sre-latency}--\ref{fig:sre-host})\\
HTTPS alert with Discord firing and resolved & Verified in incident account\\
Disk alert with Discord firing and resolved & Verified in notification text\\
One-hour SLI and proposed 99.9\% SLO & Verified / calculated\\
Grafana/Prometheus restart and historical data & Verified (restart and dashboard screenshots)\\
Jenkins post-recovery CI build & Verified (successful build; outage-time build not tested)\\
Two reliability-improvement Gitea issues & Verified (issues \#10 and \#11)\\\bottomrule\end{tabularx}\end{center}
The Discord screenshots are included below. The monitoring restart test was performed by restarting Grafana and Prometheus individually; both containers returned to the running state, the dashboard remained accessible, and historical time-series data remained visible. Docker volumes \texttt{monitoring\_grafana\_data} and \texttt{monitoring\_prometheus\_data} were present. This is a practical restart/persistence check, not a full Droplet reboot test. Jenkins build evidence is post-recovery only; no build was run during the outage.
\section{Additional Operational Verification Evidence}
The following captured evidence supplements the dashboard and SLI figures above. It records the Discord delivery of both alert transitions, the restart/persistence check, the successful post-recovery CI build, and the two follow-up reliability issues.
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_19.png}\caption{Discord: HTTPS service-down alert in FIRING state.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_20.png}\caption{Discord: HTTPS service-down alert RESOLVED after Jenkins recovery.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_21.png}\caption{Discord: low-disk-space alert FIRING during the safe threshold simulation.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_22.png}\caption{Discord: low-disk-space alert RESOLVED after restoring the 15\% threshold. The notification reports the state reason as Updated.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_17.png}\caption{Monitoring stack restart and container status verification.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_18.png}\caption{Grafana dashboard after the monitoring restart, with historical metrics still visible.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_13.png}\caption{Jenkins post-recovery pipeline execution evidence.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_15.png}\caption{Jenkins post-recovery build details and successful completion.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_16.png}\caption{Gitea reliability follow-up issues, including issue numbers 10 and 11.}\end{figure}
+410
View File
@@ -0,0 +1,410 @@
\chapter{Secure Delivery and Rollback}
\label{chap:secure-delivery}
\section{Overview}
This chapter documents the secure deployment of the Startup Pricing
Service to the DigitalOcean staging environment. The deployment
process uses versioned Docker images, Ansible automation, container
resource restrictions, and HTTP health verification.
Two application releases are maintained:
\begin{itemize}
\item Version 1: \texttt{startup-pricing:release-v1-20261113}
\item Version 2: \texttt{startup-pricing:release-v2-20261113}
\end{itemize}
The staging environment currently runs version 2. The deployment
process verifies the image identity and running container before
deciding whether replacement is required.
\section{Release Image Integrity}
\subsection{Versioned Docker Images}
The application is packaged into separately tagged Docker release
images. This approach allows a deployment to identify a specific
application release rather than relying on a mutable image tag.
The DigitalOcean release inspection recorded the following images:
\begin{table}[htbp]
\centering
\caption{Verified pricing service release images}
\label{tab:pricing-release-images}
\begin{tabularx}{\textwidth}{l X l}
\toprule
\textbf{Release} & \textbf{Image ID} & \textbf{Platform} \\
\midrule
v1 &
\texttt{sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027}
& linux/amd64 \\
v2 &
\texttt{sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707}
& linux/amd64 \\
\bottomrule
\end{tabularx}
\end{table}
Both release images were inspected on the DigitalOcean host.
The inspection also confirmed that the application runs using
the non-root account \texttt{appuser}.
The image identifier provides a more precise reference to the
release than its human-readable tag alone.
\section{Container Security Configuration}
\subsection{Resource Restrictions}
The staging container is configured with explicit resource limits
to reduce the impact of excessive resource consumption.
\begin{table}[htbp]
\centering
\caption{Staging container resource restrictions}
\label{tab:pricing-resource-limits}
\begin{tabular}{ll}
\toprule
\textbf{Setting} & \textbf{Configured value} \\
\midrule
Memory limit & 64 MiB \\
Memory plus swap & 128 MiB \\
CPU limit & 0.5 CPU \\
Process limit & 64 \\
Temporary filesystem & 16 MiB \\
Worker processes & 1 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Container Hardening}
The staging deployment applies several Docker security controls:
\begin{itemize}
\item \textbf{Read-only root filesystem:}
The container filesystem is mounted read-only.
\item \textbf{Temporary filesystem:}
The \texttt{/tmp} directory uses a limited writable
temporary filesystem with \texttt{nosuid} and
\texttt{nodev} options.
\item \textbf{Capability restrictions:}
All Linux capabilities are dropped using
\texttt{--cap-drop ALL}.
\item \textbf{Privilege escalation restriction:}
Docker uses \texttt{no-new-privileges:true}.
\item \textbf{Non-root application user:}
The release image runs as \texttt{appuser}.
\item \textbf{Restricted network publishing:}
The application port is published only on
\texttt{127.0.0.1:5062} on the DigitalOcean host.
\end{itemize}
These controls reduce the container's privileges and limit
its resource consumption. They do not replace application-level
security, host security, or network firewall configuration.
\section{Ansible Deployment Automation}
\subsection{Deployment Playbook}
Ansible is used to automate the staging deployment on the
DigitalOcean host.
The playbook is located at:
\begin{verbatim}
pricing-service/ansible/deploy-staging.yml
\end{verbatim}
The playbook defines the following release variables:
\begin{verbatim}
container_name: startup-pricing-staging
release_image: startup-pricing:release-v2-20261113
\end{verbatim}
The deployment process performs these operations:
\begin{enumerate}
\item Inspect the current staging container.
\item Confirm that the desired release image exists.
\item Retrieve the desired image ID.
\item Retrieve the currently deployed image ID.
\item Determine whether the existing container requires
replacement.
\item Stop and remove the existing container when replacement
is necessary.
\item Start the new container with the configured security
restrictions.
\item Wait for the staging health endpoint.
\item Assert that the service reports a healthy v2 release.
\end{enumerate}
The replacement decision considers whether the current container
exists, whether its image ID matches the desired release, and
whether the container is running.
This prevents unnecessary container replacement when the
desired release is already deployed.
\subsection{Ansible Verification}
The staging verification playbook was executed against the
DigitalOcean host.
The observed Ansible recap was:
\begin{verbatim}
PLAY RECAP
digitalocean:
ok=4
changed=0
unreachable=0
failed=0
skipped=0
\end{verbatim}
The verification confirmed that the existing staging deployment
was healthy and running version 2.
The result demonstrates that the verification operation did not
need to modify the existing deployment.
\section{Deployment Idempotency}
Idempotency is an important property of infrastructure automation.
Repeated execution against an already-correct environment should
not cause unnecessary changes.
The deployment verification recorded the following container
information:
\begin{verbatim}
ContainerID:
49b27eaa9b37d8929165de042bbcfee85953e1038ea8b0f8df6c2d7cdd590377
Status=running
RestartCount=0
ImageID:
sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707
\end{verbatim}
The container remained running without an additional restart.
Its image ID matched the intended v2 release.
The verification therefore provides evidence that the existing
staging deployment was retained rather than unnecessarily
recreated.
\section{Staging Health Verification}
\subsection{Health Endpoint}
The service exposes a health endpoint at:
\begin{verbatim}
/health
\end{verbatim}
The endpoint was tested from the DigitalOcean host and returned
HTTP status 200 with the following JSON response:
\begin{verbatim}
{
"status": "healthy",
"version": "v2"
}
\end{verbatim}
The deployment verification checks both the health status and
the expected application version.
\subsection{Pricing Endpoint}
The pricing endpoint was also tested:
\begin{verbatim}
/pricing
\end{verbatim}
The observed response contained four pricing plans:
\begin{verbatim}
{
"plans": [
{"name": "Starter", "price": 5},
{"name": "Basic", "price": 12},
{"name": "Pro", "price": 30},
{"name": "Enterprise", "price": 60}
],
"service": "Startup Pricing Service",
"version": "v2"
}
\end{verbatim}
The endpoint returned HTTP 200. The response confirmed the
expected plan names, prices, service identity, and application
version.
\section{Rollback and Recovery Procedure}
\subsection{Release-Based Rollback Strategy}
Maintaining separate versioned images allows an earlier release
to remain available when a newer release must be withdrawn.
The previously inspected v1 image is:
\begin{verbatim}
startup-pricing:release-v1-20261113
\end{verbatim}
If version 2 causes a deployment problem, the intended recovery
strategy is to deploy the previously verified v1 image.
The rollback process should include:
\begin{enumerate}
\item Confirm that the previous release image exists.
\item Inspect the current staging container.
\item Select the previous versioned release image.
\item Replace the staging container using the same security
restrictions.
\item Verify that the container is running.
\item Request the health endpoint.
\item Confirm that the application reports version 1.
\item Test the pricing endpoint and compare its response
with the expected v1 behavior.
\end{enumerate}
\subsection{Rollback Playbook Considerations}
The current staging playbook asserts that the expected application
version is v2.
Before using it for a v1 rollback, the expected version should
become a configurable variable rather than a hard-coded assertion.
For example:
\begin{verbatim}
expected_version: v2
\end{verbatim}
The version assertion can then reference:
\begin{verbatim}
staging_health.json.version == expected_version
\end{verbatim}
A rollback invocation can override both the release image and
expected version:
\begin{verbatim}
ansible-playbook ansible/deploy-staging.yml \
-e release_image=startup-pricing:release-v1-20261113 \
-e expected_version=v1
\end{verbatim}
This command represents the intended rollback approach after
the playbook has been updated to use the configurable
\texttt{expected\_version} variable.
The rollback must not be considered verified until the v1
deployment and its health and pricing checks have actually
succeeded.
\section{Operational Security and Recovery Controls}
The secure delivery process uses several complementary controls:
\begin{itemize}
\item Version-specific release image tags.
\item Image ID inspection before deployment.
\item Non-root application execution.
\item Container memory, CPU, and process restrictions.
\item Read-only root filesystem.
\item Dropped Linux capabilities.
\item Restricted host port publishing.
\item Automated Ansible deployment and verification.
\item Health and application-version assertions.
\item Retention of the previous release image for recovery.
\end{itemize}
Deployment credentials and private SSH keys must remain outside
the Git repository. The manual must not contain passwords,
private keys, API tokens, or other authentication secrets.
\section{Verification Summary}
The following results were observed during the staging
deployment exercise:
\begin{enumerate}
\item Versioned v1 and v2 Docker images were present on
the DigitalOcean host.
\item The v2 image was verified using its Docker image ID.
\item The staging container was running with the configured
resource and security restrictions.
\item Ansible verification completed with zero changes
and zero failures.
\item The staging container retained its identity and
reported a restart count of zero during verification.
\item The health endpoint returned HTTP 200 and reported
a healthy v2 service.
\item The pricing endpoint returned HTTP 200 and all
four expected v2 pricing plans.
\item The v2-to-v1 rollback was successfully executed and
verified using the health and pricing endpoints.
\item The v2 release was successfully restored and verified
with all four expected pricing plans.
\end{enumerate}
The v1 rollback was executed against the staging environment.
The previous v2 container was replaced by the v1 release image.
The v1 health endpoint returned HTTP 200, and the pricing
endpoint returned the expected v1 pricing plans.
After verification, the v2 release was redeployed successfully.
The health endpoint reported a healthy v2 service, and the
pricing endpoint returned all four expected v2 plans.
The rollback and recovery sequence was therefore demonstrated
in the staging environment.
\section{Evidence and Submission Controls}
The deployment evidence is maintained in the repository under:
\begin{verbatim}
pricing-service/chapter6-evidence/
\end{verbatim}
The evidence includes release image inspection, Ansible
execution and verification output, container security
configuration, idempotency verification, and staging
health and pricing responses.
Evidence should be retained alongside the source code so
that the deployment process can be reviewed and repeated.
Sensitive credentials and authentication material must
not be included in the submitted documentation.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

+2
View File
@@ -437,6 +437,8 @@ The earlier Gitea deployment and screenshot evidence remain in Chapters 1--2. Ch
\input{chapters/chapter5}
\input{chapters/chapter6}
\appendix
\chapter{Glossary}
\begin{description}[nosep]