DevOps Interview Q&A
1. How does GitLab trigger pipelines automatically when a developer pushes code?
Git triggers build the moment developer commits to the respective branch.
It works based on hook(push events).
2. How do you declare dependent stages in a CI/CD YAML file?
Use stages for ordering and needs for explicit dependencies.
3. What is terraform init?
terraform init: Initializes the environment by setting up the backend, downloading providers, and modules.
4. What is backend.tf?
backend.tf: Defines the backend configuration, which tells Terraform where to store the state file (local or remote).
5. What does terraform plan do?
terraform plan essentially performs a "dry run" of the changes, allowing you to review what will happen before you apply them.
6. What happens if you give the wrong configuration or code in Terraform and run it?
It depends. Syntax error will fail at the plan phase, else resources will get created.
If the resource already exist in state file, no action will happen.
7. Where do you store Docker images?
Artifactories like JFrog, AWS S3.
8. Kubernetes: Describe the pod command?
$ kubectl describe pod -n namepsace
9. How do you declare context in Kubernetes?
$ kubectl config set-context - with other flags
10. What if you have more contexts and namespaces in Kubernetes?
Context are collection of parameters to access cluster and namespace.
Having more namespace does not have any technical impact other than operational issues.
11. What are the types of services in Kubernetes?
ClusterIP, NodePort and Load Balancer.
12. NodePort vs. ClusterIP — What's the difference?
Node Port -> Service get bounds to the host port. So, the traffic to K8s service is accessed via host IP and port.
Cluster IP -> Used for pod-to-pod communication within the same cluster.
13. Horizontal Pod Scaling vs. Vertical Pod Scaling — Explain?
Horizontal - Creating multiple copies of the same pod.
Vertical - Increase memory/cpu of an existing pod.
14. Limit vs. request in a Kubernetes manifest file?
Request - Soft limit of how much Memory/CPU can be assigned to a pod.
Limit - Hard limit stating cannot assign Memory/CPU beyond this limit to a pod.
15. What is AWS Lambda, and what have you done with it?
Lambda is a serverless compute. Lambda is used for various back end functionalities but cannot be used for real time processing or traffic.
Lambda is primarily used for event drive architecture.
E.g.: Restart Ec2 on a scheduled basis.
16. How do you set up CloudWatch alarms, metrics, and alerts and how do you create dashboards on CloudWatch for different resources or services on AWS?
From the console, select the Cloudwatch, create dashboard, source and select the metrics from the service.
17. Which build tool do you use for Java? How about for Python?
Jenkins, AWS CodeBuild, Spinnaker, GoCD, GitHub actions, GitLab.
18. How do you integrate Azure DevOps with AWS for deployments?
The setup involves creating AWS IAM credentials, configuring a service connection in Azure DevOps, defining a deployment pipeline, and optionally using the AWS Toolkit for Azure DevOps to simplify deployment tasks.
19. Write Terraform code for an EC2 instance with security groups using depends_on?
Creating an EC2 instance which "depends_on" the resource security group. So, security group must be created first and the security group ID is passed to EC2 provisioning.
resource "aws_instance" "web_server" {
ami = "ami-12345678"
instance_type = "t2.micro"
subnet_id = aws_subnet.main.id
security_groups = [aws_security_group.instance_sg.name]
tags = {
Name = "web-server-instance"
}
# Ensure the instance depends on the security group
depends_on = [aws_security_group.instance_sg]
}
Comments
Post a Comment