Devops L2 Q&A
SET – 1 1. What is DevOps, and why is it important? DevOps is a set of practices that combines software development (Dev) and IT operations (Ops). It aims to shorten the software development life cycle and provide continuous delivery with high software quality. 2. Can you explain the CI/CD pipeline and its components? CI (Continuous Integration) is a practice where developers frequently merge code into a shared repository. CD (Continuous Deployment) automates the deployment of new changes. Key components are: Source Control: Git, SVN Build Automation: Jenkins, CircleCI Test Automation: Selenium, JUnit Deployment Automation: Ansible, Kubernetes 3. What is Infrastructure as Code (IaC), and why is it used in DevOps? IaC refers to managing infrastructure through code, allowing teams to automate the provisioning and configuration of environments. Tools include Terraform, AWS CloudFormation, and Ansible. 4. What is the difference between Ansible, Puppet, and Chef? All three are configuration management tools. Ansible uses an agentless architecture and is simpler to set up, Puppet uses a master-agent architecture, and Chef is built around Ruby and offers a powerful DSL for defining infrastructure. 5. How do you implement blue-green deployment? Blue-green deployment minimizes downtime and reduces risks by running two identical production environments (blue and green). Traffic is routed to the green environment after validation, while blue remains as a backup. 6. Explain how you would set up a monitoring and alerting system for production? Use tools like Prometheus and Grafana for monitoring. Set up alerting rules based on thresholds (e.g., CPU usage, memory, response times) and integrate with services like PagerDuty or Slack for real-time alerts. 7. What is a Dockerfile? Can you walk through a basic Dockerfile? A Dockerfile is a script that contains instructions to build a Docker image. Basic Dockerfile example: Dockerfile FROM node:14 WORKDIR /app RUN npm install CMD [“npm”, “start”] 8. How do you ensure security in DevOps? Security can be implemented using the following: Static code analysis: Tools like SonarQube Secret management: Vault, AWS Secrets Manager Compliance checks: Using tools like OpenSCAP or Chef Inspec 9. Can you explain Git branching strategies? Feature Branching: Separate branches for features Gitflow: Structured flow with master, develop, and feature branches Trunk-Based Development: Minimal branches, merging frequently into trunk 10. How do you handle configuration management in a microservices architecture? Centralized configuration management tools like Spring Cloud Config or Consul can be used to manage configuration files for all services in one place. SET – 2 1. What is container orchestration, and why is Kubernetes popular? Container orchestration automates the deployment, scaling, and management of containerized applications. Kubernetes is popular due to its powerful features like automated scaling, self-healing, and service discovery. 2. What are namespaces in Kubernetes, and why are they used? Namespaces provide a way to segment a Kubernetes cluster into virtual clusters. They help in organizing and isolating resources between teams or environments. 3. How do you optimize a CI/CD pipeline for faster deployments? Parallelizing tasks Caching dependencies Using lightweight containers Limiting unnecessary test runs 4. What’s the difference between containers and virtual machines (VMs)? Containers share the host OS and are more lightweight, while VMs run their own OS and are more resource-intensive. 5. What is a reverse proxy, and why is it used in a DevOps setup? A reverse proxy forwards client requests to backend servers, improving security, performance, and load balancing. Nginx and HAProxy are popular reverse proxy servers. 6. What is Helm in Kubernetes? Helm is a package manager for Kubernetes that allows you to define, install, and upgrade even the most complex Kubernetes applications. 7. What is the use of service mesh in microservices? A service mesh manages communication between microservices. Istio and Linkerd are popular tools that provide observability, traffic management, and security features. 8. What is the difference between Continuous Delivery and Continuous Deployment? Continuous Delivery ensures code is always in a deployable state, while Continuous Deployment automates the release process to production. 9. What are some common challenges with microservices? Common challenges include: Complex inter-service communication Distributed data management Monitoring and logging across services 10. How do you handle secrets in a CI/CD pipeline? Use secret management tools like HashiCorp Vault, AWS Secrets Manager, or environment variables encrypted with tools like Jenkins Credentials Plugin. SET – 3 1. What is canary deployment, and when would you use it? Canary deployment releases a new version of an application to a small subset of users. It’s useful when testing a new feature or mitigating risk during production deployments. 2. Explain the concept of “shift left” in DevOps. “Shift left” means moving testing, security, and performance evaluation earlier in the software development lifecycle to identify issues sooner. 3. What’s the difference between stateful and stateless applications? Stateless applications do not retain any data between requests, while stateful applications store data across multiple sessions or requests. 4. How do you implement High Aailability (HA) in your infrastructure? Use techniques like load balancing, auto-scaling, database replication, and multi- region deployments to ensure high availability. 5. What is a deployment strategy you would use for zero downtime? Blue-green deployment or rolling updates with Kubernetes ensure zero downtime during deployments. 6. What are Kubernetes pods, and how do they differ from containers? A pod is the smallest deployable unit in Kubernetes, which can contain one or more containers that share storage and network resources. 7. Explain how you would secure a Kubernetes cluster. Use Role-Based Access Control (RBAC) Enable mutual TLS for service communication Use network policies to control traffic between pods 8. What are Jenkins pipelines? Jenkins pipelines define a series of steps to automate the CI/CD process using code (Pipeline as Code). It supports complex workflows and parallel task execution. 9. How do you handle rollbacks in case of a failed deployment? Tools like Kubernetes and Helm have built-in rollback features. Additionally, using feature flags or storing previous versions of