Scenario-Based Interview Q&A
1. You deployed code, but the website is not loading. How do you troubleshoot?
Check service logs, verify server is running, check DNS, firewall, and application configuration.
2. Jenkins pipeline failed after adding a new stage. What would you check?
Review Jenkins logs, check pipeline syntax, validate credentials, and ensure dependencies are available.
3. Restrict access to a specific object and a specific user in S3
Use a bucket policy or object ACL plus an IAM policy (or cross-account role) for the user. Example bucket policy allows only one principal access to one object. Ensure BlockPublicAcls/BlockPublicPolicy are set. Object ACLs are rarely needed if bucket policy + IAM policy cover it.
4. App in Account A needs images from S3 in Account B
Use cross-account bucket policy to allow Account A’s IAM role/EC2 profile, or AssumeRole in Account B (preferred). Optionally use CloudFront or signed URLs for caching/public distribution.
5. Give temporary 5-minute access to a single S3 object while keeping bucket private
Use AWS CLI or SDK to generate a presigned URL with expires-in 300 seconds. Alternatively use temporary assume-role credentials, but presigned URL is simplest. aws s3 presign s3://my-bucket/my-object.txt --expires-in 300
6. Static website in region A must fetch images stored in a bucket in region B
Enable CORS on the image bucket and add bucket policy, or use CloudFront for production. Direct S3 URLs work if CORS allows. Example CORS config allows origin https://www.example.com.
7. Lambda (in VPC, Account A) must connect to EC2 (Account B)
Use PrivateLink with NLB + VPC Endpoint Service (recommended). Or use VPC Peering with route and SG rules. Ensure DNS resolution and IAM for app-level auth.
8. Explain Kubernetes architecture
Control plane: kube-apiserver, etcd, kube-scheduler, kube-controller-manager. Worker nodes: kubelet, kube-proxy, container runtime. Add-ons: DNS, ingress controller, CNI plugins, monitoring. Objects: Pods, ReplicaSets, Deployments, Services, ConfigMaps, Secrets, Namespaces.
9. Types of Services in Kubernetes
ClusterIP (default, internal), NodePort (basic external), LoadBalancer (cloud LB), ExternalName (DNS alias), Headless service (direct pod DNS). Ingress is not a Service but provides HTTP routing.
10. Scrape data from running nodes using monitoring agent
Deploy node-exporter as a DaemonSet on all nodes. Also use kube-state-metrics and cAdvisor. Configure Prometheus or Prometheus Operator with ServiceMonitor. Use RBAC properly.
11. Schedule specific pods on specific nodes
Use nodeSelector for simple match, nodeAffinity for advanced, taints & tolerations for restricting pods, or DaemonSet for one pod per node. Label nodes appropriately.
12. Use of Namespace in Kubernetes
Provides logical isolation, scoping for resources, RBAC, ResourceQuota, and environment separation (dev, stage, prod).
13. Communication between pods in different namespaces
Pods can talk to services in other namespaces via DNS like my-service.my-namespace.svc.cluster.local. No network changes are required by default.
14. Stop communication between pods in two different namespaces
Use NetworkPolicy with default deny and allow specific traffic. CNIs like Calico support namespace isolation.
15. When to use ConfigMap and Secrets
ConfigMap: non-sensitive data. Secret: sensitive data (passwords, tokens). Both can be injected as env vars or mounted as files.
16. Benefit of using Secrets over ConfigMap
Secrets can be encrypted at rest, managed via RBAC, and integrated with KMS or external secret managers. ConfigMaps are not encrypted.
17. Can we delete the image from which a container is running?
Yes, deleting the image does not stop a running container because it uses its own copy. But the image won’t be available for new containers.
18. If you deleted the image and then restarted the container, what happens?
If image is in registry, it will pull and start. If deleted from registry and not present locally, restart fails with ErrImagePull / ImagePullBackOff.
19. Troubleshooting 401 vs 403 errors
401 Unauthorized: authentication failed or not provided. Troubleshoot tokens, headers, expiry. 403 Forbidden: authentication succeeded but not authorized. Troubleshoot IAM policies, RBAC, ACLs, SCPs.
20. Auto-trigger Jenkins pipeline from GitHub
Configure GitHub webhook to Jenkins (push/pull_request events). Enable GitHub hook trigger in Jenkins job. For multibranch pipelines, use GitHub Branch Source plugin.
21. What is Multibranch Pipeline in Jenkins?
It auto-discovers branches in SCM with Jenkinsfile and creates jobs per branch. It also manages PR jobs. Useful for CI/CD with multiple branches.
22. Save cost on AWS RDS for non-production
Use smaller instances, Single-AZ, stop/start DB when not used, delete old snapshots, use Aurora Serverless, schedule automation for uptime.
23. Provision 5 identical EC2 instances using Terraform
Use count = 5 in aws_instance resource or use aws_autoscaling_group. Count index helps differentiate tags/names.
24. Terraform should use existing manually created VPC
Use data source to look up by tag or name: data "aws_vpc" with filter by tag:Name, then reference data.aws_vpc.existing.id.
25. Have you used dynamic block in Terraform?
Yes, dynamic block is used to generate nested blocks like multiple ingress rules dynamically using for_each.
26. What is pre-hook in Ansible Playbook?
In Ansible, pre_tasks section runs before roles and tasks. Some tools call it pre-hooks but native is pre_tasks.
27. How to increase disk space on Linux server
For AWS EBS: modify volume size, then grow partition with growpart and resize2fs/xfs_growfs. For LVM: extend VG/LV and resize filesystem. Backup before resizing.
28. How do you manage versioning for code?
Use Git branching strategy (GitFlow, trunk-based). Use semantic versioning with tags. Protect main branch with reviews. Automate releases in CI/CD.
29. Can we edit the tag?
Yes, delete and recreate lightweight or annotated tags. If already pushed, must force-push. Not recommended for shared repos.
30. Process to deploy a hotfix
Create hotfix branch from release/prod tag, fix issue, run tests, PR to release branch, merge, create new release tag, deploy, validate, monitor.
31. Explain monitoring setup with Grafana + Prometheus
Prometheus scrapes metrics, Alertmanager handles alerts, Grafana visualizes. Use exporters (node, kube-state), deploy via Prometheus Operator for Kubernetes.
32. Troubleshoot CrashLoopBackOff / ImagePullBackOff in K8s
Check kubectl describe for events, image name/tag, imagePullSecrets, registry creds. For CrashLoopBackOff check logs, exit codes, probes, resource limits.
33. How to check which files are consuming high disk space in Linux?
Use du -sh, du --max-depth, sort -hr, ncdu for interactive view. Use lsof | grep deleted to find deleted-but-open files. df -h for mount usage.
34. What is an endpoint and what are the types of endpoints?
An endpoint is a network address (IP:Port or DNS) where a service can be accessed. Types include API endpoints (REST/gRPC URLs), Service endpoints (Kubernetes ClusterIP, NodePort, LoadBalancer), Database endpoints (RDS connection string), Storage endpoints (S3 bucket URL), Public vs Private endpoints, and Managed Service endpoints like AWS PrivateLink or CloudFront.
35. How will you ensure zero downtime for your application?
Zero downtime can be achieved by using readiness and liveness probes, enabling connection draining in load balancers, deploying with rolling/blue-green/canary strategies, applying backward-compatible DB schema changes, making applications stateless, scaling with autoscaling and headroom, and using feature flags for gradual rollout.
36. When should we use Rolling Update and when should we use Blue-Green strategy?
Rolling Update replaces instances/pods gradually, suitable for low-risk, frequent updates with lower cost. Blue-Green keeps two full environments (blue and green) and switches traffic instantly, best for major releases, risky changes, and instant rollback. Rolling is cost-efficient but slower rollback, while Blue-Green is safer but more expensive.
37. How are you utilising AWS Karpenter?
AWS Karpenter is used as an open-source autoscaler for EKS that provisions EC2 nodes dynamically. It replaces cluster-autoscaler for faster scaling and better bin-packing. Setup involves installing the controller, defining AWSNodeTemplate (subnets, AMI, IAM role), and creating a Provisioner (instance types, zones, TTL). Benefits include cost savings with Spot + On-Demand, faster scale-ups, and efficient workload scheduling.
38. How to create infrastructure for three environments like dev, staging, and prod, and how to manage the state file and configuration for them?
Use a structured Terraform repo with shared modules and separate environment folders (envs/dev, staging, prod). Manage state separately using remote backend (S3 + DynamoDB locking) for each environment. Store configurations in environment-specific tfvars files. Keep secrets in AWS Secrets Manager or SSM, not in tfstate. Best practices include isolating state files, enabling S3 versioning, applying changes via CI/CD pipeline with approvals for prod, and restricting access with IAM policies.
39. In your project, how did you handle application logs inside Docker containers?
By default, Docker stores logs in JSON format. In real-time, we redirect logs to centralized tools like ELK stack (Elasticsearch, Logstash, Kibana), Splunk, or use Docker logging drivers (json-file, syslog, fluentd) to manage and analyze logs.
40. If a container crashes frequently, how would you troubleshoot?
First check logs using 'docker logs <container_id>', then check resource usage with 'docker stats'. Verify entrypoint/CMD configuration, health checks, and dependencies. For debugging, start container in interactive mode and check application-level issues.
41. What steps would you take if a Docker image size is very large?
Use multi-stage builds, choose smaller base images (like alpine), remove unnecessary packages, clean cache after installs, and use .dockerignore to exclude unwanted files.
42. If two containers need to communicate but they are on different networks, how do you solve it?
You can create a user-defined bridge network and attach both containers to the same network, or expose container ports and use service discovery in orchestrators like Kubernetes.
43. How do you secure Docker in production?
Use rootless containers, apply resource limits (CPU/memory), enable Docker Content Trust for image signing, scan images for vulnerabilities, and use distroless or minimal images.
44. Have you faced issues with Docker Daemon being a single point of failure?
Yes, in real-time setups the Docker daemon crash brings down all containers on that host. To mitigate, use orchestrators like Kubernetes or Docker Swarm to distribute workloads across multiple nodes.
45. How do you persist database data inside containers?
We use Docker volumes for persistence so that data remains even if the container is removed. For production, we map volumes to external storage solutions like EBS, NFS, or CSI drivers in Kubernetes.
46. What is your approach if Docker Hub rate limits image pulls?
Configure a local private registry (like Nexus, Artifactory, or AWS ECR) to cache/pull images internally, and use authenticated Docker Hub accounts with higher pull limits.
47. Have you faced a container consuming high CPU or memory?
Yes, to handle it we set resource limits using '--cpus' and '--memory' in docker run or within Docker Compose/Kubernetes manifests. Monitoring tools (cAdvisor, Prometheus) help detect such issues early.
48. What is your strategy for patching vulnerabilities in Docker images?
We use image scanning tools like Trivy, Anchore, or Clair to detect CVEs, then rebuild images with updated base images and security patches. We also maintain CI/CD pipelines to automate scans.