Docker And Kubernetes (UDEMY)
Git Interview Questions.
- What is the difference between
git fetchandgit pull, and when would you use each?
📝 Short explanation
This question checks your understanding of how Git handles remote updates. Many developers use git pull out of habit without realizing it combines two actions—actions that git fetch keeps separate for greater control.
✅ Answer
git fetchretrieves the latest changes from the remote repository without merging them into your current branch.git pulldoes the same asfetchbut also automatically merges the changes into your current branch.
📘 Detailed explanation
When you run git fetch, you’re asking Git to contact the remote (like GitHub) and download any changes (new commits, branches, tags) — without applying them to your working directory.
plaingit fetch origin
This is useful when you:
- want to see what others have pushed
- are preparing for a manual merge or rebase
- want to avoid surprise changes to your working branch
With git pull, you do this and merge the changes into your current branch in a single step:
plaingit pull origin main
That’s shorthand for:
plaingit fetch origin git merge origin/main
While git pull is faster, it can lead to unintended merges if you’re not ready. That’s why many teams prefer running fetch first, reviewing the changes, and then merging or rebasing manually.
Summary:
Use
git fetchwhen you want more control.Use
git pullwhen you’re ready to sync changes right away.
- What is the difference between
git forkandgit clone, and when would you use each?
git forkcreates a copy of a repository on your GitHub (or GitLab, etc.) account, letting you propose changes without write access to the original repo.git clonecreates a local copy of any Git repository (your own or someone else’s) on your machine for development.
This is especially useful for contributing to open-source and team projects where you don't have direct write access to the main repository. You fork the repo, make changes in your fork, and then create a pull request to propose those changes to the original project.
On the other hand, git clone is used to download a repository (forked or original) to your local development machine. This is what actually gives you the codebase to work with.

- What is the difference between
git rebaseandgit merge? When would you use each?

-
git mergeintegrates changes by creating a new merge commit, preserving the history of both branches. -
git rebasemoves your branch on top of another, rewriting commit history to create a linear sequence.This **re-applies your commits on top of the latest** **`main`**, like this:

