DevOps Interview Questions: Kubernetes, Terraform, Ansible, Monitoring, Security and Architecture

DevOps Certification 26 min min read Updated: Nov 17, 2026 Advanced
DevOps Interview Questions: Kubernetes, Terraform, Ansible, Monitoring, Security and Architecture
Advanced Topic 2 of 3

Kubernetes

1. Explain Kubernetes architecture.

Control plane: API server (front door), etcd (state), scheduler (places Pods), controller manager (reconciles desired state). Nodes: kubelet (runs Pods), kube-proxy (Service networking) and a container runtime (containerd). Everything is declarative and reconciled by controllers.

2. Pod vs Deployment vs ReplicaSet vs StatefulSet vs DaemonSet?

A Pod is the smallest unit. A ReplicaSet keeps N identical Pods running. A Deployment manages ReplicaSets for rolling updates and rollback. A StatefulSet gives stable identity and storage (databases). A DaemonSet runs one Pod per node (agents).

3. Explain Service types.

ClusterIP (internal), NodePort (port on every node), LoadBalancer (cloud load balancer), ExternalName (DNS alias), headless (no virtual IP, direct Pod DNS). Ingress or Gateway API handles HTTP routing on top of Services.

4. Liveness vs readiness vs startup probes?

Liveness restarts a stuck container. Readiness removes a Pod from Service endpoints until it is ready, without restarting. Startup gives slow-starting apps time before liveness begins. Do not put dependency checks in liveness.

5. Requests vs limits? What is OOMKilled?

Requests are used for scheduling and guarantee a minimum. Limits cap usage: CPU is throttled, memory over the limit causes the container to be killed (OOMKilled). Setting requests equal to limits gives the Guaranteed QoS class.

6. How does a rolling update work and how do you roll back?

The Deployment creates a new ReplicaSet and scales it up while scaling the old one down, within maxSurge and maxUnavailable, gated by readiness probes. Roll back with kubectl rollout undo or by reverting Git in GitOps.

7. A Pod is stuck in Pending. Why?

kubectl describe pod Events show it: insufficient CPU or memory, node selectors or taints with no matching node, an unbound PersistentVolumeClaim, or quota limits.

8. A Pod is in CrashLoopBackOff. Steps?

  1. kubectl logs <pod> --previous
  2. kubectl describe pod for exit code, OOMKilled and probe failures
  3. Check ConfigMaps, Secrets and environment variables
  4. Check image, command and arguments
  5. Reproduce with kubectl debug or by running the image locally

9. A Service has no traffic. What do you check?

kubectl get endpoints for the Service. Empty endpoints mean the selector does not match Pod labels or Pods are not ready. Then check the targetPort, NetworkPolicies, Ingress rules and DNS.

10. How does RBAC work?

Roles or ClusterRoles define allowed verbs on resources. RoleBindings or ClusterRoleBindings grant them to users, groups or ServiceAccounts. Use least privilege and test with kubectl auth can-i.

11. How do you manage secrets in Kubernetes?

Secrets are base64-encoded, not encrypted by default. Enable encryption at rest, restrict access with RBAC, and prefer External Secrets Operator or a CSI driver backed by a vault. In GitOps use Sealed Secrets or SOPS.

12. How do HPA, VPA and Cluster Autoscaler differ?

HPA changes the number of Pods based on metrics. VPA adjusts Pod resource requests. Cluster Autoscaler or Karpenter adds nodes when Pods are unschedulable and removes idle nodes.

13. How do you upgrade a cluster with minimal downtime?

Read release notes and deprecations, back up etcd, upgrade the control plane, then upgrade nodes one at a time using cordon and drain (respecting PodDisruptionBudgets) or surge node pools in managed services. Upgrade one minor version at a time.

14. Helm vs Kustomize?

Helm templates plus values with release tracking, good for packaged and third-party apps. Kustomize patches plain YAML per environment, simpler for your own apps. Many teams combine them with Argo CD.

