0% found this document useful (0 votes)
8 views4 pages

devops interview

The document provides detailed responses to 12 technical questions related to Docker, Jenkins, Git, Kubernetes, and system monitoring. Key topics include creating a Dockerfile, writing a shell script for resource monitoring, understanding Jenkins pipelines, and explaining Kubernetes components like ReplicaSet and Ingress Controller. It also covers Git commands and the difference between file redirection methods.

Uploaded by

poojanandish1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

devops interview

The document provides detailed responses to 12 technical questions related to Docker, Jenkins, Git, Kubernetes, and system monitoring. Key topics include creating a Dockerfile, writing a shell script for resource monitoring, understanding Jenkins pipelines, and explaining Kubernetes components like ReplicaSet and Ingress Controller. It also covers Git commands and the difference between file redirection methods.

Uploaded by

poojanandish1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Here's a detailed response to each of your 12 questions:

1. Dockerfile to install Python and copy a.py:


dockerfileCopyEditFROM ubuntu:20.04

RUN apt-get update && \


apt-get install -y python3 python3-pip

COPY a.py /app/a.py

WORKDIR /app

CMD ["python3", "a.py"]

2. Shell script to monitor CPU & Memory and send email:


bashCopyEdit#!/bin/bash

THRESHOLD=80
EMAIL="your_email@example.com"

CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}')


MEM=$(free | awk '/Mem/{printf("%.2f"), $3/$2 * 100.0}')

if (( ${CPU%.*} > THRESHOLD )) || (( ${MEM%.*} > THRESHOLD )); then


echo -e "High resource usage detected!\nCPU: $CPU%\nMemory: $MEM%"
| mail -s "Alert: High CPU/Memory Usage" "$EMAIL"
fi

You may need mailutils package for email to work.

3. How to build a Docker image:


bashCopyEditdocker build -t my-python-app .

4. Explain Jenkins Pipeline:


A Jenkins pipeline is a set of instructions written in a Jenkinsfile to
automate build, test, and deployment steps. Pipelines can be:
 Declarative: Structured format, easier to understand.

 Scripted: More flexible, written in Groovy.

Example (Declarative):
groovyCopyEditpipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}

5. When to use Git cherry-pick:


Use git cherry-pick when you want to apply a specific commit from one
branch into another without merging the whole branch.
bashCopyEditgit cherry-pick <commit_hash>

6. Difference between append and redirect:


 Redirect (>): Overwrites file content.

 Append (>>): Adds to the end of the file.

Example:
bashCopyEditecho "Hello" > file.txt # Overwrites
echo "World" >> file.txt # Appends
7. Skip failed build and continue in Jenkins:
Use catchError, try-catch, or unstable status.

groovyCopyEditstage('Optional Step') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh './fail-prone-script.sh'
}
}
}

8. Git architecture and commands:


Git has a working directory, staging area, and local repository.
 git add: Stage changes

 git commit: Commit to local repo

 git push: Push to remote

 git pull: Fetch & merge

 git fetch: Fetch only

 git status, git log, git diff: Inspect

9. What is ReplicaSet in K8s:


A ReplicaSet ensures a specified number of pod replicas are running at any
given time.
yamlCopyEditapiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-replicaset
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: mycontainer
image: nginx

10. What is ETCD:


 Distributed key-value store used by Kubernetes to store all cluster
state (pods, nodes, secrets, etc.)

 Highly consistent and reliable.

11. Services in Kubernetes:


K8s Service exposes pods as a network service. Types:
 ClusterIP (default): Internal access only

 NodePort: Exposes service on each Node’s IP at a static port

 LoadBalancer: Exposes externally via cloud LB

 Headless (ClusterIP: None): For direct pod access

12. Ingress Controller:


Ingress controller is a K8s component that manages external access to
services (HTTP/HTTPS). It uses ingress resources to define routes.
 Example: Nginx Ingress Controller

 Controls path-based or host-based routing.

Would you like me to compile this set into a downloadable PDF as well?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy