Skip to content
$ lynuxpro

INTERVIEW PREP

Interview questions

570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.

Showing 106–120 of 224 questions

106.How do you manage several clusters?MidGitOps with Argo CD

Add each with argocd cluster add and give it labels. Applications choose a destination by name, and a cluster generator can pick clusters by label.

107.How does Argo CD read a private Git repo?MidGitOps with Argo CD

You add credentials once with argocd repo add, using an HTTPS token or an SSH deploy key. Use a read-only key for that repo only. Every Application that uses the repo then works.

108.Why use a remote backend with locking?MidTerraform

A shared backend such as S3 gives the whole team one copy of state. Locking stops two people applying at the same time, which could corrupt state. Turn on versioning and encryption for the bucket as well, because state can contain secrets.

109.What is the difference between a resource and a data source?MidTerraform

A resource is something Terraform creates and manages. A data source only reads something that already exists, such as an existing VPC or the latest AMI, so you can use its values without managing it.

110.How does Terraform decide the order of work?MidTerraform

It builds a dependency graph from references. If one resource uses another's attribute, it waits for it. Independent resources run in parallel. Use depends_on only when there is a hidden dependency with no reference.

111.When should you use for_each instead of count?MidTerraform

Use for_each when each item has a clear name. Each copy gets a stable key, so removing one item destroys only that item. With count, copies are numbered, so removing one from the middle shifts the others and can cause changes or deletes you did not want.

112.What is a module?MidTerraform

A folder of Terraform files used as a reusable package, with variables as inputs and outputs as results. Call it with a module block and different values per environment. Pin the version when it comes from a registry or Git.

113.Workspaces or separate folders for environments?MidTerraform

Workspaces keep several states in one backend and are quick to start, but it is easy to run in the wrong one and the code is shared exactly. Separate folders give each environment its own backend, variables and access rules, which is safer for production. Many teams choose folders or separate pipelines.

114.A plan wants to destroy and recreate a resource you only renamed. What do you do?MidTerraform

Add a moved block (or run terraform state mv) so Terraform knows the new address is the same object. Plan again and confirm that it shows no destroy.

115.How do you bring an existing, hand-made resource under Terraform?MidTerraform

Write an import block with the resource address and the real id, run plan (optionally with -generate-config-out to get draft code), fix the code until the plan shows no changes, then apply to record it in state.

116.What does the cidrsubnet function do?MidTerraform

It cuts a smaller network out of a bigger one. cidrsubnet("10.0.0.0/16", 8, 1) gives 10.0.1.0/24: it adds 8 bits to the mask and picks network number 1. It lets you build subnets from one base range with no hand math.

117.When do you use templatefile?MidTerraform

When you need a text file, such as a startup script or config, with values filled in. You write the file with placeholders and call templatefile with a map of values.

118.What is the difference between a precondition, a postcondition and a check block?MidTerraform

A precondition is tested before a resource is made and stops the run if false. A postcondition is tested after and also stops the run. A check block tests anything in the whole setup and only prints a warning, so it suits health checks.

119.How do you replace a resource that is broken without touching others?MidTerraform

Use terraform apply -replace=ADDRESS. It is shown in the plan, so it can be reviewed. The older terraform taint command changed state before any review and is deprecated.

120.How do you make resources in two regions?MidTerraform

Add a second provider block with an alias and a different region. Pick it on a resource with provider = aws.alias. For modules, pass it in with the providers argument.