𝗴𝗶𝘁 𝗰𝗹𝗼𝗻𝗲 <𝗿𝗲𝗽𝗼> : To work on an existing project, you’ll want to clone (copy) it to your local machine. This command does that.
𝗴𝗶𝘁 𝗰𝗵𝗲𝗰𝗸𝗼𝘂𝘁 -b <𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> : If you want to switch to a different branch, use this command.
𝗴𝗶𝘁 𝗮𝗱𝗱 <𝗳𝗶𝗹𝗲𝗻𝗮𝗺𝗲> : After you’ve made some changes to your files, you’ll want to stage them for a commit. This command adds a specific file to the stage.
𝗴𝗶𝘁 𝗮𝗱𝗱 . 𝗼𝗿 𝗴𝗶𝘁 𝗮𝗱𝗱 -𝗔 : Instead of adding files one by one, you can add all your changed files to the stage with one command.
𝗴𝗶𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 -𝗺 “𝗖𝗼𝗺𝗺𝗶𝘁 𝗺𝗲𝘀𝘀𝗮𝗴𝗲” : Now that your changes are staged, you can commit them with a descriptive message.
𝗴𝗶𝘁 𝗽𝘂𝘀𝗵 𝗼𝗿𝗶𝗴𝗶𝗻 <𝗯𝗿𝗮𝗻𝗰𝗵𝗻𝗮𝗺𝗲> : This command sends your commits to the remote repository.
Git is an extremely powerful tool with plenty more commands and options.
However, this guide gives you a good start and reference point as you continue to explore and leverage Git for your version control needs.
Curious about how Kubernetes gets things done effortlessly? 🤔 Discover the magic behind scheduling Pods in this fascinating sequence diagram! 📈
🔑 Key Takeaways:
👉📝 The user creates a Pod via the API Server ✨🖥️
📥 The API server writes it to etcd 📝🔒
🔍 The scheduler notices an “unbound” Pod and decides which node to run that Pod on 🧭🏃♀️
📝 Scheduler writes that binding back to the API Server 🖊️🔙
🔄 The Kubelet notices a change in the set of Pods that are bound to its node 🔄🔧
🐳 Kubelet, in turn, runs the container via the container runtime (i.e. Docker) 🚢🏃♂️
👀 The Kubelet monitors the status of the Pod via the container runtime 🕵️♂️💬
🔄 As things change, the Kubelet will reflect the current status back to the API Server 🔄🔄💡
🌟 Dive into the orchestration magic of Kubernetes! 🚀 Embrace the containerized journey with ease! 🎯 #KubernetesWorkflow #ContainerMagic #DevOpsTech 🌐
By using the API Server as a central coordination point, Kubernetes is able to have a set of components interact with each other in a loosely coupled manner.
Kubernetes Control Plane
API Server
The API server is a component of the Kubernetes control plane that exposes the Kubernetes API.
The API server is the front end for the Kubernetes control plane.
The main implementation of a Kubernetes API server is kube-apiserver.
kube-apiserver is designed to scale horizontally—that is, it scales by deploying more instances.
You can run several instances of kube-apiserver and balance traffic between those instances.
ETCD
Consistent and highly-available key value store.
It is used as Kubernetes’ backing store for all cluster data.
Backup and restore is a must.
Scheduler
Control plane component that watches for newly created Pods with no assigned node,
And selects a node for them to run on.
Factors taken into account for scheduling decisions include:
1.Individual and collective resource requirements,
The kubelet takes a set of PodSpecs that are provided through various mechanisms and ensures that the containers described in those PodSpecs are running and healthy.
The kubelet doesn’t manage containers which were not created by Kubernetes.
Docker
Is an open source DevOps tool designed to help developers & operations guys to streamline application development and deployment.
By dockerizing an application means deploying and running an application using containers.
Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.
Run commands mentioned in this doc to https://beginner.academy/kubernetes-shortcuts/ validate Kubernetes cluster & perform deployment verification test.
✔𝗡𝗼𝗱𝗲: A Node is a Kubernetes cluster’s worker computer. Either a physical or virtual machine may be used. The operating and management of the pods is done by the nodes.
✔𝗡𝗮𝗺𝗲𝘀𝗽𝗮𝗰𝗲: The cluster resources can be split up into virtual clusters using namespaces. It gives names a range and enables many teams or projects to share the same physical cluster while isolating their resources.
✔Deployment : simplifies the process of managing and controlling the lifecycle of applications in a Kubernetes cluster, making it easier to deploy and update applications with minimal downtime and manual intervention.
✔𝗥𝗲𝗽𝗹𝗶𝗰𝗮𝗦𝗲𝘁: ReplicaSets are Kubernetes objects that guarantee a certain number of pod replicas are always active. Scaling and managing the number of pods for a certain application are done using it.
✔Ingress: in Kubernetes is an API object that serves as an entry point for external traffic into the cluster, acting as a layer between the external world and the services running inside.
✔𝗦𝗲𝗿𝘃𝗶𝗰𝗲: A logical set of pods and a policy for accessing them are defined by a service, which is an abstraction. For the pods behind it, it offers a reliable network endpoint (IP address) and load balancing.
✔𝗣𝗼𝗱: A Pod is the smallest and most basic unit in Kubernetes. It represents a single instance of a running process or a set of tightly coupled processes running together on a node. Pods are scheduled and managed by Kubernetes.
✔Network policies: in Kubernetes are a set of rules that control the traffic flow between pods within a cluster. Network policies enhance security and provide granular control over network traffic within the cluster.
✔Persistent Volumes (PVs): Kubernetes are storage resources that provide durable and independent storage for applications. PVs enable data persistence and can be dynamically provisioned or statically allocated within the cluster.
✔Persistent Volume Claims : (PVCs) in Kubernetes are requests made by applications for storage resources. PVCs provide a convenient abstraction layer, allowing applications to request and access persistent storage without directly dealing with specific PVs.
✔Service Accounts: in Kubernetes are used to provide an identity and access control for pods within the cluster. Service Accounts facilitate secure communication and authorization between pods and the Kubernetes cluster.
✔Storage Classes : in Kubernetes are used to dynamically provision different types of storage volumes based on predefined configurations.It enable flexibility and scalability in allocating storage for applications within the cluster.
Kubernetes Shortcuts
kubectl get no
kubectl get ns
kubectl get deploy
kubectl get rs
kubectl get ing
kubectl get svc
kubectl get po
kubectl get netpol
kubectl get pv
kubectl get pvc
kubectl get sa
kubectl get sc
Beginner Academy
Resource
Shortcuts
Command
Node
no
kubectl get no
Namespace
ns
kubectl get ns
Deployment
deploy
kubectl get deploy
Replica Set
rs
kubectl get rs
Ingress
ing
kubectl get ing
Services
svc
kubectl get svc
Pod
po
kubectl get po
Network policies
netpol
kubectl get netpol
Persistent Volumes
pv
kubectl get pv
Persistent Volume Claims
pvc
kubectl get pvc
Service Accounts
sa
kubectl get sa
Storage Classes
sc
kubectl get sc
Kubernetes frequently used Commands
kubectl get: Retrieve information about resources in the cluster. kubectl get pods: List all pods. kubectl get deployments: List all deployments. kubectl get services: List all services. kubectl get nodes: List all nodes in the cluster.
kubectl get pods kubectl get deployments kubectl get services kubectl get nodes
2.kubectl describe: Provide detailed information about a specific resource. kubectl describe pod <pod-name>: Get detailed information about a pod. kubectl describe deployment <deployment-name>: Get detailed information about a deployment. kubectl describe service <service-name>: Get detailed information about a service.
kubectl describe pod <pod-name> kubectl describe deployment <deployment-name> kubectl describe service <service-name>
3.kubectl create: Create a resource from a YAML or JSON file. kubectl create -f <filename.yaml>: Create a resource from a YAML file. kubectl create deployment <deployment-name> — image=<image-name>: Create a deployment using a specified image.
4.kubectl delete: Delete a resource. kubectl delete pod <pod-name>: Delete a pod. kubectl delete deployment <deployment-name>: Delete a deployment. kubectl delete service <service-name>: Delete a service.
kubectl delete pod <pod-name> kubectl delete deployment <deployment-name> kubectl delete service <service-name>
5.kubectl scale: Scale the number of replicas in a deployment. kubectl scale deployment <deployment-name> — replicas=<number>: Scale the number of replicas for a deployment.
6.kubectl logs: Print the logs of a pod. kubectl logs <pod-name>: Print the logs of a pod.
kubectl logs <pod-name>
7.kubectl exec: Execute a command on a pod. kubectl exec -it <pod-name> — <command>: Execute a command on a pod interactively.
kubectl exec -it <pod-name> - <command>
8.kubectl apply: Apply changes to a resource defined in a YAML or JSON file. kubectl apply -f <filename.yaml>: Apply changes to a resource using a YAML file.
Ansible is an Open source IT Automation tool. Mainly used to automate configuration management activities.
If we want to install software/update patches in 1 machine then it is easy and may take 10 minutes to do this task. But think that, we need to do the same activity on 12 Machines, then it would take 2 hours of effort. If we automate the same task using ansible, we will save time and there is no scope of human error and our Infra configuration would be as code. We can modify and can reuse the same.
Using Ansible, we can automate almost all the regular IT tatsks/process.
Automate daily and repetitive tasks
Application deployments
Installation of softwares
Patching of softwares
Any configuration changes related to any Application or any softwares.
To improve security and compliance
Why Ansible is so popular?
It is an Open source, i.e. free to use
Easy to learn and automate.
It is agent less. Hence no headache of maintaining agents.
Easy to install, anyone can install and start working on ansible within short time compared to its competitors.
It has great community support, after ansible was acquired by redhat.
How to install Ansible on laptop?
Steps forMac
Run below command to install it pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py --user
Run below command to install Ansible
$ python -m pip install --user ansible
Or install Ansible using brew
brew install ansible
Steps for Linux
Below is the command to run on RHEL
sudo yum install ansible
Below is the command to run on Ubuntu
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible
Steps for Windows
As of now, Ansible cannot work natively on a Windows host. So there is no direct way to install Ansible on Windows OS. However, there are different ways to use Ansible on Windows for practice purposes.
Using Cygwin and then installing ansible
Using a Linux Virtual Machine via Virtual Box and then installing ansible.
What are all the basic commands of Ansible?
ansible localhost -m ping
This is to check if the Ansible installation is good.
This runs single command
It runs the ping command on the local host
ansible-playbook playbooks/PLAYBOOK_NAME.yml
The playbook is a list of plays, with each play performing multiple tasks.
The word “DevOps” is combination of Development + Operations , It is practice which helps both IT streams to work collaboratively rather than in silos.
Before DevOps, We had below respective responsibilities of each teams.
Development Team:- Use to build the take months together time to build application and once application is tested in their local environment, It used to handed over to operation team.
Operations Team:- Used to do deployment into test preprod and prod environment and support the application as well as the servers which has hosted these applications.
Problems faced before DevOps
There was always an issue with owning responsibility for any bugs raised in higher environments. Development team used to say this issues is not development issue and works fine in my local environment.
Operations Team is to complain, this issue wasn’t there in previous release. So debate used to happen for each release and direct impact is on the customers.
After DevOps
As part of DevOps culture, It bridges the gap between development and operations teams. This was missing before.
It brought all the teams involved in building and maintaining of application as one team
Rather than passing the ball/working in silos for any issue between these IT teams.
Each member of team came forward with mindset of “how can we help to fix this issue?”
This resulted in fixing issue in short period of time.
We release small features and make it live very frequently rather than going big bang release.
Automate as much as possible, so that there is no human errors and all the environments are identical.
Why DevOps is so popular??
Time to market is shortened.
Wherever it is possible Automation of all the tasks.Which resulted in less human errors.
Early detection of any issues in development cycle only.
Code quality checks at development stages only fixed.
DevOps creates efficiency.
Improved communication between teams.
DevOps establish a growth mindset. We will fail fast and incorporate learnings into their processes