SRE Automation Tools & Infrastructure as Code 5 — Questions and Answers
Question 1: What does 'policy as code' mean in infrastructure management?
- Writing infrastructure cost budgets in spreadsheet formulas
- Defining and enforcing governance rules using code rather than manual processes (Correct answer)
- Automating HR policy distribution via configuration management
- Using code reviews as the only approval gate for infrastructure changes
Correct answer: Defining and enforcing governance rules using code rather than manual processes
Policy as code means encoding compliance, security, and operational rules as machine-readable code that can be automatically enforced and version-controlled.
Question 2: Which command initializes a Terraform working directory and downloads required providers?
- terraform get
- terraform init (Correct answer)
- terraform setup
- terraform install
Correct answer: terraform init
`terraform init` initializes the working directory, downloads provider plugins, and sets up the backend for state storage.
Question 3: What is 'infrastructure drift detection' and why is it important for SREs?
- Monitoring network latency changes over time
- Identifying when actual infrastructure differs from its IaC definition so it can be corrected (Correct answer)
- Detecting performance degradation trends in CI/CD pipelines
- Tracking which team members made the most infrastructure changes
Correct answer: Identifying when actual infrastructure differs from its IaC definition so it can be corrected
Drift detection identifies discrepancies between actual infrastructure and its IaC definition, allowing SREs to maintain consistency and prevent unexpected behavior.
Question 4: In Kubernetes, what is the purpose of a ConfigMap?
- It defines CPU and memory limits for pods
- It stores non-sensitive configuration data that can be consumed by pods (Correct answer)
- It manages network routing rules for services
- It controls which nodes pods are scheduled on
Correct answer: It stores non-sensitive configuration data that can be consumed by pods
A ConfigMap stores non-sensitive configuration data as key-value pairs that can be injected into pods as environment variables or mounted as files.
Question 5: What is the SRE benefit of using declarative IaC over imperative scripts?
- Declarative code runs significantly faster than imperative scripts
- Declarative IaC describes desired state, making the system responsible for achieving and maintaining it (Correct answer)
- Imperative scripts cannot be stored in version control
- Declarative tools require no provider credentials
Correct answer: Declarative IaC describes desired state, making the system responsible for achieving and maintaining it
Declarative IaC lets you specify what you want rather than how to get there, enabling tools to handle idempotency and state reconciliation automatically.
Question 6: Which strategy reduces risk when deploying infrastructure changes using IaC?
- Applying all changes directly to production during low-traffic hours
- Testing changes in a lower environment before promoting to production (Correct answer)
- Disabling monitoring alerts during the deployment window
- Combining multiple large changes into a single deployment
Correct answer: Testing changes in a lower environment before promoting to production
Testing infrastructure changes in staging or development environments before production reduces the risk of outages caused by untested configurations.
Question 7: What does 'infrastructure versioning' enable in an SRE workflow?
- Automatically scaling infrastructure based on version numbers
- Rollback to a previous known-good infrastructure state when issues arise (Correct answer)
- Generating semantic version numbers for server instances
- Versioning database schemas alongside application code
Correct answer: Rollback to a previous known-good infrastructure state when issues arise
Versioning infrastructure code in Git enables rollback to previous configurations when new changes cause problems, providing a safety net for infrastructure changes.
What does 'policy as code' mean in infrastructure management?