Kubernestes inteview questions for experienced:
🔥 Kubernetes Interview Questions with Commands
1. How do you check all resources in a cluster?
kubectl get all
👉 Namespace specific:
kubectl get all -n dev
2. How do you create a resource?
kubectl apply -f deployment.yaml
3. How do you check pod details?
kubectl describe pod pod-name
4. How do you check pod logs?
kubectl logs pod-name
👉 Multi-container pod:
kubectl logs pod-name -c container-name
5. How do you exec into a pod?
kubectl exec -it pod-name -- /bin/bash
6. How do you check nodes?
kubectl get nodes
kubectl describe node node-name
7. How do you scale a deployment?
kubectl scale deployment app-name --replicas=5
8. How do you check deployment status?
kubectl get deployments
kubectl describe deployment app-name
9. How do you check rollout status?
kubectl rollout status deployment app-name
10. How do you rollback deployment?
kubectl rollout undo deployment app-name
11. How do you check services?
kubectl get svc
kubectl describe svc service-name
12. How do you check endpoints?
kubectl get endpoints
13. How do you check events (very important for debugging)?
kubectl get events
14. Pod stuck in Pending – what commands?
kubectl describe pod pod-name
kubectl get nodes
kubectl describe node node-name
15. Pod in CrashLoopBackOff – what commands?
kubectl logs pod-name
kubectl describe pod pod-name
16. ImagePullBackOff issue – commands?
kubectl describe pod pod-name
kubectl get events
17. How do you check resource usage?
kubectl top pod
kubectl top node
18. How do you work with namespaces?
kubectl get ns
kubectl create ns dev
kubectl get pods -n dev
19. How do you apply autoscaling (HPA)?
kubectl autoscale deployment app-name --cpu-percent=50 --min=1 --max=10
20. How do you check Persistent Volumes?
kubectl get pv
kubectl get pvc
kubectl describe pvc pvc-name
21. How do you cordon and drain a node?
kubectl cordon node-name
kubectl drain node-name --ignore-daemonsets
22. How do you delete a resource?
kubectl delete -f deployment.yaml
23. How do you edit a running resource?
kubectl edit deployment app-name
24. How do you port-forward to a pod?
kubectl port-forward pod-name 8080:80
25. How do you check cluster info?
kubectl cluster-info
💥 Real-Time Scenario Commands (Must Remember)
👉 App not accessible
kubectl get svc
kubectl get endpoints
kubectl describe svc service-name
👉 Pod not scheduling
kubectl describe pod pod-name
kubectl get nodes
kubectl describe node node-name
👉 High CPU issue
kubectl top pod
kubectl describe pod pod-name
👉 Deployment mismatch (desired vs running)
kubectl get deployment
kubectl describe deployment app-name
kubectl get pods
============================================================
Senior DevOps engineer from Manish Tiwari:
=================================
1).what is the terraform null and provioidners ?
Terraform null:
null_resource is a dummy resource that does NOT create infrastructure.
👉 It is used to:
* Run provisioners
* Trigger scripts
* Execute automation tasks
✅ Example
resource "null_resource" "example" {
provisioner "local-exec" {
command = "echo Hello from Terraform"
}
}
👉 This will:
* Not create any server
* Only execute the command
=================================
Terraform provisioners :
What are Terraform Provisioners?
Provisioners are used to execute scripts or commands on a resource after it is created (or destroyed).
👉 In simple terms:
Terraform creates infrastructure → Provisioner runs extra setup inside it
✅ Types of Provisioners
1. remote-exec
Runs commands inside the server (VM/EC2)
resource "aws_instance" "example" {
ami = "ami-123456"
instance_type = "t2.micro"
provisioner "remote-exec" {
inline = [
"sudo apt update",
"sudo apt install nginx -y"
]
================
Why npm is installed into docker file ?
=================
Terraform Interview Questions (5 Years Experience) + Commands
1. How do you initialize Terraform?
terraform init
👉 Downloads providers, initializes backend
2. How do you validate your code?
terraform validate
3. How do you check execution plan?
terraform plan
👉 Save plan:
terraform plan -out=tfplan
4. How do you apply changes?
terraform apply
👉 With saved plan:
terraform apply tfplan
5. How do you destroy infrastructure?
terraform destroy
6. How do you format code?
terraform fmt
7. How do you manage Terraform state?
terraform state list
terraform state show aws_instance.example
8. How do you move resources in state?
terraform state mv old_resource new_resource
9. How do you remove resource from state?
terraform state rm aws_instance.example
10. How do you import existing infrastructure?
terraform import aws_instance.example i-123456
11. How do you refresh state?
terraform refresh
12. How do you taint a resource?
terraform taint aws_instance.example
👉 Untaint:
terraform untaint aws_instance.example
13. How do you use workspaces?
terraform workspace list
terraform workspace new dev
terraform workspace select dev
14. How do you debug Terraform?
TF_LOG=DEBUG terraform apply
15. How do you pass variables?
terraform apply -var="instance_type=t2.micro"
👉 Using file:
terraform apply -var-file=dev.tfvars
16. How do you output values?
terraform output
17. How do you lock state (important for team)?
👉 Backend config (AWS S3 + DynamoDB)
backend "s3" {
bucket = "my-tf-state"
key = "prod/terraform.tfstate"
region = "ap-south-1"
dynamodb_table = "tf-lock"
}
💥 Real-Time Scenario Questions (Must Answer Like This)
👉 Scenario 1: Resource drift (manual change in AWS)
Commands:
terraform plan
terraform apply
👉 Explanation:
* Terraform detects drift
* Reconciles with code
👉 Scenario 2: Someone deleted resource manually
terraform plan
terraform apply
👉 It will recreate resource
👉 Scenario 3: Rename a resource without deleting
terraform state mv old_name new_name
👉 Scenario 4: Import existing infra
terraform import aws_instance.example i-123456
terraform plan
👉 Scenario 5: Fix corrupted state
terraform state list
terraform state rm
terraform import ...
👉 Scenario 6: Multiple environments
terraform workspace new dev
terraform workspace new prod
👉 Scenario 7: Apply only specific resource
terraform apply -target=aws_instance.example
👉 Scenario 8: Dependency issue
👉 Use:
depends_on = [aws_vpc.main]
🔥 Advanced Concepts (They WILL ask)
1. Provisioners & Null Resource
👉 Already covered (say not recommended)
2. Modules
module "vpc" {
source = "./modules/vpc"
}
3. Remote Backend
👉 S3 + DynamoDB (must say in interview)
4. for_each vs count
👉 Prefer for_each
5. Lifecycle block
lifecycle {
prevent_destroy = true
}
==========
Linux interview Questions :
1).How to recover accidently deleted /etc/fstab into linux os ? anyone deleted this /etc/fstab .after this we can' boot ur os. boot into recovery mode . then go to the linux terminal page . here we have to execute the blkid command here it will list out the avilble partions and attached filesystems . if your deleting the /etc/fatab.that time root parttion won't be work now we can mount the root parttion in rw mode mount -t ext4 -0 rw,remount dev/sda1 / 2).VMSTAT command into linux ? 3).iostat and dstat command into linux os ? 4).LInux free command into linux os ? in this way we can check it our the memeory usage and swap memeory as well. then it will display out the , used,space avilble ,total ,buffer/catche abd shared what is free space we can execute the command like as the, free -b command : we will get the particular output for the bits so if you want to getto int the outpit in kilobytes : so we can execut ethe comamnd like as the, free -k free -g: it will sh...
Comments
Post a Comment