Use merge when... | Use rebase when... |
|---|---|
| You're collaborating on shared branches | You're working alone or before a PR merge |
| You want to preserve commit context | You want a clean, linear history |
| History safety is a concern | You're cleaning up before pushing |
- Explain the Git branching strategy you used in your company. Align it with the open-source branching strategy followed by Kubernetes.
In my company, we followed a well-structured Git branching model similar to the Kubernetes project's workflow. Our strategy centered around four key branches:
main– the default and stable development branchfeature/*– for all new features and enhancementsrelease/*– for preparing and testing production releaseshotfix/*– for urgent bug fixes or patches to production
This helped us maintain stability while enabling parallel development and quick recovery from issues

RESOURCE TO REVISE - Interview Guides - Your Interview Questions Answered
Github Repo for all the devops scenerio based questions :
AWS Interview guide -
Course-Presentation-AWS-INTERVIEW-GUIDE.pdf
Some docker common commands
- docker pull
- docker run
- docker ps
- docker ps -a
- docker stop
- docker rm
- docker images
- docker rmi
- docker run -d <image_name> = this runs the image in detach mode, it means my terminal become free and the running task is executed in the bg.
- docker exec -it <container_id> /bin/bash —> is used to start an interactive Bash shell session inside a running Docker container. Here's a breakdown:
docker exec: Executes a command in a running container.it: Combinesi(interactive) andt(pseudo-TTY) so you can interact with the shell.- <container_id>: Replace this with the actual container ID or name.
/bin/bash: The command to run inside the container — in this case, Bash.
Example: docker exec -it my_container /bin/bash
—> This opens a shell inside my_container, letting you run commands as if you were inside a regular Linux terminal.
- To delete all Docker images from your host — including those in use by containers —
STEPS: 1. Stop and remove all containers (since images can't be deleted if containers are using them): docker stop (docker ps -a -q)
1. Remove all images: docker rmi $(docker images -q)
What these commands do:
docker ps -q: lists running container IDs.docker ps -a -q: lists all container IDs.docker images -q: lists all image IDs.docker stopanddocker rm: stop and remove all containers.docker rmi: removes all images.
- docker inspect
- docker logs
Docker Images
A docker image is a lightweight, standalone and executable package that includes everything needed to run a piece of software, including the code, runtime, libraries, environment variables, and configuration files.
- Docker images are built layer by layer. It is not like a bundled packages.
- Images are immutable.
- Also Portable.
Docker Containers
A container is a runtime instance of a docker image. It is a lightweight, standalone, and executable package that includes everything needed to run a piece of software.
- Containers works in isolation
- Two containers are separated although they derived from the same image.
Kubernetes(k8s)-
What it is:
Kubernetes is an intelligent way of running containers workloads at scale.
Kubernetes we can say is the operating system of the cloud. Kubernetes is a bunch of VMs, who are able to communicate properly with each other and to divide their workloads.
What is namespaces in kubernetes -
a namespace is a way to logically divide a cluster into multiple virtual sub-clusters, so that resources can be grouped, isolated, and managed separately.
Isolation of resources: Namespaces provide a mechanism to isolate groups of resources within a single cluster. This is useful when multiple teams or projects share the same cluster.
Commands:
kubectl config current-context = This command tells you which cluster, user, and namespace are active right now.
kubectl config get-contexts kubectl config use-context my-cluster kubectl config current-context
kubectl run nginx —image=nginx —dry-run=client -o yaml
Kubernetes Architecture -

Commands-
ReplicaController-
kubectl create -f rc-definition.yml
kubectl get relicationcontroller
kubectl get pods
ReplicaSet
kubectl create -f replicaset-definition.yml
kubectl get replicaset
kubectl get pods
kubectl delete replicaset myapp-replicaset
kubectl replace -f replicaset-definition.yml
kubectl scale -replicas=6 -f replicaset-definition.yml
kubectl describe replicaset myapp-replicaset
kubectl edit replicaset myapp-replicaset =
Running kubectl edit replicaset myapp-replicaset opens the ReplicaSet manifest in your default editor (usually vi or nano), allowing you to make live changes to the configuration.
kubectl scale replicaset myapp-replicaset —replicas=2
Deployments- It is higher in the heirerchy, it is same as replica set only difference is that it creates a deployment object.
kubectl create -f deployment-definition.yml
kubectl get deployments
kubectl get replicaset
kubectl get pods
kubectl get all
Rollout
kubectl create -f deployment-definition.yml
kubectl get deployments
kubectl apply -f deployment-definition.yml
→ A new rollout is triggered and a new revision of the deployment is created.
kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1
—> updating the image in the definition file using the cmd.
kubectl rollout status deployment/myapp-deployment
kubectl rollout history deployment/myapp-deployment
Note- Rolling update is the default deployment strategy.
kubectl rollout undo deployment/myapp-deployment
—> The deployment will then destroy the pods in the new replica set, and bring the older ones up in the old replica set, and your application is back to its older format.
Services in Kubernetes -
In Kubernetes (K8s), a Service is an abstraction that defines a stable way to access a set of Pods. Since Pods are ephemeral (they can be created, destroyed, or rescheduled), Services provide stable networking and service discovery.
Why Services Are Needed in Kubernetes
- Pods have dynamic IP addresses
- Pods can be recreated or scaled
- Directly connecting to Pods is unreliable
✅ Service solves this by:
- Providing a stable IP & DNS name
- Load-balancing traffic across Pods
- Enabling communication inside and outside the cluster
Service-NodePort
service-definition.yml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
- targetPort: 80
port: 80
nodePort: 30008
selector:
app: myapp
type: front-end
kubectl create -f service-definition.yml
kubectl get services
Service-ClusterIP
service-definition.yml
apiVersion: v1
kind: Service
metadata:
name: back-end
spec:
type: ClusterIP
ports:
- targetPort: 80
port: 80
selector:
app: myapp
type: back-end
kubectl create -f service-definition.yml
kubectl get services
Service- LoadBalancer
service-definition.yml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: LoadBalancer
ports:
- targetPort: 80
port: 80
nodePort: 30008
minikube service vote —>
-
It looks up the
voteservice in your Kubernetes cluster. -
It identifies the NodePort assigned to it (in your case,
30811).- It launches your default web browser and opens the service at a URL like:
This gives you direct access to the
voteinterface running inside your cluster.Ingress

Kubeadm -
Setup a multi node k8s cluster using kubeadm
Ports—>




karan user -
access key - AKIAUM2PQ25SFSXPH2O5
secret access key - bBwrlstEO9/E6aK8/9cQz4zWnHMKU3K2G+9TGUcd
AWS EKS Kubernetes
Helm Chart -

Helm CLI (Commands) -
helm create helloworld
helm install myhelloworldrelease helloworld
helm delete myhelloworldrelease
helm list -a
helm uninstall myhelloworldrelease
helm upgrade myhelloworldrelease helloworld
helm rollback myhelloworldrelease
helm install myhelloworldrelease —debug —dry-run helloworld = This cmd intended to simulate a Helm chart installation without actually deploying anything.
helm template helloworld = validate YAMLs without connecting to k8s api server. Also we can say it renders the chart template locally.
helm lint helloworld = Find any errors or misconfigurations.
hostname -I = use for knowing the ip address for my ubuntu machine
microk8s dashboard-proxy = it opens the k8s dashboard.
Terraform -

Main mantra for terraform syntax
<arguments>
}
cmd-
terraform init
terraform plan
terraform apply
terraform state list
terraform state show
terraform destroy
terraform destroy —target