15. What is GitOps and why is it more secure?

Git holds desired state and an in-cluster agent (Argo CD or Flux) pulls and reconciles it. CI does not need cluster credentials, changes are audited, drift is corrected and rollback is a git revert.

Terraform

16. What is Terraform state and why is remote state needed?

State maps configuration to real resources and caches attributes. Remote state in an encrypted, versioned backend with locking enables teamwork and prevents concurrent applies and loss.

17. count vs for_each?

count uses numeric indexes, so removing a middle item shifts the others and can destroy resources. for_each uses stable keys and is preferred for collections.

18. How do you detect and handle drift?

terraform plan -refresh-only shows drift. Fix by applying to revert the change, or update code and state to accept it. Prevent with restricted console access and scheduled drift checks.

19. How do you structure Terraform for multiple environments?

Reusable versioned modules plus separate root configurations (directories) per environment with their own backends and permissions. Workspaces suit identical temporary copies, but separate directories give clearer isolation for dev, staging and prod.

20. How do you import existing infrastructure?

Write the resource block and use terraform import or an import block (Terraform 1.5 and later) to attach it to state, then run plan until there is no diff.

21. Secrets in Terraform?

Mark variables and outputs sensitive, never commit tfvars with secrets, pull secrets from a manager at runtime or use managed secrets (such as RDS managed master password), and remember state can contain secrets, so encrypt and restrict it.

22. What is a moved block and lifecycle options?

moved records a rename or restructure so Terraform updates state without destroying. Lifecycle options include create_before_destroy, prevent_destroy, ignore_changes and replace_triggered_by.

23. Terraform vs CloudFormation vs Pulumi vs Ansible?

Terraform is multi-cloud with a plan and large provider ecosystem. CloudFormation is AWS-native with deep integration and managed state. Pulumi uses general-purpose languages. Ansible mainly configures software and operates systems rather than managing cloud resource state.

Ansible

24. What is idempotency?

Running a task repeatedly gives the same final state and reports changes only when something actually changed. Dedicated modules are idempotent, while raw shell is not unless guarded with creates or changed_when.

25. Roles, handlers, variable precedence?

Roles package tasks, templates and defaults for reuse. Handlers run once at the end of a play when notified by a changed task. Role defaults have the lowest precedence and extra vars (-e) the highest.

26. How do you protect secrets in Ansible?

Ansible Vault for encrypted variable files or single values, no_log: true on sensitive tasks, vault password from the CI secret store, or lookups from a secret manager.

27. How do you do a zero-downtime rolling update with Ansible?

Use serial to process hosts in batches, remove each host from the load balancer with delegate_to, update, run health checks with until and retries, then add it back, and stop on failure with max_fail_percentage.

28. Push vs pull configuration management?

Ansible usually pushes over SSH from a control node (agentless). Pull tools (Puppet, Chef, ansible-pull) have agents that fetch configuration, which scales well for large fleets and autoscaling.

Monitoring and SRE

29. What are the four golden signals?

Latency, traffic, errors and saturation.

30. Counter vs gauge vs histogram in Prometheus? Why rate()?

A counter only increases, a gauge moves up and down, a histogram records distributions in buckets for percentiles. A raw counter is not useful alone, so rate() converts it to a per-second increase and handles resets.

31. SLI, SLO, SLA and error budget?

SLI is the measurement, SLO the internal target, SLA the contractual promise. The error budget is 100% - SLO and guides whether to ship features or focus on reliability. Alert on budget burn rate.

32. What makes a good alert?

It reflects user impact, is urgent and actionable, has a runbook, is not noisy (uses for:, grouping), and is reviewed after incidents. Alert on symptoms, not causes.

33. Metrics vs logs vs traces?

Metrics are cheap numeric trends for alerting. Logs give event detail. Traces follow a request across services. Correlating them with a trace id lets you go from alert to cause quickly.

34. How do you handle high cardinality?

Avoid unbounded label values (user ids, URLs with ids), use aggregation or recording rules, drop unneeded labels at scrape time and consider a scalable backend (Mimir, Thanos, VictoriaMetrics).

Security and DevSecOps

35. What is shift-left security?

Running security checks early in development and CI (secret scanning, SAST, dependency and IaC scans) because defects are cheaper to fix before release.

36. SAST vs DAST vs SCA?

SAST analyzes source code, DAST tests the running app from outside, SCA checks third-party dependencies for known vulnerabilities and licenses.

37. How do you secure the software supply chain?

Pin and verify dependencies, generate SBOMs, build on isolated hosted runners with provenance (SLSA), sign images (cosign), verify signatures at admission (Kyverno), use least-privilege short-lived CI credentials and protect branches.

38. How would you harden a Kubernetes cluster?

Restricted Pod Security, non-root and read-only containers, default-deny NetworkPolicies, least-privilege RBAC, private API endpoint, secrets encryption, admission policies, image scanning and signing, runtime detection (Falco), regular patching and audit logging.

39. What is the principle of least privilege and how do you apply it in the cloud?

Grant only the permissions needed. Use IAM roles instead of keys, narrow policies, permission boundaries and SCPs, short-lived credentials, separate accounts per environment and regular access reviews.

Cloud and Architecture

40. Design a highly available web application on AWS.

Multi-AZ VPC with public subnets for an ALB and private subnets for an Auto Scaling group (or EKS or ECS), a Multi-AZ database in isolated subnets, security groups chained from ALB to web to database, S3 and CloudFront for static content, CloudWatch alarms and health checks, IaC for everything, and backups with a tested restore.

41. How do you design disaster recovery?

Define RPO and RTO with the business, choose backup and restore, pilot light, warm standby or active-active accordingly, replicate data across regions, keep IaC ready to rebuild, and test failover regularly.

42. How do you control cloud cost?

  • Tag resources and track cost by team and project
  • Right-size instances and use autoscaling
  • Use Spot for tolerant workloads and savings plans for steady ones
  • Delete idle resources, set budgets and anomaly alerts, use lifecycle rules on storage
  • Review NAT, data transfer and load balancer costs

43. Monolith vs microservices for a small team?

A well-structured monolith is simpler to build and operate and often the right start. Microservices add network, deployment and observability complexity and pay off when teams and scaling needs grow. Keep clear module boundaries so the option remains open.

Senior Scenarios

44. Your Kubernetes cluster costs too much. What do you do?

Review requests versus real usage and right-size, enable HPA and cluster autoscaling, use Spot nodes for stateless workloads, remove idle namespaces and unused load balancers and volumes, consolidate small clusters, and use cost tools such as Kubecost or OpenCost.

45. Deployments are slow and risky in your company. How do you improve them?

Measure DORA metrics first. Then add CI with tests, build once artifacts, automate deployment to staging, introduce progressive delivery with canary and automatic rollback, reduce batch size with trunk-based development, and invest in observability. Show improvements with data.

46. A developer wants cluster-admin access. How do you respond?

Understand the real need, offer a namespace-scoped role or self-service workflow, use time-bound elevated access with audit, and automate common requests so people do not need broad access.

47. Walk me through an incident you handled.

Use the STAR format: situation, task, action and result. Mention detection, mitigation first, communication, root cause, and what you changed afterward. Honest learning from mistakes is valued.

Conclusion

Senior interviews test judgment: how you debug Kubernetes, structure Terraform safely, secure the supply chain, measure reliability with SLOs and trade off cost, risk and speed. Always explain your reasoning and alternatives.

Quick Summary: k8s probes/requests/RBAC; Terraform state + for_each + drift; Ansible idempotent; SLO burn alerts; supply chain signing; HA + DR + cost.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators