Azure DevOps Training Notes Sept 2024
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Day 1
KIT - https://devopsschool.com/kit/master-in-devops-engineering.html
What is Docker?
=====================
Tool | platform
Container mgmt tool
Container
mgmt
create - start - stop - restart - kill - pause - unp - remove
=====================================================
run
----------------------
pull - create - start - attached
tool
Save cost
Save time
Imp Quality
What you need to run 1 APP
============================
Apache
HARDWARE
KERNAL
DISK
PROCESS
NET
USER
==============================================================
Docker Arch
Docker Client --> Docker Server --> ContainerD --> kernel
==============================
Docker Engine
Docker Workflow
https://www.devopsschool.com/blog/simple-docker-workflow-quick-start/
Container LifeCycle
create - start - stop - restart - kill - pause - unp - remove
Docker install
20.193.153.139
Docker Tutorials: How to Install Docker in Ubuntu?
rajesh
Rajesh$1234567
https://devopsschool.com/path/
Standard DevOps Phases Lifecycle
Day 2 – Ansible _ part 1
What is Ansible?
==============================
Config Mgmt
For
SERVER(S)
Whats there in SERVER
OS
HWD
App
file C R U D
dir C R U D
user A E R
group
apt I R UP
yum
cmd command/script
bash cmd/script
Release
Ansible - cmd - os - free
Ansible Tower - PAID
Ansible AWX - FREE - GUI
From Redhat
using Python
Why Ansible?
I WANT TO CHANGE 1000s of serverS parrelll
Chef - Puppet Efengine
Udeploy Octopus Deploy
How it works?
Human --->>>>>>> ACS -----> ARS
LINUX ANY
python Linux - python
windows - ps3.0 + donet
ansible NR
---------SSH ---- LINUX
-------- WINRM --- WINDOWS
Component of Ansible (ACS)
Ansible
- executables
- Modules - A code - in py - run in ARS - require param
https://docs.ansible.com/ansible/2.9/modules/modules_by_category.html
- plugins - A code - in py - run in ACS
- configfile file
Inventory
LIST OF IP ADDRESS
CMD
FILE
SCRIPT
Playbook
yaml
contains
play
Hosts: localhost | group of inventory
Tasks:
mod1 and its param
mod2 and its param
mod3 and its param
play
Hosts:
Tasks:
play
Hosts:
Tasks:
==========================================================================
Step 1 - Install Ansible DONE
https://www.devopsschool.com/blog/ansible-installation-and-configuration-guide/\
Step 2 - Ansible Adhoc Command - DONE
Step 3 - Ansible Inventory DONE
Step 4 - Ansible Playbook
Step 5 - Ansible Roles
Step 6 - Ansible Vault
ACS
==============================
20.193.137.161
ansible
GHSFGble$123456
===================================
What is your project
==================================
- Write a code which would install/config webserver in ubtunu\
Psucode
========================================
Step 1 - install apache2 in ub - apt-get install apache2 -y === apt - name=apache2 state=latest
Step 2 - copy index.html to /var/www/html copy ---- src=index.html dest:/var/www/html/index.html
Step 3 - start apache 2 services -- - systemctl start apache2 service --- name=apache2 state=started
=================================================
ansible localhost -m apt -a"name=apache2 state=latest"
ansible localhost -m copy -a"src=index.html dest:/var/www/html/index.html"
ansible localhost -m service -a"name=apache2 state=started"
=================================================
ansible all -i 20.193.137.161, -m apt -a"name=apache2 state=latest" -u ansible -k
ansible all -i 20.193.137.161, -m copy -a"src=index.html dest=/var/www/html/index.html" -u ansible -k -b
ansible all -i 20.193.137.161, -m service -a"name=apache2 state=started" -u ansible -k -b
LINUX ---- LINUX
AUTH
user - pass
user - ket
AUTH
sudo with pass
sudo without pass
sudo with another user n pass
=================================================
ansible all -i inventory -m apt -a"name=apache2 state=latest" -u ansible -k -b
ansible all -i inventory -m copy -a"src=index.html dest=/var/www/html/index.html" -u ansible -k -b
ansible all -i inventory -m service -a"name=apache2 state=started" -u ansible -k -b
Day 2 – Ansible – Part 2
Inventory
400
10.12.12.11
10.12.12.12
10.12.12.13
10.12.12.15
10.12.12.16
[web]
20.193.137.161
10.12.12.12
10.12.12.13
[db]
10.12.12.15
10.12.12.16
ansible web -i inventory -m apt -a"name=apache2 state=latest" -u ansible -k -b
- name: Install apache httpd (state=present is optional)
ansible.builtin.apt:
name: apache2
state: present
- name: Start service httpd, if not started
ansible.builtin.service:
name: apache2
state: started
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
---
- name: Update web servers
hosts: web
tasks:
- name: Install Apache in ubuntu
ansible.builtin.apt:
name: "apache2"
state: latest
- name: Copy index.html
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
- name: Starting a Apache Server
ansible.builtin.service:
name: "apache2"
state: started
\
ansible-playbook -i inventory web.yaml -u ansible -k -b
========================================================================
CODING
vars
operators\
cond
loops
functions
class
What is ROLES?
Dir structure
dir
tasks
vars
files
template
handlers
library
- name: Print return information from the previous task
ansible.builtin.debug:
var: age
- name: Print return information from the previous task
ansible.builtin.debug:
var: name
- name: Print the gateway for each host when defined
ansible.builtin.debug:
msg: System {{ name }} has gateway {{ age }}
ansible-playbook -i inventory site.yaml -u ansible -k -b
---
- name: Update web servers
hosts: web
roles:
- web
1 clear
2 cd
3 ls
4 mkdir rajesh
5 cd rajesh/
6 pwd
7 sudo apt update
8 sudo apt install software-properties-common
9 sudo add-apt-repository --yes --update ppa:ansible/ansible
10 sudo apt install ansible
11 ansible
12 ansible version
13 ansible --version
14 ls /usr/bin/ansi*
15 ansible
16 clear
17 ansible localhost -m apt -a"name=apache2 state=latest"
18 ansible localhost -m copy -a"src=index.html dest:/var/www/html/index.html"
19 vi index.html
20 ansible localhost -m copy -a"src=index.html dest:/var/www/html/index.html"
21 ansible localhost -m copy -a"src=index.html dest=\/var/www/html/index.html"
22 ansible localhost -m copy -a"src=index.html dest=/var/www/html/index.html"
23 ls /var/www/html/index.html"
24 ls /var/www/html/index.html
25 ansible localhost -m service -a"name=apache2 state=started"
26 ansible all -i 20.193.137.161, -m apt -a"name=apache2 state=latest"
27 ansible all -i 20.193.137.161, -m apt -a"name=apache2 state=latest" -u ansible -k
28 ansible all -i 20.193.137.161, -m apt -a"name=apache2 state=latest" -u ansible -k -b
29 ansible
30 ansible all -i 20.193.137.161, -m copy -a"src=index.html dest:/var/www/html/index.html" -u ansible -k -b
31 ansible all -i 20.193.137.161, -m copy -a"src=index.html dest=/var/www/html/index.html" -u ansible -k -b
32 clear
33 vi inventory
34 clear
35 ansible all -i inventory -m apt -a"name=apache2 state=latest" -u ansible -k -b
36 more /etc/ansible/ansible.cfg | grep fork
37 more /etc/ansible/ansible.cfg\
38 more /etc/ansible/ansible.cfg
39 clear
40 ls
41 vi inventory
42 ansible web -i inventory -m apt -a"name=apache2 state=latest" -u ansible -k -b
43 clear
44 ls
45 vi web.yaml
46 ansible-playbook -i inventory web.yaml -u ansible -k -b
47 vi web.yaml
48 ansible-playbook -i inventory web.yaml -u ansible -k -b
49 ansible-playbook -i inventory web.yaml -u ansible -k -b --v
50 ansible-playbook -i inventory web.yaml -vvv -u ansible -k -b
51 clear
52 ;ls
53 clear
54 l;s
55 clear
56 ls
57 ansible-galaxy role init
58 ansible-galaxy role -h
59 ansible-galaxy role init web
60 clear
61 ls
62 tree
63 apt-get install tree -y
64 clear
65 tree
66 clear
67 ls
68 more web.yaml
69 vi web/tasks/main.yml
70 vi web/vars/main.yml
71 vi web/tasks/main.yml
72 ls
73 cp index.html web/files/
74 tree
75 vi site.yaml
76 ls
77 clear
78 ls
79 rm -rf index.html web.yaml
80 ls
81 ansible-playbook -i inventory site.yaml -u ansible -k -b
82 history
83 ansible-galaxy role install geerlingguy.java
84 java\
85 java
86 vi site.yaml
87 ansible-galaxy role install geerlingguy.java
88 ansible-playbook -i inventory site.yaml -u ansible -k -b
89 java
90 clear
91 vi inventory
92 cleaer
93 clear
94 ls
95 ansible-vault
96 ansible-vault encrypt inventory
97 cleare
98 clear
99 ls
100 more inventory
101 ansible -h
102 ansible-playbook -i inventory site.yaml -b
103 ansible-playbook -i inventory site.yaml -b -J
104 history
Day 2 – Kubernetes – Part – 1
Master
- Api server -> POD -> Container -> Docker - Contd-> Image -> Google Registry
- etcd -> POD -> Container -> Docker - Contd-> Image -> Google Registry
- schedular -> POD -> Container -> Docker - Contd-> Image -> Google Registry
- controller mgr -> POD -> Container -> Docker - Contd-> Image -> Google Registry
- kubelet
- Docker - containerd
- proxy -> POD -> Container -> Docker - Contd-> Image -> Google Registry
Worker
- kubelet
- Docker - containerd
- proxy -> POD -> Container -> Docker - Contd-> Image -> Google Registry
Workstation
- kubectl ---> configfile
APi Server add
Cred
13.71.91.52
kubernetes
QSc#123456ddsd
https://www.devopsschool.com/blog/kubernetes-1-23-6-cluster-setup-master-and-worker-in-ubuntu-20-04/
https://stackoverflow.com/questions/43147941/allow-scheduling-of-pods-on-kubernetes-master
kubectl taint node k81 node-role.kubernetes.io/master:NoSchedule-
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
node-role.kubernetes.io/control-plane
==================================================
API = ONE Service
CREATE - READ - UP - DELETE
GET PUT POST DELETE
CREATE
CMD create
YAML create -f yaml
READ
CMD get
YAML get -f yaml
UPDATE
CMD edit
YAML apply -f yaml
DELETE
CMD delete
YAML delete -f yaml
20 kubectl describe k81
21 kubectl describe node k81
22 clear
23 ls
24 kubectl get pods --all-namespaces
25 kubectl version
26 kubectl\
27 kubectl
28 clear
29 kubectl api-resources
30 cleaer
31 clear
32 kubectl get ns
33 kubectl get pods -n=kube-system
34 cleasr
35 clear
36 kubectl
37 clear
38 kubectl get ns
39 kubectl create ns rajesh
40 kubectl get ns
41 kubectl edit ns rajesh
42 kubectl get ns
43 kubectl describe ns rajesh
44 kubectl delete ns rajesh
45 kubectl get ns
Day 2 – Kubernetes – Part – 3
POD
https://www.devopsschool.com/blog/kubernetes-pod-example-programs/
apiVersion: v1
kind: Pod
metadata:
name: rajesh
labels:
app: helloworld
spec:
containers:
- name: devopsschool1
image: scmgalaxy/nginx-devopsschoolv1
ports:
- name: nginx-port
containerPort: 80
47 clear
48 kubectl explain pod
49 kubectl explain pod.spec
50 kubectl explain pod.spec.containers
51 clear
52 ls
53 vi pod.yaml
54 kubectl create -f pod.yaml -n=rajesh
55 kubectl create ns rajesh
56 kubectl create -f pod.yaml -n=rajesh
57 kubectl get pods
58 kubectl get pods -n=rajesh
59 kubectl describe pod rajesh
60 kubectl describe pod rajesh -n=rajesh
61 clear
62 ls
63 clear
64 ls
65 vi pod.yaml
66 kubectl apply -f pod.yaml -nrajesh
67 kubectl delete -f pod.yaml -n=rajesh
68 kubectl get pods
69 kubectl get pods -n=rajesh
70 kubectl apply -f pod.yaml -nrajesh
71 kubectl get pods -n=rajesh
72 kubectl get pods -n=rajesh -o wide
73 curl http://192.168.0.6
74 kubectl exec -it rajesh /bin/bash
75 kubectl exec -it rajesh /bin/bash -n=rajesh
76 clear
77 kubectl logs rajesh -n=rajesh
78 curl http://192.168.0.6
79 kubectl logs rajesh -n=rajesh
80 kubectl
Day 3 Terraform
Terraform
Azure Pipeline
==========================
What is terraform?
--------------------------
IAAC
Coding for infra
Infra
Azure
AWS
GC
VMware
https://registry.terraform.io/browse/providers
in GO
by Hashipcorp
Community --- CMD ----> FREE
Enterprise --- GUI - PAID
PRIVATE
CLOUD
Others
ARM - > Azure
CF --?> AWS
GT -- GC
=========================================================
Why TF
------------
CODING FOR EVERYTHING
How TF works? Aka TF Arch?
====================================
Step 1- Install TF
https://developer.hashicorp.com/terraform/install
Step 2 - Download providers
Using Code
Filename - anyname.tf
--------------------
FOLDER
----------------------------------
one.tf 2.tf 3.tf
Terraform Tutorials: Basic Workflow Getting Started Guide
Step 3 - Write a code
--------------------------------
VM
Resource eg vm
param | attributes
image
disk
gr
.tf
resource1 vm
att1
att2
resource2
att1
att2
resource3 net
att1
att2
resource4
att1
att2
resource5
att1
att2
Azure Tutorials – How to create IAM user and assign Service Principal Access?
variable "prefix" {
default = "rajtf"
}
resource "azurerm_resource_group" "example" {
name = "${var.prefix}-resources"
location = "Central India"
}
resource "azurerm_virtual_network" "main" {
name = "${var.prefix}-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "main" {
name = "${var.prefix}-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_virtual_machine" "main" {
name = "${var.prefix}-vm"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_B1s"
# Uncomment this line to delete the OS disk automatically when deleting the VM
# delete_os_disk_on_termination = true
# Uncomment this line to delete the data disks automatically when deleting the VM
# delete_data_disks_on_termination = true
storage_image_reference {
publisher = "canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
storage_os_disk {
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
environment = "staging-raj"
}
}
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.3.0"
}
}
}
provider "azurerm" {
# Configuration options
features {}
client_id = "d4c19e56-d307-4536-b612-a93e117bbe68"
client_secret = ""
tenant_id = "49c4f74e-d704-424f-a964-32e76cc3ae50"
subscription_id = "a112b874-8fea-4cdd-86ee-9b2cc8a59a7b"
}
https://www.devopsschool.com/blog/?s=terraform
Day 4
Web Tutorials
https://www.devopsschool.com/blog/
Slides
https://www.devopsschool.com/slide/
https://www.devopsschool.com/slides
Videos
https://www.devopsschool.com/blog/top-4-youtube-channel-for-free-videos-tutorials/
https://www.devopsschool.com/videos/
https://www.xopsschool.com/
Sample Program
https://www.devopsschool.com/blog/list-of-popular-projects-at-github-for-sample-lab-and-exercise/
https://www.devopsschool.com/blog/devopsschool-github-referenece/
Rajesh
https://www.rajeshkumar.xyz/