├── Ansible ├── Ansible_Installation_Configs_Practise.txt └── Class_Notes.txt ├── DevOps_Intro └── Class_Notes.txt ├── DevOps_On_Cloud_ClassNotes.txt ├── Docker └── Class_Notes.txt ├── GIT └── Class_Notes.txt ├── Jenkins ├── Class_Notes.txt └── Jenkins_Installation_Configuration.txt ├── Kubernetes ├── Class_Notes.txt ├── Hostpath_Volume.txt ├── Kubernetes_Installation_Config.txt ├── kube_deploy.txt └── pods.txt ├── Linux └── class_notes.txt ├── Maven_Build_Tool └── Class_Notes.txt ├── Module-1-AWS └── class_notes.txt ├── Monitoring ├── Class_Notes.txt └── Promethes_Grafana_Setup.txt ├── Project └── Class_Notes.txt ├── Python ├── Class_Notes.txt └── Python Programming Excercise.pdf ├── README.md ├── Terraform ├── Class_Notes.txt └── Terraform_Scripts.txt └── dummy /Ansible/Ansible_Installation_Configs_Practise.txt: -------------------------------------------------------------------------------- 1 | Ansible Installation & Configurations: 2 | 3 | Launch - Ubuntu - v22.04 | 3 EC2 Instances... 1 for Ansible Controller & 2 as Nodes - ubuntu v22.04 4 | 5 | SSH connections ::: 6 | 7 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 | #Login to Ansible Node1 & Node2. Perform below activities: 9 | 10 | #Add User in Ansible Nodes : 11 | 12 | sudo -i 13 | 14 | apt update -y 15 | 16 | useradd ansibleadmin -s /bin/bash -m -d /home/ansibleadmin 17 | 18 | passwd ansibleadmin 19 | 20 | #Enter New Password: 21 | #Confirm Password: 22 | 23 | #Goto: 24 | 25 | vi /etc/ssh/sshd_config 26 | 27 | #Enable Password Authentication to Yes and save the file 28 | #Execute Below command to update the changes. 29 | 30 | service ssh reload 31 | 32 | #As a root user edit below file: 33 | 34 | $ visudo 35 | 36 | #add the below mentioned line in the file and save it. 37 | 38 | ansibleadmin ALL=(ALL) NOPASSWD: ALL 39 | 40 | su - ansibleadmin 41 | 42 | ls -a 43 | 44 | 45 | 46 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47 | 48 | #Login to Ansible Controller: 49 | https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html 50 | 51 | https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html#installing-ansible-on-ubuntu 52 | 53 | sudo -i 54 | 55 | sudo apt update -y 56 | 57 | sudo apt install software-properties-common -y 58 | sudo add-apt-repository --yes --update ppa:ansible/ansible 59 | sudo apt update -y 60 | sudo apt install ansible -y 61 | 62 | ansible --version 63 | 64 | #go to /etc/ansible 65 | 66 | #host - Default inventory file 67 | #config 68 | #roles 69 | 70 | #Add User in Ansible Controller : 71 | 72 | useradd devopsadmin -s /bin/bash -m -d /home/devopsadmin 73 | 74 | #useradd devopsadmin 75 | 76 | su - devopsadmin 77 | 78 | #ssh-keygen -t rsa -b 1024 -m PEM 79 | 80 | #ssh-keygen -R rsa -b 1024 -m PEM 81 | ssh-keygen -t ecdsa -b 521 #ubuntu 22.04 or higher version of ubuntu 82 | 83 | ls ~/.ssh 84 | 85 | #You should see following two files: 86 | 87 | #id_ecdsa - private key 88 | #id_ecdsa.pub - public 89 | 90 | 91 | #Goto Node1&2, within ansibleadmin home directory, create .ssh directory 92 | 93 | vi authorized_keys 94 | 95 | #paste the id_ecdsa.pub of devopsadmin user from controller machine to authorized_keys file in Ansible Node1 96 | 97 | chmod 600 /home/ansibleadmin/.ssh/* 98 | 99 | 100 | # Use the private IP addr. of AN1 and AN2 101 | 102 | ssh ansibleadmin@172.31.34.144 103 | ssh ansibleadmin@172.31.45.232 104 | 105 | chown -R devopsadmin:devopsadmin /etc/ansible 106 | 107 | #chmod 600 /home/ansibleadmin/.ssh/* 108 | 109 | 110 | ###update vi etc/ansible/hosts 111 | 112 | 113 | [testnodes] 114 | samplenode1 ansible_ssh_host=172.31.34.144 ansible_ssh_user=ansibleadmin 115 | samplenode2 ansible_ssh_host=172.31.45.232 ansible_ssh_user=ansibleadmin 116 | 117 | 118 | Eg.::: 119 | 120 | samplenode3 ansible_ssh_host=172.31.38.135 ansible_ssh_user=ansibleadmin 121 | samplenode4 ansible_ssh_host=172.31.38.39 ansible_ssh_user=ansibleadmin 122 | 123 | [devnodes] 124 | devnode1 ansible_ssh_host=172.31.5.190 ansible_ssh_user=ansibleadmin 125 | devnode2 ansible_ssh_host=172.31.6.228 ansible_ssh_user=ansibleadmin 126 | 127 | 128 | [webappservers] 129 | webappserver1 ansible_ssh_host=172.31.9.49 ansible_ssh_user=ansibleadmin 130 | webappserver2 ansible_ssh_host=172.31.9.209 ansible_ssh_user=ansibleadmin 131 | webappserver3 ansible_ssh_host=172.31.9.209 ansible_ssh_user=ansibleadmin 132 | 133 | 134 | 135 | #************************************************************************************************************************** 136 | #hosts file is the default Inventory file for ansible 137 | #************************************************************************************************************************** 138 | #Access thru Ansible Controller : 139 | #************************************************************************************************************************** 140 | 141 | ansible -m -i 142 | 143 | ansible testnodes -m ping 144 | 145 | ansible devnodes -m ping 146 | 147 | 148 | ansible dev_server_grp1 -m ping -i dev_servers 149 | 150 | #host machines can be identified using : 151 | #all | group_name | individual_host_name 152 | 153 | 154 | ###update vi /etc/ansible/host 155 | 156 | [testnodes] 157 | samplenode1 ansible_ssh_host=172.31.41.32 ansible_ssh_user=ansibleadmin 158 | samplenode2 ansible_ssh_host=172.31.39.17 ansible_ssh_user=ansibleadmin 159 | 160 | ################################################################################## 161 | 162 | #************************************************************************************************************************** 163 | #Access thru Ansible Controller : 164 | #************************************************************************************************************************** 165 | Ansible Modules: Eg.: 166 | ansible testnodes -m ping 167 | 168 | ansible all -m ping ### will ping all hosts from /etc/ansible/hosts file 169 | 170 | ansible samplenode1 -m ping 171 | ansible samplenode2 -m ping 172 | 173 | #or using user defined Inventory file 174 | #ansible ansible-node1 -m ping -i myinventoryfile.txt 175 | 176 | 177 | ansible samplenode1 -m ping -i myinventoryfile.txt 178 | 179 | #************************************************************************************************************************** 180 | 181 | ansible samplenode2 -m ping 182 | 183 | ansible samplenode1 -m shell -a "sleep 5 ; echo 'hi'" 184 | 185 | 186 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187 | Ansible Facts! 188 | 189 | ansible samplenode1 -m setup 190 | ansible samplenode1 -m setup -a "filter=ansible_mounts" 191 | 192 | 193 | ansible testnodes -m setup -a "filter=ansible_distribution" 194 | 195 | 196 | ##Transfer a file from Ansible Controller to Target Nodes using copy Module 197 | 198 | ansible samplenode1 -m copy -a "src=/etc/ansible/file1.txt dest=/home/ansibleadmin" 199 | 200 | ansible samplenode1 -m copy -a "src=/etc/ansible/s1.txt dest=/home/ansibleadmin backup=yes" 201 | 202 | 203 | 204 | ##Transfer a file from Ansible Nodes to Ansible Controller using fetch Module 205 | ansible samplenode1 -m fetch -a "src=/home/ansibleadmin/filefrom_AN1.txt dest=/home/devopsadmin" 206 | 207 | 208 | ### List all modules: 209 | ansible-doc -l 210 | ### No. of modules: 211 | ansible-doc -l | wc -l 212 | ### Search for specific modules: 213 | ansible-doc -l | grep shel 214 | ### To know about any specific modules: 215 | ansible-doc shell 216 | 217 | 218 | https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html 219 | 220 | 221 | 222 | 223 | Ansible Playbooks ::: 224 | 225 | *.yaml scripts ==> Key-value pair 226 | 227 | - Playbook creation 228 | 229 | 230 | 231 | Playbooks ::::: 232 | 233 | - *.yaml Script 234 | - Defines the Tasks/Modules to be executed in target nodes. 235 | - Reusability 236 | 237 | 238 | Build Server ::: 239 | 240 | - install jdk 241 | - install git 242 | - install maven 243 | 244 | 245 | #************************************************************************************************************************** 246 | #Ansible Variables ! 247 | #shell : echo $var1 248 | 249 | in yaml : "{{var1}}" 250 | 251 | 252 | ansible samplenode1 -m setup 253 | 254 | debug - 255 | msg - used to print the constant value and variable data 256 | var - used to print only the variable data 257 | 258 | key:Value pair 259 | 260 | #debugmod.yaml / *.yml 261 | 262 | --- 263 | - hosts: testnodes 264 | tasks: 265 | - debug: 266 | msg: 267 | - "The os distribution is: {{ansible_distribution}}" 268 | - "THe os name is: {{ansible_system}}" 269 | - "The os family is: {{ansible_os_family}}" 270 | 271 | 272 | Execute ::: 273 | 274 | ansible-playbook debugmod.yaml 275 | 276 | 277 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 278 | #~~~~~~~~~~~~~~~~~~~~~~~~~ test_var-datatype.yaml 279 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 280 | #test_var-datatype.yaml 281 | --- 282 | - hosts: samplenode1 283 | vars: 284 | x: 23 285 | my_num: 45.67 286 | my_name: Loksai 287 | my_b: YES 288 | tasks: 289 | - debug: 290 | msg: 291 | - "The value of x is: {{x}}" 292 | - "THe value of my_num: {{my_num}}" 293 | - "The value of my_name : {{my_name}}" 294 | - "THe value of my_b is: {{my_b}}" 295 | 296 | 297 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 | #/etc/ansible/variables/myvarfile1.yaml 299 | x: 26 300 | my_num: 45.00067 301 | my_name: Loksai_ETA 302 | my_b: YES 303 | 304 | #test_var-datatype1.yaml 305 | --- 306 | - hosts: samplenode1 307 | vars_files: 308 | - /etc/ansible/variables/myvarfile1.yaml 309 | tasks: 310 | - debug: 311 | msg: 312 | - "The value of x is: {{x}}" 313 | - "THe value of my_num: {{my_num}}" 314 | - "The value of my_name : {{my_name}}" 315 | - "THe value of my_b is: {{my_b}}" 316 | 317 | 318 | 319 | --- 320 | - hosts: testnodes 321 | become: yes 322 | tasks: 323 | - name: Manage nginx tool 324 | apt: 325 | name: nginx 326 | state: present 327 | 328 | 329 | ####################################### 330 | #sudo apt install git 331 | 332 | #sudo yum install git 333 | 334 | apt: 335 | name : 336 | state: 337 | 338 | state: present / absent / latest 339 | 340 | 341 | Package Management : 342 | 343 | install/Uninstall/update 344 | ######################################## 345 | 346 | 347 | #var3.yaml 348 | --- 349 | - hosts: "{{ host_name }}" 350 | become: yes 351 | tasks: 352 | - name: Manage "{{ tool_name }}" service 353 | apt: 354 | name: "{{ tool_name }}" 355 | state: "{{ tool_state }}" 356 | 357 | ansible-playbook var3.yaml -e "host_name=testnodes tool_name=nginx tool_state=absent" 358 | 359 | 360 | ################################################################################ 361 | 362 | Handling Variables ::: 363 | 364 | --> Hardcoding the variables --> vars: 365 | --> Using Variables files --> vars_files: #recommended approach 366 | --> Passing Extra values --> -e 367 | 368 | Handling Variables in Ansible ::: 369 | 370 | - Environment variables -- accessible using Setup Module. 371 | 372 | - Hardcoding the values in playbook 373 | using vars : 374 | 375 | - Using External Variable files : 376 | using var_files 377 | 378 | - Using -e to pass the values at run time. 379 | 380 | ################################################################################# 381 | ## Using When Condition ::: 382 | 383 | 384 | --- 385 | - hosts: "{{ host_name }}" 386 | become: yes 387 | tasks: 388 | - name: Manage "{{ tool_name }}" on Debian 389 | apt: 390 | name: "{{ tool_name }}" 391 | state: "{{pkg_state}}" 392 | when: ansible_os_family == "Debian" 393 | - name: Manage "{{ tool_name }}" on Redhat 394 | yum: 395 | name: "{{ tool_name }}" 396 | state: "{{pkg_state}}" 397 | when: ansible_os_family == "RedHat" 398 | 399 | ansible-playbook var3.yaml -e "host_name=samplenode1 tool_name=maven pkg_state=present" 400 | 401 | ############################################################################################## 402 | 403 | 404 | 405 | 406 | Loops : 407 | 408 | --- 409 | - hosts: samplenode1 410 | become: yes 411 | tasks: 412 | - apt: 413 | name: git 414 | state: present 415 | - apt: 416 | name: maven 417 | state: present 418 | - apt: 419 | name: nginx 420 | state: present 421 | 422 | 423 | 424 | 425 | Loops ::: 426 | 427 | --- 428 | - hosts: samplenode1 429 | gather_facts: false 430 | become: yes 431 | tasks: 432 | - apt: 433 | name: "{{item}}" 434 | state: absent 435 | loop: 436 | - git 437 | - maven 438 | - nginx 439 | 440 | ################################################################################## 441 | Handlers --> are used to control the flow of playbook execution, based on the previous modules 442 | This can be done thru notify key. 443 | 444 | Handlers are same as tasks. 445 | But, it gets executed only if we notify. 446 | 447 | 448 | 449 | Handlers ::: 450 | 451 | Handlers are used to control the flow of execution of tasks. 452 | 453 | Tasks 1 ::: 454 | 455 | QA_Server 456 | 457 | Tomcat ::: 458 | 459 | 1. Install the Pre-requisites # jdk # jdk 460 | 2. Install the actual tool # tomcat # jenkins 461 | 3. Configure/setup the tool # start tomcat # unlock jenkins and setup 462 | 463 | 464 | 465 | ################################################################################################# 466 | 467 | Ansible Roles ::: 468 | 469 | Are used to organize the Ansible Components 470 | 471 | for Reusability 472 | 473 | Use git remote repositories to maintain the Ansible Roles. 474 | 475 | variable/handlers/defaults/secrets/tasks 476 | 477 | Playbooks 478 | 479 | 480 | Roles can be created using ::: 481 | 482 | - ansible-galaxy init testrole1 483 | 484 | 485 | Working with Handlers using Ansible Roles ::: 486 | 487 | 488 | ansible-galaxy init testrole1 489 | 490 | --- 491 | # tasks file for testrole1 492 | - name: Install-nginx 493 | apt: 494 | name: nginx 495 | state: present 496 | notify: 497 | - start-nginx 498 | 499 | 500 | --- 501 | # handlers file for testrole1 502 | - name: start-nginx 503 | service: 504 | name: nginx 505 | state: started 506 | 507 | 508 | --- 509 | - hosts: samplenode1 510 | become: yes 511 | roles: 512 | - role: testrole1 513 | 514 | 515 | --- 516 | - hosts: {{host_name}} 517 | become: yes 518 | roles: 519 | - role: {{role_name}} 520 | -------------------------------------------------------------------------------- /Ansible/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ####################### 3 | Day 41: 30th Sep. 2024 4 | ####################### 5 | 6 | Configuration Management System using Ansible :::: 7 | 8 | Terrafrom : 9 | 10 | 11 | IAC - Infra-Structure As Code 12 | 13 | Infra-Structure 14 | 15 | Infra-Structure Provisioning - Process of creating servers - Terraform 16 | 17 | Infra-Structure Configurations - Process of managing the servers - Ansible 18 | 19 | Configuration Management System using Ansible ::: 20 | 21 | - Install / Uninstall / Upgrade any Packages 22 | 23 | Configure 20 Test Servers : 24 | 25 | 20 Developers Joined the Team : 26 | 27 | - Provision/Create the dev environment 28 | 29 | - Install the required development tools 30 | 31 | 32 | Working with Ansible : 33 | 34 | - Why we need Ansible ? 35 | 36 | - Ansible Architecture 37 | - Master & Client Architecture: 38 | 39 | - Ansible Components 40 | 41 | - Ansible Controller 42 | - Install Ansible 43 | - Maintain the Ansible Modules and Inventory file 44 | 45 | - Ansible Nodes : 46 | - Target Machines/Clients that can be configured through Ansible Controller 47 | 48 | Inventory file : 49 | - Used to define the Ansible Nodes details 50 | - Host Name, User Name and Credentials - SSH Keys / Password 51 | 52 | Ansible Modules : 53 | - It is a script or function that gets injected into the target machine. 54 | - These Modules are based of Python Scripts 55 | - Ansible Inject/push the modules from the Ansible Controller Machine into the Ansible Nodes, perform the desired Task, and Once the Task is over, it will delete that module from that target machine. 56 | 57 | Ansible_Controller Ansible_Node1 58 | 59 | setup_Java_BuildServer.sh ======================> Copy setup_Java_BuildServer.sh and Execute this script in Ansible Node1 60 | apt install git 61 | apt install jdk 62 | apt install maven 63 | 64 | 65 | - Ansible Use the Push Mechanism 66 | 67 | 68 | Ansible is Agentless. 69 | 70 | 71 | - Ansible Config File : 72 | 73 | - Is used to define the default properties of Ansible 74 | 75 | - Ansible Adhoc Commands : 76 | 77 | - It is used to execute a module in the target machine. 78 | 79 | Eg.: 80 | 81 | Target Server : 82 | 83 | install git : 84 | - apt install git -y 85 | 86 | - Ansible Playbooks : 87 | 88 | - Used to execute the series of task/Modules in the target machine. 89 | - Ansible Playbooks should be reusable 90 | - Ansible Playbooks are written using *.yaml Scripts 91 | 92 | Eg.: 93 | Target Server : 94 | 95 | Setup the Jenkins Slave_Node : 96 | 97 | - apt install git -y 98 | - apt install jdk -y 99 | - apt install maven -y 100 | - apt install docker.io -y 101 | 102 | 103 | - Installation & Configurations of Ansible Controller and Nodes 104 | 105 | - Create Ansible Inventory File 106 | 107 | Next :: 108 | - Ansible Concepts :: 109 | - Ansible Adhoc Commands 110 | 111 | - Ansible Playbooks 112 | 113 | - Ansible Variables 114 | 115 | - Ansible Handlers 116 | 117 | - Ansible Roles 118 | 119 | 120 | ####################### 121 | Day 42: 3rd Oct. 2024 122 | ####################### 123 | 124 | 125 | - Ansible Concepts :: 126 | - Ansible Adhoc Commands 127 | 128 | - Ansible Playbooks 129 | 130 | - Ansible Variables 131 | 132 | - Ansible Handlers 133 | 134 | - Ansible Roles 135 | 136 | 137 | - Ansible Adhoc Commands : 138 | 139 | - It is used to execute a module in the target machine. 140 | 141 | - Ansible Playbooks ::: 142 | 143 | 144 | - Used to execute the series of task/Modules in the target machine. 145 | - Ansible Playbooks should be reusable 146 | - Ansible Playbooks are written using *.yaml Scripts 147 | 148 | 149 | Varibles ::: 150 | 151 | Environment Variables - Keywords 152 | 153 | 154 | 155 | User-Defined Variables 156 | 157 | 158 | Next :: 159 | 160 | - Ansible Handlers 161 | 162 | - Ansible Roles 163 | 164 | - Terraform 165 | 166 | 167 | ####################### 168 | Day 43: 4th Oct. 2024 169 | ####################### 170 | 171 | - Ansible Handlers ::: 172 | 173 | Handlers --> are used to control the flow of playbook execution, based on the previous modules 174 | This can be done thru notify key. 175 | 176 | Handlers are same as tasks. 177 | But, it gets executed only if we notify. 178 | 179 | 180 | Install git : 181 | 182 | Install Maven : 183 | 184 | Install Tomcat : 185 | GIT Maven Tomcat MYSQL 186 | 187 | - Install the Pre-requisites --> NA JDK 1. JDK Pre-requisites 188 | 189 | - Install the Actual Tool --> install git Install Maven 2. Tomcat Install MYSQL 190 | 191 | - Perform Post Installation Activities --> NA NA 3. Start Tomcat Start MYSQL Server 192 | 193 | 194 | Software Package : 195 | 196 | - Tool 197 | 198 | - Service 199 | 200 | 201 | 202 | Ansible Roles :::: 203 | 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /DevOps_Intro/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | Day 21: 23rd Aug. 2024 3 | ####################### 4 | 5 | Introduction to DevOps 6 | 7 | 1. Evolution of Waterfall, Agile, and DevOps 8 | 2. What is DevOps 9 | 3. Why DevOps 10 | 4. Benefits of DevOps 11 | 5. DevOps Stages 12 | 6. DevOps Lifecycle 13 | 7. Various Automation in DevOps 14 | 8. Overview of CICD 15 | 16 | 17 | DevOps ::: 18 | 19 | What is DevOps ???? 20 | 21 | 22 | IT 23 | 24 | Develop the Software Applications ::: 25 | 26 | SDLC - Software Development Life Cycle :: 27 | 28 | 29 | Software - Any Computer Application 30 | 31 | Desktop Applications 32 | 33 | Web Applications 34 | 35 | Mobile Applications 36 | 37 | Embedded Applications 38 | 39 | SDLC - Software Development Life Cycle :: 40 | 41 | Desktop Application :: 42 | - SuperMarket Billing System 43 | Functions : 44 | - User Interface Design 45 | - Stock_Maintainence 46 | - Payment Module 47 | - Cash 48 | - Card 49 | - Billing 50 | - Print_Bills 51 | 52 | Stages of SDLC :: 53 | 54 | Requirement Analysis 55 | Design/Document 56 | Code/Develop 57 | Test 58 | Implementation 59 | Monitor/Maintain 60 | 61 | 62 | Waterfall Model :: 63 | - Top-Down Approach 64 | - It is linear in fashion 65 | - It was used for Monolith Application Architecture 66 | 67 | Core_Project 68 | Requirement Analysis ===> 12 Months 69 | - SuperMarket Billing System 70 | Functions : 71 | - User Interface Design 72 | - Stock_Maintainence 73 | - Payment Module 74 | - Cash 75 | - Card 76 | - Billing 77 | - Print_Bills 78 | Design/Document 79 | Code/Develop 7th Month ==> Add New Feature - UPI Payment Feature 80 | Test 81 | Implementation 82 | Monitor/Maintain 83 | 84 | Enhancement_Project ==> Add New Feature - UPI Payment Feature 85 | 86 | Requirement Analysis 87 | Design/Document 88 | Code/Develop 89 | Test 90 | Implementation 91 | Monitor/Maintain 92 | 93 | 94 | AGILE Methodologies ::: 95 | - SuperMarket Billing System 96 | Functions/Modules ==> Iterations : 97 | - User Interface Design 98 | - Stock_Maintainence 99 | - Payment Module 100 | - Cash 101 | - Card 102 | - Billing 103 | - Print_Bills 104 | 105 | Iteration 1 : User Interface Design 106 | 107 | Requirement Analysis 108 | Design/Document 109 | Code/Develop 110 | Test 111 | Implementated to Production with proper approval 112 | Monitor/Maintain 113 | 114 | Iteration 2 : Stock_Maintainence 115 | 116 | Requirement Analysis 117 | Design/Document 118 | Code/Develop 119 | Test 120 | Implementated to Production with proper approval 121 | Monitor/Maintain 122 | 123 | Iteration 3 : Payment Module - CASH 124 | 125 | Requirement Analysis 126 | Design/Document 127 | Code/Develop 128 | Test 129 | Implementated to Production with proper approval 130 | Monitor/Maintain 131 | 132 | 133 | Iteration 4 : Payment Module - CARD 134 | 135 | Requirement Analysis 136 | Design/Document 137 | Code/Develop 138 | Test 139 | Implementated to Production with proper approval 140 | Monitor/Maintain 141 | 142 | Iteration nth : Payment Module - UPI 143 | 144 | Requirement Analysis 145 | Design/Document 146 | Code/Develop 147 | Test 148 | Implementated to Production with proper approval 149 | Monitor/Maintain 150 | 151 | Using AGILE Methodologies :: 152 | We can achieve : 153 | 154 | - Continuous Development 155 | - Continuous Integration 156 | - Continuous Testing 157 | - Continuous Delivery 158 | - Here For any production release, manual approvals are required 159 | 160 | We cannot achieve : 161 | - Continuous Deployment 162 | - Here No Manual Approvals Need for Production Release 163 | 164 | 165 | DevOps ::: 166 | 167 | DevOps is a Software Development Strategy which helps to promote the collaboration between the Teams like Development Team and Operations Team to achieve Continuous Development, Continuous Integration, Continuous Testing, Continuous Delivery, Continuous Deployment, Continuous Monitoring in more automated fashion. 168 | 169 | How to Implement DevOps ? 170 | 171 | Teams involved in the overall SDLC Process : 172 | 173 | DevOps Team 174 | Infra-Structure Management Team 175 | Application Development Team 176 | Testing Team 177 | Release Management Team 178 | Production Support Team 179 | Production Monitoring Team 180 | IT Security Team 181 | 182 | Environments ::: 183 | 184 | Non-Prod Environments Production Environments 185 | 186 | Dev 187 | Build 188 | Test 189 | QA 190 | UAT ============> Production Servers 191 | 192 | DevOps Stages ::: 193 | 194 | Continuous Development : 195 | - It is the capabililty of Application Development Team to Continously Develop/Create the Application Source Code. 196 | - The main objective of this process is to improve Developers' Productivity 197 | 198 | What is the role/responsibility of Developer? 199 | 200 | - Create Application Source Code 201 | 202 | - Build the code - Compile and create artifacts 203 | - Unit Testing 204 | - Promote the Application to higher testing Environment 205 | - Notify the Testing Team 206 | 207 | 208 | Using DevOps Approach :: 209 | Developers : 210 | -- Create Application Source Code 211 | -- Commit the Source Code to Source Code Repository like github 212 | 213 | Using DevOps Process : 214 | Automate :: 215 | 216 | - Build the code - Compile and create artifacts 217 | - Unit Testing 218 | - Promote the Application to higher testing Environment 219 | - Notify the Testing/Development Team 220 | 221 | Tools ::: 222 | 223 | - Eclipse based IDEs - like Eclipse for Java,Pycharm,Intellij, Visual Studio, Visual Studio Code 224 | - Source Code Management Tool - like github/AWS Code Commit/Azure Repos 225 | 226 | 227 | Continuous Integration : 228 | - It is the capabililty of Application Development Team to Continously Integrate the Code Changes for further Testing, without impacting others. 229 | 230 | Tools : 231 | - Eclipse based IDEs - like Eclipse for Java,Pycharm,Intellij, Visual Studio, Visual Studio Code 232 | - Source Code Management Tool - like github/AWS Code Commit/Azure Repos 233 | - Jenkins/AWS Code Pipeline/Azure Pipeline, Docker, Kubernetes, Ansible 234 | 235 | Continuous Testing : 236 | - It is the capabililty of Testing Team to Continously Test the Code Changes without impacting others. 237 | 238 | Tools : 239 | - Jenkins/AWS Code Pipeline/Azure Pipeline 240 | - Junit/TestNG/Selenium 241 | 242 | 243 | Continuous Delivery / Deployment : 244 | - Both are used perform the Production Releases 245 | 246 | Continuous Delivery ::: 247 | 248 | - It expects manual approvals for production release 249 | - It is a manual process 250 | - Expect Downtime during production release 251 | 252 | Continuous Deployment ::: 253 | 254 | - This approach is used to automate the production releases without any manual intervension. 255 | - It is the automated process 256 | - The New Deployments/Relase can be done without any Downtime during production release 257 | 258 | Tools : 259 | 260 | - GIT, Jenkins/AWS Code Pipeline/Azure Pipeline, Docker, Kubernetes, Ansible 261 | 262 | Continuous Monitoring : 263 | - It is used to monitor the infra-structure and Applications based on the monitorig frequency 264 | 265 | - Infra-Structure Monitoring 266 | - Prometheus/Grafana/Dyna-trace/Nagios/Splunk 267 | - Used ot Monitor the CPU/Memory utilizations 268 | 269 | - Application Monitoring 270 | 271 | - AppDynamics / DataDog 272 | 273 | 274 | 275 | Infra-Structure Perspective::: 276 | 277 | - Provisioning/Creating the Resources 278 | - Terraform/Cloudformation 279 | 280 | - Configure the Resources 281 | - Configuration Management Tools: 282 | - Ansible 283 | 284 | 285 | Monolith Application Architecture ::: 286 | 287 | - Application is tightly coupled. 288 | - It is not easy to split and deploy any function independently 289 | 290 | - Only Continuous Delivery can be possible with the Monolith Application Architecture 291 | 292 | Micro-Service Based Application Architecture :: 293 | 294 | - Application is loosely coupled. 295 | - The functions/Modules are called as microservice 296 | - Each Micro-Service can be independently created, test, and deployed to prod, without any manual intervension 297 | 298 | - Continuous Deployment can be possible with the Micro-Service Based Application Architecture 299 | 300 | 301 | DevOps LifeCycle :::: 302 | 303 | Developer Create Source Code 304 | | 305 | | 306 | Commit the Code to Source Code Repository (Github/Az-Repo) 307 | | 308 | | 309 | Automated Build 310 | | 311 | | 312 | Automated Code Promotion to Test Environment 313 | | 314 | | 315 | Automated Testing 316 | | 317 | | 318 | Automated Code Promotion to Production Environments 319 | | 320 | | 321 | Production Testing 322 | | 323 | | 324 | Continuous Monitoring 325 | | 326 | | 327 | Feedback from Customers/Business Users 328 | 329 | 330 | -------------------------------------------------------------------------------- /DevOps_On_Cloud_ClassNotes.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | Day 45: 9th Oct. 2024 3 | ####################### 4 | 5 | Overview of DevOps on Cloud - AWS / Azure DevOps Services! 6 | 7 | 1. Overview of AWS DevOps and Azure DevOps 8 | 2. Code Build 9 | 3. Code Commit 10 | 4. Code Deploy 11 | 5. Code Pipeline 12 | 6. Overview of Cloud Formation 13 | 14 | Open-Source DevOps Tools : github/jenkins/docker/kubernetes/ansible/terraform 15 | 16 | 17 | DevOps Service from Cloud Service Providers : Managed Services : 18 | 19 | -> Azure DevOps Services # 1st Preference! 20 | 21 | -> AWS DevOps Services # 22 | 23 | DevOps Implementation ::: 24 | 25 | How to Choose the DevOps Services (Open-Source vs Managed_Services) ? 26 | 27 | - Need to do a detailed DevOps Assessment! 28 | 29 | - Based on the DevOps Assessment, we can recommended the DevOps Tools & Services. 30 | 31 | DevOps Assessment ??? 32 | 33 | DevOps Lead/Architect/Consultant :: 34 | 35 | --> Interact with all the stakeholders. 36 | 37 | --> Tools 38 | 39 | --> Current Development/Build/Test/Deployment Process 40 | 41 | --> Build and Release Environments and Frequencies 42 | 43 | --> Key Performance Metrics 44 | - MTTR 45 | 46 | --> IAAS / PAAS / SAAS ---> Customers/Client & Vendor/AWS Cloud Service Provider 47 | 48 | DevOps Assessment Report with the recommendations! 49 | 50 | How to provide the recommendations to implement DevOps. 51 | 52 | AWS DevOps Services 53 | 54 | Open-Source DevOps Services 55 | 56 | 57 | DevOps ::: 58 | 59 | DevOps is a Software Development Strategy which helps to promote the collaboration between the Teams like Development Team and Operations Team to achieve Continuous Development, Continuous Integration, Continuous Testing, Continuous Delivery, Continuous Deployment, Continuous Monitoring in more automated fashion. 60 | 61 | How to Implement DevOps ? 62 | 63 | Teams involved in the overall SDLC Process : 64 | 65 | DevOps Team 66 | Infra-Structure Management Team 67 | Application Development Team 68 | Testing Team 69 | Release Management Team 70 | Production Support Team 71 | Production Monitoring Team 72 | IT Security Team 73 | 74 | Environments ::: 75 | 76 | Non-Prod Environments Production Environments 77 | 78 | Dev 79 | Build 80 | Test 81 | QA 82 | UAT ============> Production Servers 83 | 84 | 85 | 86 | AWS DevOps Services Open-Source DevOps Tools Azure DevOps Services 87 | 88 | 89 | - Code Commit - github/bitbucket/gitlab-ci - Azure Repository 90 | 91 | - Code Build - Jenkins - Azure Pipelines 92 | 93 | - Code Deploy - Jenkins - Azure Pipelines 94 | 95 | - Code Pipeline - Jenkins - Azure Pipelines 96 | 97 | - Code Artifacts - JFrog Artifactory - Azure Artifacts 98 | 99 | - Elastic Container Service(ECS) - Docker - Azure Container Service(ACS) 100 | 101 | - Elastic Container Registry(ECR) - Docker Container Registry(DockerHub) - Azure Container Registry(ACR) 102 | 103 | - Elastic Kubernetes Service(EKS) - Kubernetes - Azure Kubernetes Service(AKS) 104 | 105 | - Jira(Appln. Lifecycle Mgmt) - Jira(Appln. Lifecycle Mgmt) - Azure Boards (Appln. Lifecycle Mgmt) 106 | 107 | 108 | Infra-Structure Management : 109 | 110 | - Cloudformation - Terraform/Ansible - Azure Resource Manager(ARM) 111 | -------------------------------------------------------------------------------- /Docker/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ####################### 4 | Day 31: 12th Sep. 2024 5 | ####################### 6 | 7 | Containerization using Docker! 8 | 9 | Docker!!! 10 | 11 | Containerization ::: 12 | 13 | --> Containerization is a process of packaging the application along with its dependencies! 14 | 15 | 16 | 17 | Virtual Machines : 18 | 19 | - VMs are hardware level Virtualization 20 | - VMs are created using Hypervisor 21 | - VMs are used to run the Operating Systems 22 | - VMs will continue to execute even if there is no task or active applications 23 | - VMs consume more space and time to start up. 24 | 25 | Containers : 26 | 27 | - Containers are hardware level Virtualization 28 | - Containers are created using Container Engine 29 | - Containers are used to run the the Application. NOT Operating Systems 30 | - Containers will immediately go to EXIT state, if there is no task or active applications 31 | - Containers consume less space and time to start up 32 | - Using Containers we can reduce the no. of VM, But we cannot completely elimate VMs 33 | - Container run in its own isolated address spac, the scope of the container application is within the container 34 | 35 | 36 | --> Containerization is a process of packaging the application along with its dependencies! 37 | 38 | Container Use-Cases ::: 39 | 40 | Infra-Structure Perspective ::: 41 | 42 | --> Containers are used to reduce the number of VMs and save the Infra-Structure Cost! 43 | 44 | Jenkins_Master (VM) ==> To Create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 45 | 46 | Jenkins_SlaveNode1 (VM) ==> Perform Application Builds - Java Applications 47 | Jenkins_SlaveNode2 (VM) ==> Perform Application Builds - .Net Applications 48 | Jenkins_SlaveNode3 (VM) ==> Perform Application Builds - Python Applications 49 | Jenkins_SlaveNode4 (VM) ==> Perform Application Builds - Angular/NodeJS 50 | Jenkins_SlaveNode5 (VM) ==> Perform Application Builds - Ruby 51 | 52 | --> Using Containers : 53 | 54 | Jenkins_Master (VM) 55 | - Jenkins_Build_Server (VM) 56 | - Install Container Engine 57 | C1 ==> Perform Application Builds - Java Applications 58 | C2 ==> Perform Application Builds - .Net Applications 59 | C3 ==> Perform Application Builds - Python Applications 60 | C4 ==> Perform Application Builds - Angular/NodeJS 61 | C5 ==> Perform Application Builds - Ruby 62 | 63 | Developers'/Deployment Perspective ::: 64 | 65 | --> Containers are used to package the application along with its dependencies and deploy in target environments! 66 | 67 | 68 | Environments: 69 | 70 | Dev Environment (VM) 71 | 72 | Developers Create the Source Code 73 | Build - Compile and Create Artifacts ==> mywebapp.war 74 | Run the Application and do Unit Testing 75 | --> jdk_11,tomcat_8.0 - using this jdk and tomcat mywebapp.war got executed and tested 76 | Promote the Application to QA / UAT / Prod 77 | 78 | QA Environment (VM) ==> mywebapp.war 79 | Testing Team will Run the Application and do QA Testing 80 | --> jdk_17,tomcat_9.0 81 | 82 | UAT Environment 83 | Testing Team will Run the Application and do QA Testing 84 | 85 | 86 | 87 | --> Using Containerization Process ::: 88 | 89 | --> Containerization is a process of packaging the application along with its dependencies! 90 | Using Containerization :::: 91 | 92 | 93 | Dev Environment (VM) 94 | 95 | Developers Create the Source Code 96 | Build - Compile and Create Artifacts ==> mywebapp.war 97 | Run the Application and do Unit Testing 98 | --> jdk_11,tomcat_8.0 - using this jdk and tomcat mywebapp.war got executed and tested 99 | 100 | Package the application - (mywebapp.war + jkd_11,tomcat_8.0) --> Application Images 101 | 102 | Create Application Image --> mywebapp_imgv1.0 103 | 104 | Publish/Push/Save the Application Image to the Container Registry and version control it. 105 | 106 | 107 | QA Environment (VM) 108 | Testing Team will Pull the Application Image from Container Registry and run it as an Application Container. 109 | ==> mywebapp_imgv1.0 --> (mywebapp.war + jkd_11,tomcat_8.0) 110 | 111 | 112 | Terminolgies ::: 113 | 114 | Container Engine 115 | -- Is used to Create/Manage Container Images and Create/Manage and run Containers 116 | 117 | Container Images 118 | -- Is a Static file that defined the properties of the Container and its dependencies 119 | -- Container Images are Non-Executables 120 | -- Container Images are composed of various Layers created using the Dockerfile Instructions 121 | 122 | Containers 123 | -- Containers are the executable units of Container Images 124 | -- Containers are used to run the applications defined in the Container Images 125 | 126 | Container Registry 127 | -- It is used to save and version control the Container Images 128 | Dockerhub is Container Registry to be used. 129 | https://hub.docker.com/ 130 | 131 | Container Repositories 132 | -- Container Repositories are the subset of Container Registry 133 | 134 | github Docker-Hub_Registry 135 | repo1 Docker-hub_Repository1 136 | repo2 Docker-hub_Repository2 137 | 138 | 139 | Working with Docker! 140 | 141 | - Install Docker Engine 142 | # https://docs.docker.com/engine/install/ 143 | 144 | - Launch Ubuntu Machine - v22.04 / Use existing Jenkins Slave Node to Installl Docker Engine 145 | 146 | - sudo -i 147 | - apt update -y 148 | - apt install docker.io -y 149 | 150 | 151 | - Docker CLI Commands 152 | 153 | docker --version 154 | 155 | 156 | docker images # To get the list of images in local machine 157 | 158 | docker ps # To get the list of Active/Running Containers 159 | 160 | docker ps -a # To get the list of all containers 161 | 162 | 163 | Container Registry 164 | -- It is used to save and version control the Container Images 165 | Dockerhub is Container Registry to be used. 166 | https://hub.docker.com/ 167 | 168 | Container Repositories 169 | -- Container Repositories are the subset of Container Registry 170 | 171 | 172 | 173 | docker pull # To download the docker container image from dockerhub registry to lacl machine 174 | 175 | docker pull centos:latest 176 | docker pull ubuntu:v1.0 177 | 178 | 179 | ####################### 180 | Day 32: 13th Sep. 2024 181 | ####################### 182 | 183 | docker pull # TO Download the latest version of Container Image 184 | 185 | docker pull : # TO Download the specific version of Container Image 186 | 187 | 188 | docker run # To Create and run the Container 189 | 190 | Container Execution Modes :: 191 | 192 | - Foreground / Attached Mode # Default Mode 193 | 194 | docker run 195 | 196 | Eg.: 197 | 198 | docker run centos sleep 20 199 | 200 | - Background / Detached Mode 201 | 202 | docker run -d 203 | Eg.: 204 | 205 | docker run -d centos sleep 20 206 | 207 | - Interactive Mode 208 | 209 | docker run -d 210 | Eg.: 211 | 212 | docker run -it centos bash 213 | 214 | 215 | docker start # To Start the Container 216 | 217 | docker stop # To Stop the container 218 | 219 | docker exec -it bash # To Login to the running Container 220 | 221 | docker rm # To remove/delete the Container 222 | 223 | docker rmi # To remove/delete the Image from local machine 224 | 225 | 226 | Port Mapping / Port Binding :::: 227 | 228 | - It is used to expose the container to access thru internet 229 | 230 | - It is a process of mapping the container port with the host port. 231 | 232 | Run Application inside the Container! 233 | 234 | docker run -it tomcat:8.0 bash 235 | 236 | docker run -it -p : tomcat:8.0 237 | 238 | Eg: 239 | 240 | docker run -it -p 8089:8080 tomcat:8.0 241 | 242 | -p : 243 | 244 | 245 | QA_Server ::: 246 | 247 | Installed Tomcat :: 248 | 249 | 8080 --> Execute only one application 250 | 251 | service1 -- 8080 252 | 253 | service2 -- 8089 254 | 255 | 256 | ####################### 257 | Day 33: 16th Sep. 2024 258 | ####################### 259 | 260 | 261 | Docker Volumes :::: 262 | 263 | 264 | Container ::: 265 | 266 | - Runs in an isolated address space. 267 | 268 | Monolith 269 | Micro-Service 270 | 3-tier Applications 271 | 272 | 273 | Container 274 | 275 | Stateless Applications 276 | - Application that will not have any state of execution 277 | - Applications that will not create any output/need any input. 278 | 279 | Stateful Applications :: 280 | - Application that will have state of execution 281 | - Applications that requires some input nad generate some output 282 | 283 | 284 | 285 | User_Login/SignIn Services ::: 286 | 287 | 3 - Tier Application Layers ::: 288 | 289 | Front-End - User Interface 290 | 291 | Application Layer - Business Logic 292 | 293 | Back-End Layer - DataBase 294 | 295 | 296 | docker volume ::: 297 | 298 | - Is used to create permanent Volumes that can be attached to any container to maintain the persistant data accross the Applications running thru containers. 299 | 300 | 301 | docker volume create 302 | 303 | docker volume inspect 304 | 305 | docker run -it centos bash 306 | 307 | docker run -it --mount source=sa-wd-devops-vol1,destination=/sa-wd-devops-vol1 centos bash 308 | 309 | 310 | 311 | Create Container Images :::: 312 | 313 | 314 | docker commit :: 315 | 316 | - To Create a New Container Image based on the properties of existing Container. 317 | 318 | Syntax : 319 | 320 | docker commit /New_Image_Name>: 321 | 322 | Eg.: 323 | docker commit 6070980df5f2 loksaieta/sa-javaappbuildimg:v1.0 324 | 325 | 326 | 327 | docker build :: 328 | 329 | - To create a new Container Image based on the Dockerfile reference. 330 | - Dockerfile composed of Instructions to Create Docker Container Images 331 | - Application Developers create the Dockerfile and update in the Source Code Repository. 332 | 333 | 334 | vi Dockerfile 335 | 336 | FROM ubuntu 337 | RUN apt update -y 338 | RUN apt install git -y 339 | RUN apt install maven -y 340 | 341 | Syntax : 342 | 343 | docker build -t /New_Image_Name>: . # '.' refers to the Dockerfile path 344 | 345 | Eg.: 346 | 347 | docker build -t loksaieta/sa-javamvnimg . # '.' refers to the Dockerfile path 348 | 349 | Write Dockerfile ::: 350 | 351 | Docker File Instructions ::: 352 | 353 | FROM # To Identify the Base Image 354 | RUN # To run the package manager 355 | COPY # To Copy the file from host volume to container volume 356 | CP # To Copy the file within the container volumes 357 | ADD # To Copy the file from Host Volume as well as from URL 358 | ENV # To define the Environment Variable 359 | ARG # To pass Arguements to the Steps in Dockerfile 360 | EXPOSE # To Define the Container Port 361 | WORKDIR # To set the current working directory within the Container 362 | CMD # To set the default start-up command to the container 363 | This Command can be changed at run-time. 364 | ENTRYPOINT # To set the default start-up command to the container 365 | This Command cannot be changed at run-time. 366 | 367 | 368 | 369 | Dockerfile ::: 370 | 371 | FROM tomcat:8.0 372 | COPY ./target/*.war /usr/local/tomcat/webapps 373 | EXPOSE 8080 374 | 375 | docker build -t loksaieta/sa-webappimg:v1.0 . # run this command from the Dockerfile location. 376 | docker run -it -p 8089:8080 loksaieta/sa-webappimg:v1.0 377 | 378 | 379 | 380 | ####################### 381 | Day 34: 18th Sep. 2024 382 | ####################### 383 | 384 | 385 | Container Orchestration :::: 386 | 387 | Overview of ; 388 | Docker Compose 389 | Docker Swarm 390 | 391 | Kubernetes 392 | 393 | Containers ::: 394 | 395 | 396 | 3-Tier Application Service : 397 | 398 | User_SignIn Service : 399 | 400 | Front-End --> C1.0 401 | 402 | Application_Layer --> C2.0 403 | 404 | Database Layer --> C3.0 405 | 406 | 407 | 408 | docker run c1.0_image 409 | 410 | docker run c2.0_image 411 | 412 | docker run c3.0_image 413 | 414 | 415 | Need run the containers as a service! 416 | 417 | How to execute more than once container as a service ??? 418 | 419 | Docker Compose 420 | - Is an extension/Plugin to Docker Engine. 421 | - Is used to run multiple containers as a Service! 422 | - Docker Compose uses the Yaml file to create the Service definitions 423 | 424 | User_SignIn_Service: 425 | C1.0 426 | C2.0 427 | C3.0 428 | 429 | 430 | Any Container that is part of a Service : 431 | 432 | should be in-sync with other container within the service 433 | 434 | 435 | Start/Stop all these container at the same time. 436 | 437 | 438 | 439 | Work with Docker Compose :: 440 | 441 | Install Docker_Compose 442 | 443 | https://docs.docker.com/compose/install/linux/ 444 | 445 | # Manual Installation of Docker Compose ::: 446 | 447 | DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} 448 | mkdir -p $DOCKER_CONFIG/cli-plugins 449 | curl -SL https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose 450 | 451 | chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose 452 | 453 | docker compose version 454 | 455 | vi docker-compose.yaml 456 | 457 | 458 | 459 | ### Yaml Files are based on Keys & Values -- key:value Pairs 460 | 461 | version: '3' 462 | services: 463 | webserv1: 464 | image: "tomcat:8.0" 465 | ports: 466 | - 8098:8080 467 | dbserv1: 468 | image: "redis:alpine" 469 | 470 | docker compose up 471 | 472 | docker compose down 473 | 474 | 475 | Docker Swarm :::: 476 | 477 | Container Orchestration Tool :::: 478 | 479 | - Docker Swarm is one the Container Orchestration Tools. 480 | - It is meant only for Docker Containers. 481 | - Used to Ensure High Availability of Containers by creating Replicas of Containers. 482 | - We cannot Do Auto-Scaling or Load Balancing! 483 | 484 | 485 | 486 | 3-Tier Application Service : 487 | 488 | User_SignIn Service : 489 | 490 | Front-End --> C1.0,C1.1,C1.2,C1.3,C1.4 491 | 492 | Application_Layer --> C2.0,C2.1,C2.2,C2.3,C2.4 493 | 494 | Database Layer --> C3.0,C3.1,C3.2,C3.3,C3.4 495 | 496 | 497 | 498 | 499 | Prod-Environment 500 | 501 | Production server1,2,3,4,5,6 502 | 503 | 504 | 505 | Web Application: 506 | 507 | 5000 Users to access my website at the same time 508 | 509 | 100 Container Instances 510 | 511 | 10000 512 | 513 | 200 Container Instances ? # Scale-Up the Container Instances 514 | 515 | 5000 516 | 517 | 100 Container Instances ? # Scale-Down the Container Instances 518 | 519 | Summary ::: 520 | 521 | Containerization 522 | VM (vs) Container 523 | How install Container Engine 524 | Docker CLi Commands 525 | 3 Mode of Docker run command 526 | exec 527 | persistant volumes 528 | Create Images - docker commit and build command 529 | Dockerfile Instructions 530 | Docker Compose & Swarm 531 | 532 | 533 | Next : 534 | Kubernetes ::::: 535 | 536 | 537 | 538 | ####################### 539 | Day 34: 18th Sep. 2024 540 | ####################### 541 | 542 | 543 | Kubernetes :::: 544 | 545 | - It is a Open-Source Container Orchestration Tool 546 | - Kubernetes is used to Deploy any type of Containers. 547 | - It is used to ensure high availability of the Applications/services running thru Containers. 548 | - Used to Ensure High Availability of Containers by creating Replicas of Containers. 549 | - It supports Auto-Scaling & Load Balancing. 550 | 551 | Managed Services :: 552 | 553 | AWS - ECS/ECR/EKS 554 | Azure - ACS/ACR/AKS 555 | 556 | GOOGLE ! 557 | 558 | Kubernetes Architecture 559 | 560 | Kubernetes Components 561 | 562 | Install Kubernetes 563 | 564 | DevOps :::: 565 | 566 | 567 | 568 | Docker Swarm :::: 569 | 570 | Container Orchestration Tool :::: 571 | 572 | - Docker Swarm is one the Container Orchestration Tools. 573 | - It is meant only for Docker Containers. 574 | - Used to Ensure High Availability of Containers by creating Replicas of Containers. 575 | - We cannot Do Auto-Scaling or Load Balancing! 576 | 577 | 578 | Service ::: 579 | 580 | Front_End C1 / Replicas of C1 - 3 Replicas 581 | 582 | Application_Layer C2 583 | 584 | Back_End (DataBase) C3 585 | 586 | 587 | Kubernetes :::: 588 | 589 | - It is a Open-Source Container Orchestration Tool 590 | - Kubernetes is used to Deploy any type of Containers. 591 | - It is used to ensure high availability of the Applications/services running thru Containers. 592 | - Used to Ensure High Availability of Containers by creating Replicas of Containers. 593 | - It supports Auto-Scaling & Load Balancing. 594 | 595 | 596 | Working with Kubernetes ::: 597 | 598 | - Used to deploy the Containerized Application Services to the Target Environments 599 | 600 | Docker Images :::: 601 | 602 | 603 | Container Registry ::: 604 | 605 | - Used to manage the container Images 606 | - DockerHub 607 | 608 | Continous Integration/Continous Deployment Workflow ::: 609 | 610 | 1. Create Source Code 611 | 2. Application Build 612 | 3. Application Image Build using Dockerfile 613 | 4. Publish the Application Image to Container Registry 614 | 615 | 5. Deploy the Application Images to the Target Environments using Kubernetes 616 | 617 | 618 | 619 | 620 | 1. Publish/Push the Application Images to Container Registry. 621 | 622 | Next : 623 | How to Publish/Push the Application Images to Container Registry ? 624 | How to Deploy to Kubernetes Cluster? 625 | How to Ensure High Availability of Application by creating replicas? 626 | 627 | Kubernetes Architecture ??? 628 | 629 | Kubernetes Components/Terminologies/Concepts ??? 630 | 631 | Install Kubernetes ??? 632 | 633 | 634 | ####################### 635 | Day 35: 19th Sep. 2024 636 | ####################### 637 | 638 | Docker :: 639 | 640 | Publish/Push the Application Images to Container Registry. 641 | 642 | vi Dockerfile 643 | 644 | 645 | FROM tomcat:8.0 646 | COPY ./target/*.war /usr/local/tomcat/webapps 647 | EXPOSE 8080 648 | 649 | docker build -t loksaieta/sa-webappimg:v1.0 . # run this command from the Dockerfile location. 650 | 651 | docker run -it -p 8089:8080 loksaieta/sa-webappimg:v1.0 652 | 653 | 654 | Publish/Push the Application Images to Container Registry. 655 | 656 | Login to DockerHub using Docker CLI. 657 | - DockerHub LoginID 658 | - DockerHub Access Token 659 | - Create Access Token in DockerHub 660 | 661 | docker login -u loasxsdksaieta 662 | 663 | Password: dcasdfasdfasdfasdfasdfasdfasdf 664 | 665 | 666 | 667 | docker push loksaieta/sa-webappimg:v1.0 668 | 669 | docker pull loksaieta/sa-webappimg:v1.0 670 | 671 | 672 | 673 | 674 | Thru Jenkins pipeline, create container images and Publish to Container registry. 675 | 676 | Jenkins :: with master/slave Nodes! 677 | 678 | Pipeline : 679 | SCM_Checkout 680 | Application_Build 681 | Deploy Application Artifacts to Target Environment 682 | 683 | 684 | pipeline { 685 | agent { label 'slave1' } 686 | 687 | stages { 688 | stage('SCM_Checkout') { 689 | steps { 690 | echo 'Perform SCM Checkout' 691 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 692 | } 693 | } 694 | stage('Application Build') { 695 | steps { 696 | echo 'Perform Application Build' 697 | sh 'mvn clean package' 698 | } 699 | } 700 | stage('Deploy to Test Environment') { 701 | steps { 702 | script{ 703 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Tomcat_Server', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: 'target/', sourceFiles: 'target/*.war')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 704 | } 705 | } 706 | } 707 | } 708 | } 709 | 710 | 711 | Objective ::: 712 | 713 | Jenkins pipeline, perform application build, create container images and Publish to Container registry. 714 | 715 | 716 | Resources - Servers/Tools Needed : 717 | 718 | 719 | Servers ::: 720 | 721 | Jenkins_Master --> # To create CICD Pipeline Jobs and schedule it to run in Slave Nodes 722 | 723 | Build_Server-Jenkins_Slave --> # Compile the Source Code 724 | (Perform Application Build and Docker Build) # Perform Unit Testing 725 | # Create Artifacts 726 | # Create Application Image 727 | # Publish Application Image to DockerHub Registry 728 | 729 | Tools :::: 730 | 731 | Jenkins_Master ---> # jdk, jenkins, git 732 | 733 | Build_Server-Jenkins_Slave ---> # git, jdk, maven, docker 734 | 735 | 736 | Maintain DockerHub Credentials in the Jenkins Credential Manager 737 | goto jenkins dashboard 738 | -- Manage Jenkins 739 | -- Credential 740 | -- using dockerhub username and access token 741 | 742 | 743 | pipeline { 744 | agent { label 'slave1' } 745 | 746 | environment { 747 | DOCKERHUB_CREDENTIALS=credentials('dockerloginid') 748 | } 749 | 750 | stages { 751 | stage('SCM_Checkout') { 752 | steps { 753 | echo 'Perform SCM Checkout' 754 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 755 | } 756 | } 757 | stage('Application Build') { 758 | steps { 759 | echo 'Perform Application Build' 760 | sh 'mvn clean package' 761 | } 762 | } 763 | stage('Docker Build') { 764 | steps { 765 | echo 'Perform Docker Build' 766 | sh "docker build -t loksaieta/sa-wd-webapp:${BUILD_NUMBER} ." 767 | sh 'docker image list' 768 | } 769 | } 770 | stage('Login to Dockerhub') { 771 | steps { 772 | echo 'Login to DockerHub' 773 | sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' 774 | 775 | } 776 | } 777 | stage('Publish the Image to Dockerhub') { 778 | steps { 779 | echo 'Publish to DockerHub' 780 | sh "docker push loksaieta/sa-wd-webapp:${BUILD_NUMBER}" 781 | } 782 | } 783 | } 784 | } 785 | 786 | 787 | Docker ::: 788 | 789 | Containerization 790 | VM (vs) Container 791 | How install Container Engine 792 | Docker CLi Commands 793 | 3 Mode of Docker run command 794 | exec 795 | persistant volumes 796 | Create Images - docker commit and build command 797 | Dockerfile Instructions 798 | Docker Compose & Swarm 799 | 800 | Create Jenkins CICD Pipeline to perform application build, create container images and Publish to Container registry. 801 | 802 | 803 | Dev 804 | 805 | Build Create Docker Images 806 | 807 | QA / UAT / Prod # Deployed using Kubernetes 808 | 809 | 810 | Next ::: 811 | 812 | Kubernetes :::: 813 | 814 | Kubernetes Architecture 815 | 816 | Kubernetes Components/Terminologies/Concepts 817 | 818 | Install Kubernetes 819 | -------------------------------------------------------------------------------- /Jenkins/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | Day 27: 4th Sep. 2024 3 | ####################### 4 | 5 | Build Orchestration Tool - Jenkins 6 | 7 | Jenkins ::: 8 | 9 | Continuous Development & Continuous Integration :::: 10 | 11 | Using DevOps Approach :: 12 | Developers : 13 | -- Create Application Source Code 14 | -- Commit the Source Code to Source Code Repository like github 15 | 16 | Using DevOps Process : 17 | Automate :: 18 | 19 | - Build the code - Compile and create artifacts 20 | - Unit Testing 21 | - Promote the Application to higher testing Environment 22 | - Notify the Testing/Development Team 23 | 24 | Tools ::: 25 | 26 | - Eclipse based IDEs - like Eclipse for Java,Pycharm,Intellij, Visual Studio, Visual Studio Code 27 | - Source Code Management Tool - like github/AWS Code Commit/Azure Repos 28 | - Jenkins/AzurePipeline/AWS CodeBuild/gitlab-ci 29 | 30 | 31 | Environment: 32 | 33 | Dev 34 | Create Source Code! --> Eclipse/GIT/GITHUB 35 | 36 | Build 37 | use the code in build enviroment --> Git 38 | build - compile --> maven 39 | create artitfacts --> maven 40 | unit test --> maven,junit 41 | promote the artifacts to Test environment --> Ansible/Deployment plugins/SSH 42 | 43 | Test 44 | Automated QA Testing --> TestNG,Selenium 45 | Generate Test Reports --> TestNG,Selenium 46 | Validated Test Results --> TestNG,Selenium 47 | promote the artifacts to Prod environment --> Ansible/Deployment plugins/SSH 48 | 49 | What is Jenkins ::: 50 | 51 | Jenkins is Open-Source Build Orchestration Tool. 52 | Used to Automate the End-to-End Application Build and Deployments 53 | Using Jenkins we can create CI/CD Pipelines 54 | 55 | Jenkins Architecture :: 56 | 57 | Jenkins is based on Master-Slave Architecture ::: 58 | 59 | Jenkins_Master (VM) ==> Install Jenkins - To Create Jenkins CI/CD Pipeline Projects 60 | Jenkins_SlaveNode1 (VM) ==> Perform Application Builds - compile/create artifacts 61 | 62 | 63 | At Enterprise level ::: 64 | 65 | Java Applications 66 | .Net Applications 67 | Python Applications 68 | 69 | Scenario1 : Application Build and Release frequency is very less. 70 | 71 | Jenkins_Master (VM) ==> Create Jenkins CI/CD Pipeline Projects & Execute the Build in same Jenkins_Master Node. 72 | 73 | 74 | Scenario2 : Muliple Applications with high Build and Release frequencies. 75 | 76 | Jenkins_Master (VM) ==> To Create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 77 | 78 | Jenkins_SlaveNode1 (VM) ==> Perform Application Builds - Java Applications 79 | Jenkins_SlaveNode2 (VM) ==> Perform Application Builds - .Net Applications 80 | Jenkins_SlaveNode3 (VM) ==> Perform Application Builds - Python Applications 81 | Jenkins_SlaveNode4 (VM) ==> Perform Application Builds - Angular/NodeJS 82 | Jenkins_SlaveNode5 (VM) ==> Perform Application Builds - Ruby 83 | 84 | 85 | CI/CD Workflow ::: 86 | 87 | SCM_Checkout 88 | Application Build 89 | Unit Testing 90 | Create Artifacts 91 | Promote the Application to Test Environments 92 | Notify 93 | Deploy to Prod 94 | 95 | 96 | Working with Jenkins ::: 97 | 98 | Developers' Perspective ::: 99 | - All Developers are just the Consumers of Jenkins Tools and Services. 100 | - Developers can just execute/cancel/view the Jenkins jobs/Status. 101 | 102 | DevOps Perspective ::: 103 | 104 | Roles & Responsibilies of DevOps Team : 105 | 106 | Jenkins Administration 107 | - Installation of Jenkins 108 | - Global System Configurations 109 | - Tools Management 110 | - User Management 111 | - Security Management 112 | 113 | - Plugins Management 114 | - Credential Management 115 | - Master/Slave Node Configurations 116 | - Creation CICD Pipeline Projects 117 | - Onboard Applications to use Jenkins CICD Projects 118 | - Periodic Upgrade of Jenkins and its plugins 119 | - Periodic Backup 120 | - Troubleshooting the Issues! 121 | 122 | 123 | - Installation of Jenkins ::: 124 | 125 | --> Jenkins can be installed in Linux - Ubuntu Machine AMI - v22.04 126 | https://www.jenkins.io/doc/book/installing/ 127 | 128 | https://www.jenkins.io/doc/book/installing/linux/ 129 | 130 | Jenkins run as a service, it runs in default port 8080 131 | 132 | 133 | - Global System Configurations 134 | --> Used to setup Global System Configuration and define default properties 135 | 136 | - Tools Management 137 | - User Management 138 | - Security Management 139 | 140 | Next ::: 141 | - Plugins Management ::: 142 | --> Plugins are extension to Jenkins to intergrate any external tool with Jenkins 143 | 144 | 145 | ####################### 146 | Day 28: 5th Sep. 2024 147 | ####################### 148 | 149 | 150 | - Plugins Management 151 | - Credential Management 152 | - Master/Slave Node Configurations 153 | - Creation CICD Pipeline Projects 154 | - Onboard Applications to use Jenkins CICD Projects 155 | - Periodic Upgrade of Jenkins and its plugins 156 | - Periodic Backup 157 | - Troubleshooting the Issues! 158 | 159 | - Plugins Management ::: 160 | --> Plugins are extension to Jenkins to intergrate any external tool with Jenkins 161 | 162 | 163 | VM -> Maven Build Tool 164 | -> Jenkins - using Jenkins I want to perform maven build 165 | - So, using Maven Plugins installed in Jenkins, Jenkins will interact with Maven Tool installed in the VM. 166 | 167 | - Credential Management ::: 168 | - Used to Create the Credentials for the external tools/servers 169 | 170 | 171 | - Create a Jenkins Project/Job ::: 172 | 173 | - Free-Style Projects # It is based on the Manual Configurations 174 | 175 | - Pipeline Project # It is based on the groovy Scripts to create CI/CD Pipelines 176 | 177 | 178 | - Handling Variables ::: 179 | 180 | - Environment Variables ::: 181 | - Pre-defined / reserved keywords that holds the jobs related details. 182 | 183 | - User-Defined Variables ::: 184 | 185 | a = 5 186 | 187 | "${var1}" 188 | 189 | 190 | - Pipeline Project 191 | 192 | Pipelines :: ==> are written using groovy scripts 193 | used to perform CI/CD Automation. 194 | 195 | - Scripted Pipelines :: 196 | 197 | - 198 | 199 | - Declarative Pipelines :: Simplified version of Scripted Pipelines 200 | 201 | 202 | Pipelines are the composed of various stages 203 | 204 | Stages are composed of various steps/tasks 205 | 206 | 207 | CI/CD Workflow ::: 208 | 209 | SCM_Checkout 210 | Application Build 211 | Unit Testing 212 | Create Artifacts 213 | Promote the Application to Test Environments 214 | Notify 215 | Deploy to Prod 216 | 217 | 218 | 219 | 220 | pipeline { 221 | agent any 222 | 223 | stages { 224 | stage('SCM_Checkout') { 225 | steps { 226 | echo 'Perform SCM Checkout' 227 | } 228 | } 229 | stage('Application Build') { 230 | steps { 231 | echo 'Perform Application Build' 232 | } 233 | } 234 | stage('Deploy to Test Environment') { 235 | steps { 236 | echo 'Perform Deployment' 237 | } 238 | } 239 | } 240 | } 241 | 242 | 243 | 244 | ####################### 245 | Day 29: 6th Sep. 2024 246 | ####################### 247 | 248 | 249 | - Master/Slave Node Configurations 250 | - Creation CICD Pipeline Projects 251 | - Onboard Applications to use Jenkins CICD Projects 252 | 253 | 254 | Scenario2 : Muliple Applications with high Build and Release frequencies. 255 | 256 | Jenkins_Master (VM) ==> To Create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 257 | 258 | Jenkins_SlaveNode1 (VM) ==> Perform Application Builds - Java Applications 259 | 260 | 261 | Environments ::: 262 | 263 | Non-Prod Environments Prod Environment 264 | 265 | Dev ==> Developers 266 | Create Source Code 267 | 268 | Build (VM) ===> Build -> Compile, create artifacts, 269 | Unit Test the Changes 270 | Promote the Changes to Test Environment 271 | 272 | Test =============> Prod Servers 273 | QA Testing (VM) 274 | Install Web Application Servers (Tomcat/Nginx) 275 | 276 | Purpose of Jenkins Master & Slave Nodes : 277 | 278 | Jenkins_Master (VM) ==> To Create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 279 | Jenkins_SlaveNode (VM) ==> To Perform Application Build & Unit Testing 280 | 281 | Tools to be installed : 282 | 283 | Jenkins_Master (VM) ==> git,jdk,jenkins 284 | Jenkins_SlaveNode (VM) ==> git,jdk,maven 285 | 286 | Configuration of Jenkins Master & Slave Nodes. 287 | 288 | Jenkins_Master (VM) git,jdk,jenkins 289 | 290 | Jenkins_SlaveNode (VM) git,jdk,maven 291 | - Install the Build Tools 292 | 293 | - Create UserName with SSH Keys 294 | 295 | 296 | Create CICD Pipeline :: 297 | 298 | Pipeline : 299 | 300 | Stage1 ==> SCM_Checkout 301 | 302 | Stage2 ==> Application_Build 303 | Maven Goals : 304 | This defines the actions we perform using Maven 305 | 306 | ● mvn compile - to compile the source code 307 | ● mvn test - to compile and execute junit test cases 308 | ● mvn package - to compile, test and create artifacts in the target folder of Project Library 309 | ● mvn clean - to clean the target folder. 310 | 311 | Eg.: 312 | 313 | mvn clean package 314 | Stage3 ==> Deploy to Test Environment 315 | 316 | 317 | pipeline { 318 | agent { label 'slave1' } 319 | 320 | stages { 321 | stage('SCM_Checkout') { 322 | steps { 323 | echo 'Perform SCM Checkout' 324 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 325 | } 326 | } 327 | stage('Application Build') { 328 | steps { 329 | echo 'Perform Application Build' 330 | sh 'mvn clean package' 331 | } 332 | } 333 | stage('Deploy to Test Environment') { 334 | steps { 335 | echo 'Perform Deployment' 336 | } 337 | } 338 | } 339 | } 340 | 341 | 342 | Build Triggers ::: 343 | 344 | It used to Automate the Job Exection. 345 | 346 | -> Build Periodic # https://crontab.guru/ 347 | 348 | - Used to trigger the jenkins jobs irrespective of code change. - It is not meant for CI/CD. 349 | - The build is sheduled based on the crontab 350 | 351 | Non-Prod Environments Prod Environment 352 | Shd be available only during business hrs 353 | DEV Servers 354 | BUILD 355 | QA/UAT Prod Servers 356 | 357 | 358 | 8AM - 10PM 359 | 360 | 361 | -> Github Webhook 362 | 363 | - Used to trigger the jenkins Job whenever there is any commit happened in the remote repository 364 | - github webhook has be configured in the remote repository by using the jenkins URL 365 | 366 | 367 | -> Poll-SCM 368 | 369 | - It is used to trigger the build based on the crontab only if there is any changes happened in the source-code repository. 370 | 371 | Eg.: 372 | 373 | Test Cycles ::: 374 | 375 | 376 | 8AM - 12PM - 3PM 377 | 378 | 379 | 380 | Next :: 381 | 382 | Target Server - Setup Tomcat Server! 383 | Email Notifications! 384 | 385 | 386 | ####################### 387 | Day 30: 11th Sep. 2024 388 | ####################### 389 | 390 | Target Server - Setup Tomcat Server! 391 | Email Notifications! 392 | 393 | 394 | pipeline { 395 | agent { label 'slave1' } 396 | 397 | stages { 398 | stage('SCM_Checkout') { 399 | steps { 400 | echo 'Perform SCM Checkout' 401 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 402 | } 403 | } 404 | stage('Application Build') { 405 | steps { 406 | echo 'Perform Application Build' 407 | sh 'mvn clean package' 408 | } 409 | } 410 | stage('Deploy to Test Environment') { 411 | steps { 412 | echo 'Perform Deployment' 413 | } 414 | } 415 | } 416 | } 417 | 418 | 419 | What is Deployment ? 420 | 421 | --> Deployment is a process of copy the application artifacts from the source machine to the target machine. 422 | 423 | Environments ::: 424 | 425 | Non-Prod Environments Prod Environment 426 | 427 | Dev ==> Developers 428 | Create Source Code 429 | 430 | Build (VM) ===> Build -> Compile, create artifacts, 431 | Unit Test the Changes 432 | Promote the Changes to Test Environment 433 | *.war 434 | 435 | Test 436 | QA Testing (VM) 437 | Install Web Application Servers (Tomcat{8080}/Nginx{80}) 438 | 439 | UAT Testing 440 | Install Web Application Servers (Tomcat{8080}/Nginx{80}) =============> Prod Servers 441 | 442 | 443 | 444 | Purpose :: 445 | 446 | Jenkins_Master (VM) ==> To Create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 447 | Jenkins_SlaveNode (VM) ==> To Perform Application Build & Unit Testing and create application artifacts 448 | 449 | Tomcat_Server (VM) ==> To Run the Web-Application for further Testing 450 | 451 | 452 | Required Tools :: 453 | 454 | Jenkins_Master (VM) ==> jdk,jenkins,git 455 | Jenkins_SlaveNode (VM) ==> git,jdk,maven 456 | 457 | Tomcat_Server (VM) ==> jdk,tomcat #https://tomcat.apache.org/download-80.cgi 458 | 459 | 460 | Workflow/Integration of Jenkins_Master, Jenkins_SlaveNode1 and Tomcat_Server 461 | 462 | 463 | 464 | 465 | Jenkins_Master (VM) ==> jdk,jenkins,git 466 | Jenkins_SlaveNode (VM) ==> git,jdk,maven 467 | 468 | Tomcat_Server (VM) ==> jdk,tomcat 469 | 470 | Jenkins_Master acts as Controller : 471 | - It used to create Jenkins CI/CD Pipeline Projects and schedule to the builds in the slave_nodes 472 | - It copy the artifacts from the slave node to the target server 473 | 474 | 475 | Use Publish Over SSH Plugins on Jenkins Master to attach the Tomcat_Server to Jenkins_Master 476 | 477 | Publish Over SSH Plugins - is used to connect to remote server and copy the artifacts 478 | 479 | Configure the required Connection Parameters to attach the Tomcat Server in Jenkins Master 480 | 481 | 482 | What is Deployment ? 483 | 484 | --> Deployment is a process of copy the application artifacts from the source machine to the target machine. 485 | 486 | 487 | Source Machine ============> Target Machine 488 | 489 | Jenkins_SlaveNode Tomcat_Server 490 | 491 | 492 | Source PATH : Target PATH : 493 | 494 | /target/*.war opt/tomcat/webapps 495 | 496 | Upon Deployment:: 497 | 498 | /target/*.war --------------> opt/tomcat/webapps/*.war 499 | opt/tomcat/webapps/target/*.war 500 | 501 | 502 | pipeline { 503 | agent { label 'slave1' } 504 | 505 | stages { 506 | stage('SCM_Checkout') { 507 | steps { 508 | echo 'Perform SCM Checkout' 509 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 510 | } 511 | } 512 | stage('Application Build') { 513 | steps { 514 | echo 'Perform Application Build' 515 | sh 'mvn clean package' 516 | } 517 | } 518 | stage('Deploy to Test Environment') { 519 | steps { 520 | script{ 521 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Tomcat_Server', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: 'target/', sourceFiles: 'target/*.war')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 522 | } 523 | } 524 | } 525 | } 526 | } 527 | 528 | 529 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Tomcat_Server', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: 'target/', sourceFiles: 'target/*.war')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 530 | 531 | 532 | 533 | Email Notifications ::::::: 534 | 535 | In Jenkins Pipeline Jobs, Email Notifications can be done as a post build action. 536 | 537 | 538 | Stage{} 539 | post{ 540 | success 541 | failure 542 | abort 543 | } 544 | 545 | To Setup the Email Notifications, First we need to set the Email Server in the Jenkins System configuration : 546 | 547 | 548 | How to setup the Email Server in the Jenkins Config: 549 | 550 | goto manage jenkins -> system configuration 551 | 552 | goto Email Notification 553 | 554 | SMTP Server : 555 | smtp.gmail.com 556 | 557 | SMTP Authentication 558 | 559 | SMTP Port :: 465 560 | 561 | Login to Gmail ::: 562 | 563 | Click Manage Account Settings 564 | 565 | @Left side panel - select Security 566 | 567 | MFA --> mobile# 568 | 569 | App Password = 16 bytes of App Password. vazr vauf xhd bnl l 570 | 571 | What ? window 572 | Which Appln - email 573 | 574 | 575 | pipeline { 576 | agent { label 'slave1' } 577 | 578 | stages { 579 | stage('SCM Checkout') { 580 | steps { 581 | echo 'Perfomr SCM Check-Out' 582 | echo 'Cloning Java Maven App Code' 583 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 584 | } 585 | post { 586 | failure { 587 | sh "echo 'Send mail on failure'" 588 | mail bcc: 'l@gmail.com', body: 'Jenkins Jobs Status ', cc: 'l@gmail.com', from: '', replyTo: '', subject: 'SCM-Checkout Failed ', to: 'l@gmail.com' 589 | 590 | 591 | } 592 | } 593 | } 594 | stage('Java Application Build') { 595 | steps { 596 | echo 'Perform Java Maven Application Build' 597 | sh 'mvn clean package' 598 | } 599 | post { 600 | failure { 601 | sh "echo 'Send mail on failure'" 602 | mail bcc: 'l@gmail.com', body: 'Jenkins Jobs Status ', cc: 'l@gmail.com', from: '', replyTo: '', subject: 'App Build Failed ', to: 'l@gmail.com' 603 | } 604 | } 605 | } 606 | stage('Deploy to Tomcat_Server') { 607 | steps { 608 | script { 609 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA-Tomcat_Server', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: 'target/', sourceFiles: 'target/mvn-hello-world.war')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 610 | } 611 | 612 | } 613 | post { 614 | failure { 615 | sh "echo 'Send mail on failure'" 616 | mail bcc: 'l@gmail.com', body: 'Jenkins Jobs Status ', cc: 'l@gmail.com', from: '', replyTo: '', subject: 'App Deployment Failed ', to: 'l@gmail.com' 617 | } 618 | success { 619 | sh "echo 'Send mail on Successful'" 620 | mail bcc: 'l@gmail.com', body: "jenkins-${JOB_NAME}-${BUILD_NUMBER}", cc: 'l@gmail.com', from: '', replyTo: '', subject: 'App Deployment Successful ', to: 'l@gmail.com' 621 | } 622 | } 623 | } 624 | } 625 | } 626 | 627 | 628 | -------------------------------------------------------------------------------- /Jenkins/Jenkins_Installation_Configuration.txt: -------------------------------------------------------------------------------- 1 | Install & Configure Jenkins Server : 2 | 3 | - Refer to that tools/Service's Official Documentation. 4 | https://www.jenkins.io/doc/book/installing/linux/ 5 | 6 | Launch AWS EC2 Instance - AMI - Ubuntu 20.04v 7 | t2.medium/t2.micro - Instance Type 8 | 9 | #Allow All Traffic for Demo! 10 | 11 | Updated Inbound Rule - Port 8080 12 | 13 | 1. Install the pre-requisites ::: 14 | 15 | # Install Jdk: 16 | 17 | sudo -i 18 | sudo apt update -y 19 | sudo apt install openjdk-17-jre -y # previous version 20 | java -version 21 | 22 | 2. Install the Actual tool ::: 23 | 24 | #Install Jenkins: 25 | 26 | sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ 27 | https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key 28 | 29 | echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ 30 | https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ 31 | /etc/apt/sources.list.d/jenkins.list > /dev/null 32 | 33 | sudo apt-get update 34 | 35 | sudo apt-get install jenkins -y 36 | 37 | 38 | 39 | 3. Perform Post_Installation Activities ::: 40 | 41 | jenkins --version 42 | 43 | systemctl status jenkins 44 | systemctl stop jenkins 45 | systemctl start jenkins 46 | systemctl restart jenkins 47 | systemctl enable jenkins 48 | 49 | /var/lib/jenkins # Default Installation Dir of Jenkin on Linux Box 50 | 51 | Open web browser : 52 | 53 | http://:8080/ 54 | 55 | E.g.: http://13.127.8.53:8080/ 56 | 57 | cat /var/lib/jenkins/secrets/initialAdminPassword 58 | 59 | 60 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`` 61 | #Configure Slave Node1 for Java Maven App. : 62 | 63 | Launch an Ubuntu Machine : v22.04 64 | 65 | sudo -i 66 | 67 | apt update -y 68 | 69 | Install Java :: 70 | 71 | sudo apt update -y 72 | sudo apt install openjdk-17-jre -y 73 | java -version 74 | 75 | Install GIT : 76 | 77 | sudo apt install git -y 78 | 79 | Install Maven - Build Tool : 80 | https://maven.apache.org/install.html 81 | 82 | sudo apt install maven -y 83 | 84 | Create User in Jenkins Slave Machine & Create SSH Keys 85 | 86 | SSH Keys --> is composed of public and private keys 87 | 88 | #Add User : 89 | 90 | useradd devopsadmin -s /bin/bash -m -d /home/devopsadmin 91 | 92 | su - devopsadmin 93 | 94 | #ssh-keygen 95 | 96 | #for Ubuntu :: 97 | #ssh-keygen -t rsa -b 2048 -m PEM #ubuntu 20.04 98 | 99 | ssh-keygen -t ecdsa -b 521 #ubuntu 22.04 or higher version of ubuntu 100 | 101 | 102 | ls ~/.ssh 103 | 104 | #You should see following two files: 105 | 106 | #id_ecdsa - private key 107 | #id_ecdsa.pub - public 108 | 109 | 110 | #cat id_rsa.pub > authorized_keys 111 | 112 | cat id_ecdsa.pub > authorized_keys 113 | 114 | chmod 600 /home/devopsadmin/.ssh/* 115 | 116 | 117 | 118 | Login to Jenkins - Manage Jenkins - Attach the Slave Node to jenkins Master 119 | 120 | Goto to Manage Jenkins 121 | Select Nodes 122 | On Nodes Dashboard, Click on New Node 123 | Give Node Name, and choose permanent agent. 124 | 125 | 126 | ##################################################################################################### 127 | #####################Install TOMCAT Application Server on Ubuntu ::: 128 | 129 | Launch New Node - Ubuntu - 22.04 ami 130 | 131 | Enable port 8080 132 | 133 | Install Tomcat :: https://tomcat.apache.org/download-80.cgi 134 | 135 | 136 | sudo -i 137 | apt update -y 138 | apt-get install default-jdk -y 139 | java --version 140 | cd /opt/ 141 | wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.99/bin/apache-tomcat-8.5.99.tar.gz 142 | tar -xvzf /opt/apache-tomcat-8.5.99.tar.gz 143 | mv apache-tomcat-8.5.99 tomcat 144 | cd tomcat/bin/ 145 | ./startup.sh # Used to Start the Tomcat Server 146 | 147 | 148 | 149 | 150 | Open web browser : 151 | 152 | http://:8080/ 153 | 154 | E.g.: http://13.127.8.53:8080/ 155 | 156 | 157 | ########################################### 158 | 159 | #Add User : 160 | 161 | useradd devopsadmin -s /bin/bash -m -d /home/devopsadmin 162 | 163 | su - devopsadmin 164 | 165 | 166 | #ssh-keygen 167 | 168 | #for Ubuntu :: 169 | #ssh-keygen -t rsa -b 2048 -m PEM #ubuntu 20.04 170 | 171 | ssh-keygen -t ecdsa -b 521 #ubuntu 22.04 or higher version of ubuntu 172 | 173 | 174 | ls ~/.ssh 175 | 176 | #You should see following two files: 177 | 178 | #id_ecdsa - private key 179 | #id_ecdsa.pub - public 180 | 181 | 182 | #cat id_rsa.pub > authorized_keys 183 | 184 | cat id_ecdsa.pub > authorized_keys 185 | 186 | chmod 600 /home/devopsadmin/.ssh/* 187 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | #make devopsadmin user as a owner to tomcat dir : 189 | 190 | chown -R devopsadmin /opt/tomcat 191 | 192 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 193 | -------------------------------------------------------------------------------- /Kubernetes/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ####################### 3 | Day 36: 20th Sep. 2024 4 | ####################### 5 | 6 | Kubernetes :::: 7 | 8 | Environments 9 | 10 | Non-Prod-Environments Prod-Environment 11 | 12 | DEV 13 | 14 | BUILD 15 | 16 | QA ==> docker pull/run 17 | 18 | UAT ==> docker pull/run =========> PROD_Server1 ==> docker pull/run --> LIVE Server! 19 | PROD_Server2 ==> docker pull/run 20 | PROD_Server3 ==> docker pull/run 21 | PROD_Server4 ==> docker pull/run 22 | PROD_Server5 ==> docker pull/run 23 | 24 | 25 | Kubernetes :::: 26 | 27 | - It is a Open-Source Container Orchestration Tool 28 | - Kubernetes is used to Deploy any type of Containers. 29 | - It is used to ensure high availability of the Applications/services running thru Containers. 30 | - Used to Ensure High Availability of Containers by creating Replicas of Containers. 31 | - It supports Auto-Scaling & Load Balancing. 32 | - Self-Healing 33 | 34 | 35 | Kubernetes Architecture ::: 36 | 37 | - Client/Server Architecture 38 | 39 | 40 | Kubernetes_Master # Used to Create and Schedule the Deployments to Kubernetes_WorkNodes 41 | 42 | Kubernetes_WorkNode1 # Target Servers 43 | Kubernetes_WorkNode2 44 | Kubernetes_WorkNode3 45 | Kubernetes_WorkNode4 46 | Kubernetes_WorkNode5 47 | 48 | 49 | Kubernetes Architecture 50 | Kubernetes_Master # Used to Create and Schedule the Deployments to Kubernetes_WorkNodes 51 | 52 | Kubernetes_WorkNode1 # Target Servers 53 | Kubernetes_WorkNode2 54 | Kubernetes_WorkNode3 55 | 56 | 57 | 58 | Kubernetes Components :::: 59 | 60 | API_Server --> # Acts as an interface to the kubernetes 61 | 62 | ETCD --> # Single point of Source for Kubernetes Components 63 | 64 | Scheduler --> # To identify the Healthy Node for Deployments 65 | 66 | Controller Manager --> # To run the pods in its desired state 67 | 68 | 69 | Kubelet --> # Is a Kubernetes Agent used to Create & Deploy the Pods 70 | 71 | KubeProxy --> # Is used to enable pod networking by create Pod IP Address 72 | 73 | CRI - Container RunTime Interface (Container-D) 74 | --> # It is used identify the Image from Container Registry for deployment 75 | 76 | 77 | 78 | Kubernetes Concepts / Terminologies :::: 79 | 80 | 81 | Kubernetes_Master # Used to Create and Schedule the Deployments to Kubernetes_WorkNodes 82 | 83 | Kubernetes_WorkNodes # Target Servers 84 | 85 | Kubectl # Is Command Line Utility, used to interact with Kubernetes Master 86 | 87 | Container Images 88 | -- Is a Static file that defined the properties of the Container and its dependencies 89 | -- Container Images are Non-Executables 90 | -- Container Images are composed of various Layers created using the Dockerfile Instructions 91 | 92 | Containers 93 | -- Containers are the executable units of Container Images 94 | -- Containers are used to run the applications defined in the Container Images 95 | 96 | Container Registry 97 | -- It is used to save and version control the Container Images 98 | Dockerhub is Container Registry to be used. 99 | https://hub.docker.com/ 100 | 101 | Container Repositories 102 | -- Container Repositories are the subset of Container Registry 103 | 104 | 105 | Pod # Is Atomic Unit of Schedule - Any Smalled Task you run in Kubernetes is executed as Pod. 106 | # Used to Run the Container(s) 107 | # As a best practise, it is recommended to have One Container in a Pod. 108 | 109 | Kubelet # Is a Kubernetes Agent used to Create & Deploy the Pods 110 | 111 | CRI # Container Run-Time Interface - "Container-D" 112 | # It is used identify the Image from Container Registry for deployment 113 | 114 | 115 | Manifest File # Is a AppConfig file, that defines the properties of the pods to be deployed in kubernetes 116 | # It is written using *.yaml/*.json format by the developers and maintained in the Source Code Repositories during CICD Pipeline Automation Process 117 | 118 | 119 | Cluster # Is collection of WorkerNodes 120 | 121 | 122 | Kubernetes_Master 123 | 124 | Kubernetes_Cluster 125 | Kubernetes_WorkNode1 126 | Kubernetes_WorkNode2 127 | Kubernetes_WorkNode3 128 | 129 | Kubernetes_Master 130 | 131 | Kubernetes_Cluster1 132 | Kubernetes_WorkNode1 133 | Kubernetes_WorkNode2 134 | Kubernetes_WorkNode3 135 | 136 | Kubernetes_Cluster2 137 | Kubernetes_WorkNode1 138 | Kubernetes_WorkNode2 139 | Kubernetes_WorkNode3 140 | 141 | Kubernetes_Master 142 | Kubernetes_Master1 143 | 144 | Kubernetes_Cluster1 145 | Kubernetes_WorkNode1 146 | Kubernetes_WorkNode2 147 | Kubernetes_WorkNode3 148 | 149 | Kubernetes_Cluster2 150 | Kubernetes_WorkNode1 151 | Kubernetes_WorkNode2 152 | Kubernetes_WorkNode3 153 | 154 | Kubernetes_Master2 155 | 156 | Kubernetes_Cluster1 157 | Kubernetes_WorkNode1 158 | Kubernetes_WorkNode2 159 | Kubernetes_WorkNode3 160 | 161 | Kubernetes_Cluster2 162 | Kubernetes_WorkNode1 163 | Kubernetes_WorkNode2 164 | Kubernetes_WorkNode3 165 | 166 | 167 | Core Kubernetes Concepts ::: 168 | 169 | Pods 170 | 171 | Kubectl 172 | 173 | Syntax: 174 | 175 | kubectl 176 | 177 | kubectl get pods mypod1 -o wide 178 | 179 | kubectl get Deployment mydeploy 180 | 181 | Eg.: Kubectl Commands : 182 | 183 | create / get / exec / expose / describe 184 | 185 | 186 | Controller Object 187 | ReplicaSet 188 | Deployment 189 | 190 | Services 191 | NodePort Service 192 | ClusterIP 193 | LoadBalancer 194 | 195 | Volumes 196 | HostPath Volumes 197 | 198 | Namespaces 199 | 200 | 201 | Next :: 202 | 203 | Installation & Configuration of Kubernetes_Master & Kubernetes_WorkNodes 204 | 205 | Working with Kubernetes Objects / Concepts 206 | 207 | 208 | ####################### 209 | Day 37: 23rd Sep. 2024 210 | ####################### 211 | 212 | 213 | Installation & Configuration of Kubernetes_Master & Kubernetes_WorkNodes 214 | 215 | Managed Services : - Paid Service! 216 | 217 | AWS - ECS/ECR/EKS 218 | 219 | Azure - ACS/ACR/AKS 220 | 221 | GCP - GCR/GKE 222 | 223 | 224 | Open-Source Kubernetes ::: 225 | 226 | https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/ 227 | 228 | 229 | Kubernetes_Master (VM) 230 | Kubernetes_WorkNode1 (VM) 231 | Kubernetes_WorkNode2 (VM) 232 | 233 | 234 | Minikube --> 1 Node Configuration 235 | VM -> 236 | 237 | Kubeadm --> 238 | 239 | 240 | Installation of Kubernetes using Kubeadm ::: 241 | 242 | 1. Launch 3 VMs on AWS Cloud (Ubuntu v22.04) --> (1 Master Node, 2 WorkerNodes) 243 | 244 | In all the Nodes(i.e., Master Node and WorkerNodes): 245 | 246 | 2. Allow all traffic for all the nodes - just for this demo 247 | 3. Change the HostName of all the Nodes 248 | 4. Disable swap configuration in all the nodes 249 | 5. Install Docker in all the nodes 250 | 6. Install CRI - 'Container-D' in all the nodes 251 | 7. Install Kubeadm,kubelet,kubectl 252 | 8. Enable Kubelet 253 | 254 | Only on Master Node: 255 | 256 | 9. Execute Kubeadm Init Command # To initialize Kubernetes Master Node 257 | 10. Enable user Access to Kubernetes 258 | 11. Install flannel Network plugins for kubeproxy 259 | 260 | Only on WorkerNodes: 261 | 262 | 12. Execute Kubeadm Join Command # To attach the Worknodes with Kubernetes Master Node. 263 | 264 | kubeadm join 172.31.8.101:6443 --token 7nd74g.qf0o7ntrb9im3hqr \ 265 | --discovery-token-ca-cert-hash sha256:20a690f48ba814666bf93da0a3460e53b46992e339a515bc2dd4f4a1bbf5d4b1 266 | 267 | 268 | Deploy a new pod in Kubernetes cluster ::: 269 | 270 | 1. Write a manifest file - save as *.yaml 271 | 272 | - Yaml files are based on key:value pairs 273 | 274 | 2. Use kubectl command to create/deploy the pod using the manifest file 275 | 276 | 277 | 278 | 279 | How to install and configure kubernetes Master and workernodes 280 | 281 | Write a manifest file to create a pod 282 | 283 | Using kubectl to create a pod 284 | 285 | get/describe/login 286 | 287 | expose pod using nodeport services 288 | 289 | access the application running inside the pod using web browser 290 | 291 | delete pod and svc 292 | 293 | 294 | Next :: 295 | 296 | Controller Object 297 | ReplicaSet 298 | Deployment 299 | 300 | Services 301 | NodePort Service 302 | ClusterIP 303 | LoadBalancer 304 | 305 | Volumes 306 | HostPath Volumes 307 | 308 | Namespaces 309 | 310 | 311 | 312 | ####################### 313 | Day 38: 25th Sep. 2024 314 | ####################### 315 | 316 | Controller Object ::: 317 | ReplicaSet 318 | Deployment 319 | 320 | 321 | ReplicaSet ::: 322 | 323 | --> Replicaset is used to execute the specific no. of pods in the cluster. 324 | --> Replicaset uses the Set Based Operator 325 | --> Used to replicate the pods and able to scale up/down 326 | --> The Replicasets will be automatically created, while creating Deployment Controller Object. 327 | 328 | Deployment Controller Object ::: 329 | 330 | --> It is used to deploy the pods and ensure high availability of pods by creating pod replicas 331 | --> 1. Create Muliple instance/replicas/copies of pods 332 | 2. Used to Scale-Up / Scale-Down the Pods 333 | 3. Used to Upgrade the application pods 334 | 4. Used to Down-grade/roll-back the application pods 335 | --> The upgrade/down-grade of application pods can be done without any downtime. 336 | --> To achieve zero-downtime during upgrade/down-grade, By Default, it used Rolling-Update Deployment Strategy. 337 | 338 | UseCase ::: 339 | 340 | - Deploy 3 instance pod using Deployment Controller Object --> Nginx_previous_version 341 | - 342 | 343 | 344 | Output :: 345 | 346 | - Deployment Object 347 | 348 | - Replicaset 349 | 350 | - Pods 351 | 352 | 353 | Web Application ::: 354 | 355 | Launched a Website! 356 | 357 | --> 3 instances of pod to deploy this application 358 | 359 | 100 Users can access my application 360 | 361 | 1000 ++++ 362 | 2000 ++++ 363 | 364 | 365 | Scale-up the pod instances ! 366 | Scale-down the pod instances ! 367 | 368 | ####################### 369 | Day 39: 26th Sep. 2024 370 | ####################### 371 | 372 | Deployment Controller Object ::: 373 | 374 | --> It is used to deploy the pods and ensure high availability of pods by creating pod replicas 375 | --> 1. Create Muliple instance/replicas/copies of pods 376 | 2. Used to Scale-Up / Scale-Down the Pods 377 | 3. Used to Upgrade the application pods 378 | 4. Used to Down-grade/roll-back the application pods 379 | --> The upgrade/down-grade of application pods can be done without any downtime. 380 | --> To achieve zero-downtime during upgrade/down-grade, By Default, it used Rolling-Update Deployment Strategy. 381 | 382 | 383 | 384 | - Upgrade the application pods 385 | - Down-grade/roll-back the application pods 386 | 387 | 388 | What is the need for Kubectl describe Command ??? 389 | 390 | - Kubectl Describe Command is used to capture the complete information about the kubenetes objects 391 | - Kubectl Describe Command provides the complete list of events based on the kubernetes object. 392 | - Kubectl Describe Command is used to diagonize/debug/analyze the kubernetes objects 393 | 394 | 395 | 396 | Developer created --> webappimg:v1.0 ==> Publish to container Registry ==> Deployed to kubernetes 397 | Developer created --> webappimg:v2.0 ==> Publish to container Registry ==> Deployed to kubernetes 398 | 399 | 400 | Deployment Strategy ::: 401 | 402 | nginx-deploy ---> nginx:stable-otel(v1.0) # Current version of Application Image 403 | 404 | pod1 ---> nginx:stable-otel(v1.0) # Current version of Application Image 405 | pod2 ---> nginx:stable-otel(v1.0) # Current version of Application Image 406 | pod3 ---> nginx:stable-otel(v1.0) # Current version of Application Image 407 | 408 | 409 | 410 | 411 | Upgrade the Application Image from nginx:stable-otel(v1.0) to nginx:stable-pearl(v2.0) 412 | 413 | nginx-deploy ---> nginx:stable-pearl(v2.0) # Current version of Application Image 414 | 415 | pod1 ---> nginx:stable-pearl(v2.0) # Current version of Application Image 416 | pod2 ---> nginx:stable-pearl(v2.0) # Current version of Application Image 417 | pod3 ---> nginx:stable-pearl(v2.0) # Current version of Application Image 418 | 419 | 420 | --> To achieve zero-downtime during upgrade/down-grade, By Default, it used Rolling-Update Deployment Strategy. 421 | 422 | During the Upgrade, if anything goes wrong, we can quickly roll-back to previous version 423 | 424 | 425 | First will see how to deploy any new version of image, for roll-back 426 | 427 | 428 | roll-back - When will go for roll-back ??? 429 | 430 | Whenever the deployment fails, will go for roll-back/undo the changes 431 | 432 | when pod is not running as expected 433 | when we need to use previous version 434 | 435 | 436 | 437 | Kubernetes Services ::: 438 | 439 | Services are used to enable the communication to the pods ::: 440 | 441 | 442 | - Cluster-IP Service: 443 | - It is used to enable the communication between the pods within the cluster 444 | 445 | - Node-Port Service 446 | - It is used to expose the pods to internet 447 | - Uses the port range : 30000 to 32767 448 | 449 | - Load Balancer Service 450 | 451 | - Is used to reduce the number of IPs address to be maintained for NodePort Service. 452 | 453 | - Load Balancer Service Created on top of the NodePort Service, will receives the request from end user thru internet and Route the request the corresponding nodeport service and access the pod within that. 454 | 455 | 456 | 3-tier application : 457 | 458 | - Front-End 459 | 460 | - Application-Layer 461 | 462 | - Data-Base Layer 463 | 464 | 465 | Next ::: 466 | 467 | Volume - Kubernetes Hostpath Volume 468 | 469 | Kubernetes Namespaces 470 | 471 | Demo : Using this Deployment controller Object and Service : using jenkins. 472 | 473 | 474 | apiVersion: apps/v1 475 | kind: Deployment 476 | metadata: 477 | name: loksai-eta-deploy 478 | labels: 479 | app: loksai-eta-deploy-lbl 480 | spec: 481 | replicas: 3 482 | selector: 483 | matchLabels: 484 | app: loksai-eta-app 485 | template: 486 | metadata: 487 | labels: 488 | app: loksai-eta-app 489 | spec: 490 | containers: 491 | - name: loksai-eta-container 492 | image: loksaieta/loksai-eta-app 493 | ports: 494 | - containerPort: 8080 495 | --- 496 | apiVersion: v1 497 | kind: Service 498 | metadata: 499 | name: loksai-eta-np-service 500 | labels: 501 | app: loksai-eta-app 502 | spec: 503 | selector: 504 | app: loksai-eta-deploy-lbl 505 | 506 | type: NodePort 507 | ports: 508 | - nodePort: 31028 509 | port: 8080 510 | targetPort: 8080 511 | 512 | 513 | 514 | ####################### 515 | Day 40: 27th Sep. 2024 516 | ####################### 517 | 518 | Kubenetes Namespaces ::: 519 | 520 | Kubernetes Volumes ::: 521 | 522 | Kubernetes Integration with Jenkins - Demo 523 | 524 | 525 | - Kubernetes Volumes ::: 526 | 527 | Persistant Volumes :: 528 | 529 | --> Is used to maintain the persistant data. 530 | 531 | Hostpath Volume ::: 532 | 533 | - Same as Docker Volume. 534 | 535 | - Difference is hostpath volume is created at the pod level not at the container level. 536 | 537 | - Used to pass the input files to pods and restore the output from pods. 538 | 539 | 540 | 541 | - Kubernetes Namespace ::: 542 | 543 | - Is the Logical Partition of Kubernetes Cluster 544 | 545 | 546 | Environments: 547 | 548 | Dev 549 | 550 | QA 551 | 552 | UAT 553 | 554 | Prod 555 | 556 | kubectl create namespace dev # Create Namespace 557 | 558 | vi nginx-devpod.yaml 559 | 560 | apiVersion: v1 561 | kind: Pod 562 | metadata: 563 | name: nginx-pod 564 | namespace: appteam2 565 | labels: 566 | app: nginx 567 | tier: dev 568 | spec: 569 | containers: 570 | - name: nginx-container 571 | image: nginx 572 | 573 | ports: 574 | - containerPort: 80 575 | 576 | kubectl create -f nginx-devpod.yaml 577 | 578 | kubectl get pods --namespace=dev 579 | 580 | kubectl get pods --all-namespaces 581 | 582 | kubectl delete pod nginx-pod --namespace=dev # Used to delete the pod created in this namespace 583 | 584 | Note: During real-Project Discussion, will show how to use kubernetes namespaces 585 | 586 | 587 | 588 | Kubernetes Integration with Jenkins - Demo :::: 589 | 590 | Project: 591 | 592 | 593 | apiVersion: apps/v1 594 | kind: Deployment 595 | metadata: 596 | name: loksai-eta-deploy 597 | labels: 598 | app: loksai-eta-deploy-lbl 599 | spec: 600 | replicas: 3 601 | selector: 602 | matchLabels: 603 | app: loksai-eta-app 604 | template: 605 | metadata: 606 | labels: 607 | app: loksai-eta-app 608 | spec: 609 | containers: 610 | - name: loksai-eta-container 611 | image: loksaieta/sa-wd-webapp 612 | ports: 613 | - containerPort: 8080 614 | --- 615 | apiVersion: v1 616 | kind: Service 617 | metadata: 618 | name: loksai-eta-np-service 619 | labels: 620 | app: loksai-eta-app 621 | spec: 622 | selector: 623 | app: loksai-eta-deploy-lbl 624 | 625 | type: NodePort 626 | ports: 627 | - nodePort: 31028 628 | port: 8080 629 | targetPort: 8080 630 | 631 | 632 | How to implement this using Jenkins CICD Pipeline : 633 | 634 | 635 | 636 | Objective ::: 637 | 638 | Jenkins pipeline, perform application build, create container images, Publish application image to Container registry and deploy to kubernetes cluster 639 | 640 | 641 | Resources - Servers/Tools Needed : 642 | 643 | 644 | Servers ::: 645 | 646 | Jenkins_Master --> # To create CICD Pipeline Jobs and schedule it to run in Slave Nodes 647 | 648 | Build_Server-Jenkins_Slave --> # Compile the Source Code 649 | (Perform Application Build and Docker Build) # Perform Unit Testing 650 | # Create Artifacts 651 | # Create Application Image 652 | # Publish Application Image to DockerHub Registry 653 | 654 | Kubernetes_Master --> Schedule Pod Deployments 655 | Kubernetes_WorkNode1 --> Execute the Pods 656 | Kubernetes_WorkNode2 --> Execute the Pods 657 | 658 | 659 | Tools :::: 660 | 661 | Jenkins_Master ---> # jdk, jenkins, git 662 | Build_Server-Jenkins_Slave ---> # git, jdk, maven, docker 663 | Kubernetes_Master ---> # All Kubernetes Components 664 | Kubernetes_WorkNode1 665 | Kubernetes_WorkNode2 666 | 667 | Maintain DockerHub Credentials in the Jenkins Credential Manager 668 | goto jenkins dashboard 669 | -- Manage Jenkins 670 | -- Credential 671 | -- using dockerhub username and access token 672 | 673 | 674 | 675 | Integration of Kubernetes Master Node with Jenkins Master Node. 676 | 677 | - Using Publish over ssh plugins, integrate Kubernetes_Master Node to Jenkins Master Node 678 | - And Execute kubectl create command using Publish over ssh plugins 679 | 680 | --> 1. Create a devopsadmin - User in Kubernetes_Master 681 | --> 2. Create SSH Keys to devopsadmin - User 682 | --> 3. Ensure that devopsadmin - User have access to execute kubectl commands 683 | --> 4. Use, the Kubernetes - Master Node's - Private IP Address,User_Name and Credential to config in Jenkins - Publish Over SSH 684 | --> 5. Create a Pipeline Deployment Stage using Publish Over SSH Plugins step 685 | - To copy the kubernetes manifest file - *.yaml file from jenkins_Slave Node to Kubernetes Master Node. 686 | - To execute a command : kubectl create -f kdeploy.yaml 687 | 688 | 689 | kubectl create -f kdeploy.yaml # Used to create a new kubernetes object 690 | 691 | kubectl apply -f kdeploy.yaml # Used to create/replace a kubernetes object 692 | 693 | 694 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Kubernetes_Master', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'kubectl apply -f kubedeploy.yaml', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.yaml')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 695 | 696 | 697 | pipeline { 698 | agent { label 'slave1' } 699 | 700 | environment { 701 | DOCKERHUB_CREDENTIALS=credentials('dockerloginid') 702 | } 703 | 704 | stages { 705 | stage('SCM_Checkout') { 706 | steps { 707 | echo 'Perform SCM Checkout' 708 | git 'https://github.com/SA-AWS-DevOps-July24/java-mvn-springbootapp.git' 709 | } 710 | } 711 | stage('Application Build') { 712 | steps { 713 | echo 'Perform Application Build' 714 | sh 'mvn clean package' 715 | } 716 | } 717 | stage('Docker Build') { 718 | steps { 719 | echo 'Perform Docker Build' 720 | sh "docker build -t loksaieta/sa-wd-webapp:${BUILD_NUMBER} ." 721 | sh "docker tag loksaieta/sa-wd-webapp:${BUILD_NUMBER} loksaieta/sa-wd-webapp:latest" 722 | sh 'docker image list' 723 | } 724 | } 725 | stage('Login to Dockerhub') { 726 | steps { 727 | echo 'Login to DockerHub' 728 | sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' 729 | 730 | } 731 | } 732 | stage('Publish the Image to Dockerhub') { 733 | steps { 734 | echo 'Publish to DockerHub' 735 | sh "docker push loksaieta/sa-wd-webapp:latest" 736 | } 737 | } 738 | stage('Deploy to Kubernetes Cluster') { 739 | steps { 740 | script { 741 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Kubernetes_Master', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'kubectl apply -f kubedeploy.yaml', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.yaml')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 742 | } 743 | } 744 | } 745 | } 746 | } 747 | 748 | -------------------------------------------------------------------------------- /Kubernetes/Hostpath_Volume.txt: -------------------------------------------------------------------------------- 1 | 2 | ******************************************************************* 3 | ******************************************************************* 4 | 5 | # 1. HostPath YAML file 6 | 7 | apiVersion: v1 8 | kind: Pod 9 | metadata: 10 | name: nginx-hostpath 11 | spec: 12 | containers: 13 | - name: nginx-container 14 | image: nginx 15 | volumeMounts: 16 | - mountPath: /test-mnt 17 | name: test-vol 18 | volumes: 19 | - name: test-vol 20 | hostPath: 21 | path: /test-vol 22 | 23 | 24 | ******************************************************************* 25 | # 2. Create and Display HostPath 26 | 27 | kubectl create -f nginx-hostpath.yaml 28 | kubectl get po 29 | kubectl exec nginx-hostpath df /test-mnt 30 | 31 | ******************************************************************* 32 | 3. Test: Creating "test" file underlying host dir & accessing from from pod 33 | 34 | From HOST: 35 | ~~~~~~~~~~ 36 | cd /test-vol 37 | echo "From Host" > from-host.txt 38 | cat from-host.txt 39 | 40 | From POD: 41 | ~~~~~~~~ 42 | kubectl exec nginx-hostpath cat /test-mnt/from-host.txt 43 | 44 | 45 | ******************************************************************* 46 | 4. Test: Creating "test" file inside the POD & accessing from underlying host dir 47 | 48 | From POD: 49 | ~~~~~~~~~ 50 | kubectl exec nginx-hostpath -it bash 51 | cd /test-mnt 52 | echo "From Pod" > from-pod.txt 53 | cat from-pod.txt 54 | 55 | From Host: 56 | ~~~~~~~~~~ 57 | cd /test-vol 58 | ls 59 | cat from-pod.txt 60 | 61 | 62 | ******************************************************************* 63 | 5. Clean up 64 | 65 | kubectl delete po nginx-hostpath 66 | kubectl get po 67 | ls /test-vol 68 | 69 | 70 | ******************************************************************* 71 | -------------------------------------------------------------------------------- /Kubernetes/Kubernetes_Installation_Config.txt: -------------------------------------------------------------------------------- 1 | ############################################################################################################ 2 | 3 | #Kube-Master(Controller) - VM # Ubuntu v22.04 4 | # Kube-Worker1 5 | # Kube-Worker2 6 | 7 | #https://kubernetes.io/docs/setup/ 8 | #https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ 9 | 10 | #Add Port: 0 - 65535 11 | 12 | #Allow All Traffic for Demo! 13 | 14 | #Master Nodes : 15 | #### 6443, 2379-2380, 10250, 10259, 10257 16 | 17 | Worker Nodes : 18 | #### 10250, 30000-32767(NodePort Range) 19 | 20 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 | ###On Both Master and Worker Nodes: 22 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 | 24 | sudo -i 25 | 26 | apt update -y 27 | 28 | #Set the appropriate hostname for each machine. 29 | #----------------------------------------------- 30 | sudo hostnamectl set-hostname "kmaster-node" 31 | exec bash 32 | 33 | reboot 34 | 35 | sudo hostnamectl set-hostname "worker-node1" 36 | exec bash 37 | 38 | reboot 39 | 40 | sudo hostnamectl set-hostname "worker-node2" 41 | exec bash 42 | 43 | reboot 44 | 45 | 46 | #To allow kubelet to work properly, we need to disable swap on both machines. 47 | 48 | sudo swapoff -a 49 | sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab 50 | 51 | #Install Docker : 52 | 53 | apt install docker.io -y 54 | 55 | #Step 1. Install containerd Is a CRI 56 | #To install containerd, follow these steps on both VMs: 57 | 58 | #Load the br_netfilter module required for networking. 59 | 60 | sudo modprobe overlay 61 | sudo modprobe br_netfilter 62 | cat < 3m2s v1.24.2 262 | 263 | #Finally, to set the proper role for the worker node, run this command on the master node: 264 | 265 | #kubectl label node worker-node node-role.kubernetes.io/worker=worker 266 | 267 | #To verify that the role was set: 268 | 269 | kubectl get nodes 270 | 271 | #The output should show the worker node’s role as follows: 272 | 273 | NAME STATUS ROLES AGE VERSION 274 | master-node Ready control-plane,master 5m12s v1.24.1 275 | worker-node Ready worker 2m55s v1.24.1 276 | 277 | 278 | sudo kubeadm token create --print-join-command # To generate New Token along with Kubeadm Join Command. 279 | 280 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281 | ###Only in Worker Nodes: 282 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 283 | 284 | kubeadm join 172.31.8.101:6443 --token 7nd74g.qf0o7ntrb9im3hqr \ 285 | --discovery-token-ca-cert-hash sha256:20a690f48ba814666bf93da0a3460e53b46992e339a515bc2dd4f4a1bbf5d4b1 286 | 287 | 288 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 | 290 | 291 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292 | 293 | 294 | On Kubernetes Master Node :: 295 | 296 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 297 | 298 | 299 | #Add User : 300 | 301 | useradd devopsadmin -s /bin/bash -m -d /home/devopsadmin 302 | 303 | su - devopsadmin 304 | 305 | #ssh-keygen 306 | 307 | #for Ubuntu :: 308 | #ssh-keygen -t rsa -b 2048 -m PEM #ubuntu 20.04 309 | 310 | ssh-keygen -t ecdsa -b 521 #ubuntu 22.04 or higher version of ubuntu 311 | 312 | 313 | ls ~/.ssh 314 | 315 | #You should see following two files: 316 | 317 | #id_ecdsa - private key 318 | #id_ecdsa.pub - public 319 | 320 | 321 | #cat id_rsa.pub > authorized_keys 322 | 323 | cat id_ecdsa.pub > authorized_keys 324 | 325 | chmod 600 /home/devopsadmin/.ssh/* 326 | 327 | # Install Docker Engine in the Slave Node : 328 | apt install docker.io 329 | 330 | usermod -aG docker devopsadmin 331 | 332 | 333 | #As a root user edit below file: 334 | 335 | $ visudo 336 | 337 | #add the below mentioned line in the file and save it. 338 | 339 | devopsadmin ALL=(ALL) NOPASSWD: ALL 340 | 341 | mkdir -p $HOME/.kube 342 | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 343 | sudo chown $(id -u):$(id -g) $HOME/.kube/config 344 | 345 | ################################################################## 346 | -------------------------------------------------------------------------------- /Kubernetes/kube_deploy.txt: -------------------------------------------------------------------------------- 1 | # 1. Deployment YAML file 2 | 3 | 4 | # *.json 5 | 6 | # nginx-deploy.yaml 7 | apiVersion: apps/v1 8 | kind: Deployment 9 | metadata: 10 | name: nginx-deploy 11 | labels: 12 | app: nginx-deploy 13 | spec: 14 | replicas: 3 15 | template: 16 | metadata: 17 | labels: 18 | app: nginx-app 19 | spec: 20 | containers: 21 | - name: nginx-container 22 | image: nginx:stable-otel 23 | ports: 24 | - containerPort: 80 25 | selector: 26 | matchLabels: 27 | app: nginx-app 28 | 29 | ******************************************************************* 30 | # 2. Create and Display Deployment 31 | 32 | kubectl create -f nginx-deploy.yaml 33 | kubectl get deploy -l app=nginx-deploy 34 | kubectl get rs -l app=nginx-deploy 35 | kubectl get po -l app=nginx-app 36 | kubectl describe deploy nginx-deploy 37 | 38 | ******************************************************************* 39 | # 3. Testing: Rollback update 40 | 41 | kubectl set image deploy nginx-deploy nginx-container=nginx:stable-pearl 42 | kubectl rollout status deployment/nginx-deploy 43 | 44 | kubectl rollout undo deployment/nginx-deploy 45 | kubectl rollout status deployment/nginx-deploy 46 | kubectl describe deploy nginx-deploy | grep -i image 47 | 48 | ******************************************************************* 49 | # 4. Testing: Update Version of "nginx:stable-otel" to "nginx:stable-perl" 50 | 51 | kubectl set image deploy nginx-deploy nginx-container=nginx:stable-perl 52 | kubectl rollout status deployment/nginx-deploy 53 | kubectl get deploy 54 | 55 | ******************************************************************* 56 | # 5. Testing: Scale UP 57 | 58 | kubectl scale deployment nginx-deploy --replicas=5 59 | kubectl get deploy 60 | kubectl get po -o wide 61 | 62 | ******************************************************************* 63 | 64 | # 6. Testing: Scale DOWN 65 | 66 | kubectl scale deployment nginx-deploy --replicas=3 67 | kubectl get deploy 68 | kubectl get po -o wide 69 | 70 | ******************************************************************* 71 | 72 | ******************************************************************* 73 | 74 | # 7. Cleanup 75 | 76 | kubectl delete -f nginx-deploy.yaml 77 | kubectl get deploy 78 | kubectl get rs 79 | kubectl get po 80 | 81 | ******************************************************************* 82 | -------------------------------------------------------------------------------- /Kubernetes/pods.txt: -------------------------------------------------------------------------------- 1 | ******************************************************************* 2 | # 1. 3 | 4 | # nginx-pod.yaml 5 | apiVersion: v1 6 | kind: Pod 7 | metadata: 8 | name: nginx-pod 9 | labels: 10 | app: nginx 11 | tier: dev 12 | spec: 13 | containers: 14 | - name: nginx-container 15 | image: nginx 16 | 17 | ports: 18 | - containerPort: 80 19 | 20 | ******************************************************************* 21 | 22 | 2. Create and display Pods 23 | 24 | # Create and display PODs 25 | kubectl create -f nginx-pod.yaml 26 | kubectl get pod 27 | kubectl get pod -o wide 28 | kubectl get pod nginx-pod -o yaml 29 | kubectl describe pod nginx-pod 30 | 31 | 32 | ******************************************************************* 33 | 34 | 3. Test & Delete 35 | 36 | # To get inside the pod 37 | kubectl exec -it nginx-pod -- /bin/sh 38 | 39 | # Create test HTML page 40 | cat < /usr/share/nginx/html/test.html 41 | 42 | 43 | 44 | Testing.. 45 | 46 | 47 |

Hello, Everyone...!

48 |

Welcome to Kubernetes Demo :-)

49 | 50 | 51 | EOF 52 | exit 53 | 54 | # Expose PODS using NodePort service 55 | kubectl expose pod nginx-pod --type=NodePort --port=80 56 | 57 | 58 | -p : 59 | 60 | 61 | # Display Service and find NodePort 62 | kubectl describe svc nginx-pod 63 | 64 | # Open Web-browser and access webapge using 65 | http://:/test.html 66 | 67 | #eg.: http://3.6.89.129:31302/test.html 68 | 69 | 70 | 71 | # Delete pod & svc 72 | kubectl delete svc nginx-pod 73 | kubectl delete pod nginx-pod 74 | 75 | 76 | ******************************************************************* 77 | -------------------------------------------------------------------------------- /Linux/class_notes.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | Day 16: 14th Aug. 2024 3 | ####################### 4 | 5 | Fundamentals of Linux ::: 6 | 7 | 1. Overview of Linux 8 | 2. Linux Architecture 9 | 3. Linux Distributions 10 | 4. Basic Linux Commands 11 | 5. File Permission Management 12 | 6. User Creation 13 | 7. Shell Scripts 14 | 8. SSH and VI Utility 15 | 16 | 17 | Operating System ::: 18 | 19 | Fundamentals of Linux Operating System 20 | 21 | - Windows 22 | - Mac 23 | - Linux 24 | 25 | Linux Operating System 26 | - Open-Source 27 | - Is Secured 28 | - Linux OS was created based on the Unix Operating System 29 | - Is an interface between the user applications and underlying Hardware. 30 | - Linux OS is based on the Command User Interface 31 | - Core of Linux OS is called kernel! 32 | Components of Linux OS Architecture 33 | - Networking 34 | - Storage 35 | - IPC - Inter Process Communication 36 | - User Management 37 | - Security Management 38 | - Control Groups 39 | - Namespace 40 | - Process 41 | 42 | - Command Line Interface 43 | 44 | - Linux Distributions ::: 45 | 46 | - Flavors of Linux OS 47 | 48 | - Centos / RHEL 49 | - Debian / Ubuntu 50 | - Fedora 51 | 52 | Package Management - Package Managers ::: 53 | - Package Managers are used to install/Uninstall/Upgrade the Packages/software 54 | 55 | - Centos / RHEL ===> yum package Manager 56 | - Debian / Ubuntu ===> apt/apt-get package Manager 57 | - Fedora ===> dnf (Latest Version of Fedora) 58 | yum (Previous Version of Fedora) 59 | 60 | - Package Managers can be executed only by the root user on Linux 61 | 62 | - TO work with Package Manager : 63 | - Elevate the Access to Root Level 64 | - sudo -i # This Command is used to elevate the access to root level 65 | 66 | Learn Linux on DevOps Perspectives : 67 | 68 | What the Role of DevOps Team/Engineer on Linux. 69 | 70 | - All the DevOps Tools can be installed and Managed in Linux Machines 71 | 72 | What is your role here ???? 73 | 74 | - Install all the DevOps Tools 75 | - Package Management - Periodically Upgrade/Uninstall - Backup of the Tools 76 | - Managing Remote Servers 77 | - Client Server Architecture 78 | - Server1 (VM) 79 | - Client1,2,3,4,5,6 80 | 81 | - As a DevOps Team we can Manage the Linux Machines 82 | 83 | - Package Management 84 | - File Management 85 | - User Management 86 | - Access Management 87 | - Remote Servers Management 88 | - Process Automation(Shell Scripting) 89 | 90 | 91 | Working with Linux :: 92 | 93 | - Basic Linux Commands 94 | 95 | Package Manager - apt/yum/dnf ==> can e executed as a root user. 96 | 97 | - Linux Distributions 98 | 99 | Packages can be managed based on the Distributions 100 | 101 | 102 | - Package Management ::: 103 | 104 | - Package Managers are used to install/Uninstall/Upgrade the Packages/software 105 | 106 | - Centos / RHEL ===> yum package Manager 107 | - Debian / Ubuntu ===> apt/apt-get package Manager 108 | - Fedora ===> dnf (Latest Version of Fedora) 109 | yum (Previous Version of Fedora) 110 | 111 | - Package Managers can be executed only by the root user on Linux 112 | 113 | - TO work with Package Manager : 114 | - Elevate the Access to Root Level 115 | - sudo -i # This Command is used to elevate the access to root level 116 | 117 | - To Install any tool/package : 118 | 119 | Install Pre-requisites 120 | Install Actual Tool 121 | Post Installation Actions 122 | 123 | Eg.: Tomcat :::: 124 | 125 | Install Pre-requisites ===> jdk 126 | 127 | Install Actual Tool ===> Installed Tomcat 128 | 129 | Post Installation Actions ===> Started Tomcat 130 | 131 | 132 | How to Install/Manage Packages ? ::: 133 | 134 | - Elevate the Access to Root Level 135 | sudo -i # This Command is used to elevate the access to root level 136 | 137 | - apt update # Used update the default packages 138 | 139 | - apt install openjdk-11 # Install Java Package 140 | 141 | - Linux Application Service(nginx/Jenkins) 142 | 143 | - Start / Stop / Enable / Status / restart 144 | 145 | systemctl status nginx 146 | 147 | systemctl start nginx 148 | 149 | systemctl stop nginx 150 | 151 | systemctl enable nginx # Used to define the service as as start up service 152 | 153 | systemctl disable nginx # Used to remove the service from the start-up task list 154 | 155 | systemctl restart nginx 156 | 157 | - apt install git # Install git 158 | 159 | - apt remove git # Uninstall git 160 | 161 | - apt upgrade git # Used to upgrade git 162 | 163 | 164 | Package : 165 | 166 | - Stand-alone Tool Eg.: git 167 | - Service Eg.: tomcat/nginx/jenkins/docker 168 | 169 | which nginx # Used to get the path of installation ? 170 | 171 | which get 172 | 173 | git --version 174 | 175 | 176 | 177 | - File Management 178 | 179 | - sudo -i 180 | 181 | - exit # Logout from current linux user 182 | 183 | - ls # Is to List the files and Directories 184 | 185 | - ll # Long Listing - to get the full property of the directory 186 | 187 | - ls -a # List All(List all the files, including hidden files and directories) 188 | 189 | 190 | Navigate to Directories ::: 191 | 192 | - pwd # Get the Present Working Directory 193 | 194 | - cd # Change Directory 195 | 196 | - cd # Change to a specific directory 197 | 198 | - cd / # This command will take to the root directory 199 | 200 | - cd ~ # This command will take to the home directory(Default Directory) of the specific linux user 201 | Eg.: ubuntu ===> /home/ubuntu 202 | 203 | root ===> /root 204 | Next ::: 205 | 206 | - Create a Directory(Folder) 207 | - Is a collection of files and directories 208 | 209 | - Create a File 210 | 211 | - Edit the files 212 | 213 | - Delete the files 214 | 215 | - Delete the Directories 216 | 217 | - Copy the files/Directories 218 | 219 | - Move the Files/Directories 220 | 221 | - Rename the Files/Directories 222 | 223 | Create File Access Control 224 | 225 | ####################### 226 | Day 17: 15th Aug. 2024 227 | ####################### 228 | 229 | 230 | - Create a Directory(Folder) 231 | - Is a collection of files and directories 232 | 233 | - Create a File 234 | 235 | - Edit the files 236 | - Using File Editors - (vi editor / nano editor) 237 | 238 | - Delete the files 239 | 240 | - Delete the Directories 241 | 242 | - Copy the files/Directories 243 | 244 | - Move the Files/Directories 245 | 246 | - Rename the Files/Directories 247 | 248 | Create File Access Control 249 | 250 | - File Management 251 | 252 | - sudo -i 253 | 254 | - exit # Logout from current linux user 255 | 256 | - ls # Is to List the files and Directories 257 | 258 | - ll # Long Listing - to get the full property of the directory 259 | 260 | - ls -a # List All(List all the files, including hidden files and directories) 261 | 262 | 263 | Navigate to Directories ::: 264 | 265 | - pwd # Get the Present Working Directory 266 | 267 | - cd # Change Directory 268 | 269 | - cd # Change to a specific directory 270 | 271 | - cd / # This command will take to the root directory 272 | 273 | - cd ~ # This command will take to the home directory(Default Directory) of the specific linux user 274 | Eg.: ubuntu ===> /home/ubuntu 275 | 276 | root ===> /root 277 | 278 | 279 | clear # Clear the Screen 280 | 281 | 282 | mkdir # used to Creae Directory 283 | 284 | cd # Change the directory 285 | 286 | cd .. # Take the control back to previous directory 287 | 288 | Create Files : 289 | 290 | - touch # used to create an empty file 291 | 292 | - echo "Record1" >> # To create a file with a record 293 | 294 | - echo "rec1" >> file1.txt 295 | # Used to add more record to the specific file 296 | 297 | - echo "rec1" > file1.txt 298 | # Used to replace the file content with the new record 299 | 300 | - vi # Used to Create / edit a file using vi editor 301 | 302 | 303 | Read the file content : 304 | 305 | cat # Read the Content of a file 306 | 307 | 308 | - vi # Used to Create / edit a file using vi editor 309 | 310 | Eg.: 311 | 312 | vi file1.txt 313 | 314 | press i # goto insert mode 315 | 316 | #type some contents 317 | #type some contents 318 | 319 | press esc :wq # Save and Exit from a file 320 | 321 | press esc :q! # Exit from a file without saving it. 322 | 323 | Rename File or Directory ::: 324 | 325 | mv file1 file-new-name 326 | 327 | mv dir1 new-dir-name 328 | 329 | Delete a file or Directory ::: 330 | 331 | rm # Remove File 332 | 333 | rm file1.txt 334 | 335 | rm *.txt 336 | 337 | rm -r # Remove Directory 338 | 339 | rm -rf # Forceful Deletion of Directory 340 | 341 | 342 | Copy files from one directory to another ::: 343 | 344 | cp # Used to copy a file to target folder 345 | 346 | mv # Used to move a file to target folder 347 | 348 | mv file1 file-new-name # To Rename a file 349 | mv dir1 new-dir-name # To Rename a directory 350 | 351 | 352 | File Access :::: 353 | 354 | Who can Access the file ? 355 | 356 | - By Default Owner will have complete access. 357 | 358 | 1 sudo -i 359 | 2 clear 360 | 3 clear 361 | 4 sudo -i 362 | 5 clear 363 | 6 apt update 364 | 7 sudo -i 365 | 8 clear 366 | 9 sudo -i 367 | 10 pwd 368 | 11 cd / 369 | 12 ls 370 | 13 cd home/ 371 | 14 ls 372 | 15 cd ubuntu/ 373 | 16 pwd 374 | 17 cd /home/ 375 | 18 ls 376 | 19 cd ubuntu/ 377 | 20 pwd 378 | 21 cd / 379 | 22 ls 380 | 23 tree 381 | 24 clear 382 | 25 ls 383 | 26 cd home 384 | 27 cd ubuntu/ 385 | 28 lpwd 386 | 29 clear 387 | 30 pwd 388 | 31 sudo -i 389 | 32 pwd 390 | 33 cd /root/ 391 | 34 cd / 392 | 35 clear 393 | 36 ls 394 | 37 pwd 395 | 38 cd home/ 396 | 39 pwd 397 | 40 cd ubuntu/ 398 | 41 pwd 399 | 42 c d/ 400 | 43 cd / 401 | 44 ls 402 | 45 cd home/ubuntu/ 403 | 46 pwd 404 | 47 ls 405 | 48 pwd 406 | 49 ls 407 | 50 sudo -i 408 | 51 clear 409 | 52 sudo -i 410 | 53 clear 411 | 54 history 412 | 413 | 414 | ####################### 415 | Day 18: 19th Aug. 2024 416 | ####################### 417 | 418 | 419 | - File Management 420 | - User Management 421 | - Access Management 422 | 423 | - Remote Servers Management 424 | 425 | - Process Automation(Shell Scripting) 426 | 427 | 428 | Access Management ::: 429 | 430 | 431 | File : 432 | 433 | script 434 | program 435 | artifacts 436 | 437 | 438 | >> ll # Long Listing 439 | 440 | 441 | drwxrwxr-x 2 ubuntu ubuntu 4096 Aug 16 14:49 dir4/ 442 | -rw-rw-r-- 1 ubuntu ubuntu 0 Aug 16 14:54 file1.txt 443 | 444 | 445 | ---------- 446 | 447 | - # Denote dir or file (Possible value: d or - ) 448 | 'd' Denotes Directory 449 | '-' Denotes File 450 | 451 | 452 | --- # Denote the Owner Level Access 453 | Possible Values: r / w /x 454 | r - Read only Access 455 | w - Write Access 456 | x - Execute Access 457 | 458 | --- # Denote the Group Level Access 459 | Possible Values: r / w /x 460 | r - Read only Access 461 | w - Write Access 462 | x - Execute Access 463 | 464 | --- # Denote the Public User Level Access 465 | Possible Values: r / w /x 466 | r - Read only Access 467 | w - Write Access 468 | x - Execute Access 469 | 470 | 471 | User 472 | 473 | Group 474 | 475 | RBAC --> User_ID --> Group 476 | 477 | dev_user1 478 | Developer_grp 479 | 480 | Test_User1 481 | Tester_Grp 482 | 483 | drwxrwxr-x 2 dev_user1 Developer_grp 4096 Aug 16 14:49 dir4/ 484 | -rw-rw-r-- 1 Test_User1 Tester_Grp 0 Aug 16 14:54 file1.txt 485 | 486 | https://chmod-calculator.com/ 487 | 488 | chmod 489 | 490 | chmod 600 myjavaproject1/* 491 | 492 | Access Mode ::: 493 | r - Read only Access 494 | w - Write Access 495 | x - Execute Access 496 | 497 | 498 | User Management :::::: 499 | 500 | Create Linux Users ::: 501 | 502 | ubuntu user 503 | 504 | root user 505 | 506 | devopsadmin 507 | 508 | 509 | Linun Machine uses SSH(Secure SHell) Connection 510 | --> Host_Name,User_Name,Credentials 511 | 512 | How to Create Linux User? 513 | - devopsadmin 514 | 515 | User Authentication? 516 | SSH Authentication Methods : 517 | 518 | - Password Based Authentication 519 | - Token Based Authentication 520 | - Key Based Authentication 521 | - Public Key/Private Key 522 | - Passwordless 523 | 524 | 525 | User Authorization? 526 | --> Ownership 527 | 528 | Create Linux User with SSH Keys ::: 529 | 530 | useradd devopsadmin -s /bin/bash -m -d /home/devopsadmin 531 | 532 | su - devopsadmin 533 | 534 | ssh-keygen -t ecdsa -b 521 #ubuntu 22.04 or higher version of ubuntu 535 | 536 | cd .ssh 537 | 538 | ls ~/.ssh 539 | 540 | #You should see following two files: 541 | 542 | #id_ecdsa - private key 543 | #id_ecdsa.pub - public 544 | 545 | 546 | cat id_ecdsa.pub > authorized_keys # authorized_keys this file name should be same. 547 | 548 | authorized_keys ::: 549 | It is the copy of Public Key. 550 | 551 | Always the private key will be compared with the authorized_keys 552 | 553 | chmod 600 /home/devopsadmin/.ssh/* # Used to Change the Access Mode of Files or Directories 554 | 555 | chown -R devopsadmin:devopsadmin /opt/tomcat/ # Used to Change the Ownership of Files or Directories 556 | 557 | 558 | Get the List of Linux Users :::: 559 | cat /etc/passwd 560 | 561 | Get the list of Linux User Groups :::: 562 | cat /etc/group 563 | 564 | 565 | Create Password to any Linux User: 566 | 567 | As a root user :: 568 | 569 | passwd 570 | 571 | root@ip-172-31-46-175:~# passwd devopsadmin 572 | New password: 573 | Retype new password: 574 | passwd: password updated successfully 575 | 576 | Next ::: 577 | 578 | Remote Server Access ::: 579 | 580 | AWS Cloud : 581 | 582 | VM1 583 | 584 | VM2 585 | 586 | 1. Establish Connection to Remote Server 587 | 2. Login to the Remote Server 588 | 3. Copy the Files from one server to another server 589 | using SCP 590 | 4. Manage the Remote Server - Install any package/Uninstall/Upgrade 591 | 592 | Pre-requisites for Remote Server ::: 593 | 594 | - Launch 2 VMs (VM1-Source & VM2-Target) 595 | 596 | - Ensure that Port 22 is enabled 597 | 598 | - Create User in both the VMs 599 | 600 | - Create SSH-Key in one server(VM1) 601 | 602 | - Use the public_Key as a authorized_keys in the target server(VM2) 603 | 604 | - Establish SSH Connection & Login to VM2(Target_Machine) 605 | 606 | - Copy Files from VM1 to VM2(Target_Machine) 607 | 608 | 609 | SHELL Scripting! 610 | 611 | 612 | ####################### 613 | Day 19: 21st Aug. 2024 614 | ####################### 615 | 616 | Remote Server Access ::: 617 | 618 | AWS Cloud : 619 | 620 | VM1 (Server) 621 | 622 | VM2 (Client) 623 | 624 | 1. Establish Connection to Remote Server 625 | 2. Login to the Remote Server 626 | 3. Copy the Files from one server to another server 627 | using SCP 628 | 4. Manage the Remote Server - Install any package/Uninstall/Upgrade 629 | 630 | Pre-requisites for Remote Server ::: 631 | 632 | - Launch 2 VMs (VM1-Source & VM2-Target) 633 | 634 | - Ensure that Port 22 is enabled 635 | 636 | - Create User in both the VMs 637 | 638 | - Create SSH-Key in one server(VM1) 639 | 640 | - Use the public_Key as a authorized_keys in the Client Machine(VM2) 641 | 642 | - Establish SSH Connection & Login to VM2(Client_Machine) 643 | 644 | - Copy Files from VM1 to VM2(Client_Machine) 645 | 646 | 647 | Client_Machine :::: 648 | 649 | useradd adminuser1 -s /bin/bash -m -d /home/adminuser1 650 | 651 | su - adminuser1 652 | 653 | mkdir .ssh 654 | 655 | cd .ssh 656 | 657 | vi authorized_keys 658 | 659 | #paste the id_ecdsa.pub of devopsadmin user from Server machine to authorized_keys file in Client Machine 660 | 661 | chmod 600 /home/adminuser1/.ssh/* 662 | 663 | 664 | From Server execute this Command as a devopsadmin user : 665 | 666 | ssh adminuser1@172.31.1.144 667 | 668 | 669 | - Copy Files from VM1 to VM2(Client_Machine) 670 | 671 | 672 | Server Machine :::: 673 | /home/devopsadmin/mywebappfile1.txt 674 | 675 | Client Machine :::: 676 | /home/adminuser1/mywebappfile1.txt 677 | 678 | #cp /home/devopsadmin/mywebappfile1.txt home/devopsadmin/dir1/ 679 | 680 | scp /home/devopsadmin/mywebappfile1.txt adminuser1@172.31.1.144:/home/adminuser1 681 | 682 | #nohup scp 683 | 684 | 685 | To Add Any User to a Group : 686 | 687 | usermod -aG 688 | 689 | usermod -aG docker devopsadmin 690 | 691 | SHELL Scripting ::: 692 | 693 | Process Automation using shell scripting! 694 | 695 | Fundamentals of Shell Scripting! 696 | 697 | Scripting Languages ? 698 | - Are used to perform some process automation/validations 699 | - Light-weight 700 | - Eg.: java scripts / shell scripts / yaml script / groovy / python 701 | (vs) 702 | Progamming Language ? 703 | - Are used to create some business applications 704 | - Huge Collection of Programming components 705 | - Eg.: Java/.Net Framework/Python/Ruby/Cobol/C 706 | 707 | 708 | Shell Scripting Language : 709 | 710 | - Shell Scripting is a collection shell commands 711 | - Shell Script file should be saved as *.sh (Extention should be .sh) 712 | 713 | Install git ? 714 | 715 | Install all these packages in 200 VMs ::: 716 | 717 | apt install openjdk11 -y 718 | apt install git -y 719 | apt install maven -y 720 | apt install docker.io -y 721 | apt install ansible -y 722 | 723 | Shell Script : 724 | 725 | installbuildtools.sh 726 | #!/bin/bash 727 | sudo apt install openjdk11 -y 728 | sudo apt install git -y 729 | sudo apt install maven -y 730 | sudo apt install docker.io -y 731 | #sudo apt install ansible -y 732 | 733 | save the script as installbuildtools.sh 734 | 735 | /home/devopsadmin/scripts/$ ls 736 | installbuildtools.sh 737 | 738 | /home/devopsadmin/scripts/$ ./installbuildtools.sh # Run the Shell Script! 739 | 740 | Any Scripting/Programming Languages ::: 741 | 742 | 743 | Data !!! 744 | 745 | Variable_Name to store data 746 | Type of Data - Data Type ! 747 | 748 | var1 = 10001 749 | var2 = "asdfasdf" 750 | var3 = 'a' 751 | 752 | Stud_Number = '101' 753 | 754 | 755 | Validation / Conditional Statements 756 | 757 | IF Conditions 758 | SwitchCase Statements 759 | 760 | Stud_Number[5]; # Array Variable 761 | ==> {1,2,3,4,5} 762 | 763 | Looping Contructs 764 | 765 | - for loop 766 | - while loop 767 | - do-while 768 | 769 | Functions 770 | - String function 771 | 772 | Keyword 773 | 774 | File Handling : 775 | 776 | - Create/Read/Write/Update/Delete the Files 777 | 778 | DataBase Handling using Programming Language 779 | 780 | Remote Server Handling 781 | 782 | Next ::: 783 | 784 | Working with Shell Scripting! 785 | 786 | 787 | ####################### 788 | Day 20: 22nd Aug. 2024 789 | ####################### 790 | 791 | #Install JDK 792 | 793 | java --version 794 | 795 | cd /usr/lib/jvm/ 796 | 797 | /usr/lib/jvm/java-21-openjdk-amd64/bin 798 | 799 | #edit /etc/profile & add JAVA_HOME 800 | 801 | vi /etc/profile 802 | 803 | 804 | export JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64/bin" 805 | PATH=$PATH:$HOME/bin:$JAVA_HOME/bin 806 | 807 | source /etc/profile 808 | 809 | 810 | Fundamentals of Shell Scripting! 811 | 812 | Software Application ? 813 | 814 | - Collection of Programs. 815 | 816 | Program / Script? 817 | - To Solve a problem. 818 | - To Provide a Solution. 819 | 820 | - How to write a program? 821 | - What are the pre-requisites to write a program? 822 | 823 | Problem Statement: 824 | 825 | The Requirement 826 | 827 | SDLC 828 | 829 | Requirement Analysis Phase 830 | Design/Document 831 | Code/Programming 832 | Test 833 | Implementation 834 | 835 | Program 836 | 837 | Algorithm : 838 | 839 | - The Step-by-step process to provide the solution/Task 840 | - It is written is high-level language 841 | 842 | - Based on the algorithm, we create Source Code using Programming/Scripting Languages 843 | 844 | Problem Statement : 845 | 846 | Calculate sum of two numbers and print the result : 847 | 848 | S1: Take two integers as input 849 | S2: Add the two integers 850 | S3: Print the result 851 | 852 | 853 | int a; 854 | int b; 855 | int c; 856 | pub=a,b,c; 857 | a=b+c; 858 | print a; 859 | 860 | 1)int a=8 861 | 2)int b=7 862 | 3)int c=a+b 863 | then 864 | print c. 865 | 866 | 867 | 5 + 5 = ? 868 | 869 | 30 + 30 = ? 870 | 871 | 20000000000000 + 3000000000000000 = ? 872 | 873 | 222222222.55534 + 2342342.123123 = ? 874 | 875 | 876 | Logical Thinking! 877 | 878 | 879 | Scripting ::: 880 | 881 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 882 | A simple script to print Hello World on terminal using echo command 883 | 884 | Source Code: 885 | 886 | #!/bin/bash 887 | # 888 | echo "Hello World" 889 | 890 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 891 | A simple script to print the calender month by default. 892 | 893 | Source Code: 894 | 895 | #!/bin/bash 896 | # 897 | echo "The Month is" 898 | cal # cal command displays current month by default 899 | 900 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 901 | A simple script to read user input and perform operations with them. 902 | 903 | Source Code: 904 | 905 | #!/bin/bash 906 | echo -n "Enter number 1 : " # -n option supresses newline 907 | read NUM1 # Read the user input from Standard Input and store in Variable NUM1 908 | 909 | echo -n "Enter number 2 : " 910 | read NUM2 911 | 912 | SUM=$(($NUM1 + $NUM2)) # Arithmetic expansion using double parentheses 913 | echo "The sum is $SUM" 914 | 915 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 916 | A script to show usage of if condition 917 | 918 | #Operators :: 6 Operators 919 | 920 | Source Code: 921 | 922 | 923 | #!/bin/bash 924 | 925 | NUM1=5 # variabe assignment 926 | NUM2=2 927 | 928 | if [ $NUM1 -gt $NUM2 ] # -gt is to test integer numbers 929 | then 930 | echo "NUM1 > NUM2" 931 | fi 932 | 933 | 934 | 935 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 936 | A script to show usage of if else condition 937 | 938 | Source Code: 939 | 940 | #!/bin/bash 941 | 942 | NUM1=2 # Variabe assignment 943 | NUM2=5 944 | 945 | if [ $NUM1 -lt $NUM2 ] # -lt is to test intiger numbers 946 | then 947 | echo "NUM1 < NUM2" 948 | else 949 | echo "NUM1 > NUM2" 950 | fi 951 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 952 | A script to show usage of else if condition 953 | 954 | Source Code: 955 | 956 | #!/bin/bash 957 | # 958 | 959 | echo -n "Enter a number: " 960 | read NUM 961 | 962 | if [ $NUM -gt 0 ] 963 | then 964 | echo "$NUM is +ve" 965 | elif [ $NUM -lt 0 ] 966 | then 967 | echo "$NUM is -ve" 968 | else 969 | echo "$NUM is 0" 970 | fi 971 | 972 | echo "done" 973 | 974 | 975 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 976 | A script to demonstrate case statement 977 | 978 | Source Code: 979 | 980 | #!/bin/bash 981 | 982 | echo -n "Enter a character: " 983 | read CHAR # A , a ,e,i,o,u l 984 | 985 | case $CHAR in 986 | a) echo "You entered $CHAR which is a vowel";; # ;; Terminates each option 987 | e) echo "You entered $CHAR which is a vowel";; 988 | i) echo "You entered $CHAR which is a vowel";; 989 | o) echo "You entered $CHAR which is a vowel";; 990 | u) echo "You entered $CHAR which is a vowel";; 991 | *) echo "You entered $CHAR which is not a vowel";; # Defaults to everything else 992 | esac 993 | 994 | echo "What if you enter upper case letters!!?, Check the next example" 995 | 996 | 997 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 998 | A script to demonstrate case statement 999 | 1000 | Source Code: 1001 | 1002 | #!/bin/bash 1003 | 1004 | echo -n "Enter a character: " 1005 | read CHAR 1006 | 1007 | case $CHAR in 1008 | a | A) # Test for both Lower or Upper case letter 1009 | # You may write commands in this fashion too!!, means multiline commands 1010 | echo "You entered $CHAR which is a vowel" 1011 | ;; # Terminates each option 1012 | e | E) 1013 | echo "You entered $CHAR which is a vowel" 1014 | ;; 1015 | i | I) 1016 | echo "You entered $CHAR which is a vowel" 1017 | ;; 1018 | o | O) 1019 | echo "You entered $CHAR which is a vowel" 1020 | ;; 1021 | u | U) 1022 | echo "You entered $CHAR which is a vowel" 1023 | ;; 1024 | *) # Defaults to everything else 1025 | echo "You entered $CHAR which is not a vowel" 1026 | ;; 1027 | esac 1028 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1029 | A script to demonstrate case statement 1030 | 1031 | Source Code: 1032 | 1033 | #!/bin/bash 1034 | 1035 | echo -n "Oceans are larger than lakes (True or False) : " 1036 | read USER_INPUT 1037 | 1038 | case $USER_INPUT in 1039 | "TRUE"| "True" | "true") 1040 | echo "Yes you are right" 1041 | ;; # Terminates each option 1042 | "FALSE" | "Fasle" | "false") 1043 | echo "No your are wrong" 1044 | ;; 1045 | *) # Defaults to everything else 1046 | echo "Please enter either True or False" 1047 | ;; 1048 | esac 1049 | 1050 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1051 | A simple script to show usage of string compare operator == and != 1052 | 1053 | Source Code: 1054 | 1055 | #!/bin/bash 1056 | 1057 | STR1="Hello" 1058 | STR2="Hello" 1059 | 1060 | if [ ${STR1} == ${STR2} ] 1061 | then 1062 | echo "Strings match" 1063 | else 1064 | echo "Strings don't match" 1065 | fi 1066 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1067 | A simple script to show usage of string compare operator -z and -n 1068 | 1069 | Source Code: 1070 | 1071 | #!/bin/bash 1072 | 1073 | STR1="Hello" 1074 | STR2="Hello" 1075 | 1076 | if [ -z "${STR1}" ] 1077 | then 1078 | echo "String1 is empty" 1079 | else 1080 | echo "String1 is NOT empty" 1081 | fi 1082 | 1083 | echo ":$STR:" 1084 | if [ -n "${STR2}" ] 1085 | then 1086 | echo "String2 is NOT empty" 1087 | else 1088 | echo "String2 is empty" 1089 | fi 1090 | 1091 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1092 | A simple script to show usage of logical operators 1093 | 1094 | Source Code: 1095 | 1096 | #!/bin/bash 1097 | 1098 | echo -n "Enter a NUM: " 1099 | read NUM 1100 | 1101 | # Check whether a number is between 10 and 20 (Using AND -a operator) 1102 | if [ $NUM -ge 10 -a $NUM -le 20 ] 1103 | then 1104 | echo "$NUM is between 10 and 20" 1105 | else 1106 | echo "$NUM is NOT between 10 and 20" 1107 | fi 1108 | 1109 | echo -n "Enter another NUM: " 1110 | read NUM 1111 | 1112 | # Check whether a number is between 10 and 20 (Using OR -o operator) 1113 | if [ $NUM -lt 10 -o $NUM -gt 20 ] 1114 | then 1115 | echo "$NUM is NOT between 10 and 20" 1116 | else 1117 | echo "$NUM is between 10 and 20" 1118 | fi 1119 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1120 | A simple script to show usage while loop 1121 | 1122 | Source Code: 1123 | 1124 | #!/bin/bash 1125 | # 1126 | 1127 | COUNT=0 1128 | 1129 | while [ $COUNT -lt 5 ] 1130 | do 1131 | echo "Loop count is ${COUNT}" 1132 | COUNT=$((COUNT + 1)) 1133 | done 1134 | 1135 | echo "Done" 1136 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1137 | Sum of N natural numbers using while loop 1138 | 1139 | Source Code: 1140 | 1141 | #!/bin/bash 1142 | # 1143 | 1144 | echo -n "Enter a number: " 1145 | read NUM 1146 | 1147 | let SUM=0; 1148 | let I=1 1149 | while [ $I -le $NUM ] 1150 | do 1151 | SUM=`expr $SUM + $I` 1152 | I=$((${I} + 1)) 1153 | done 1154 | 1155 | echo "The sum of the first $NUM numbers is: $SUM" 1156 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1157 | A simple script to demonstarte for loop [ Bash syntax ] 1158 | 1159 | Source Code: 1160 | 1161 | #!/bin/bash 1162 | # 1163 | 1164 | COUNT=0 1165 | 1166 | for i in 0 1 2 3 4 1167 | do 1168 | echo "Loop count is ${COUNT}" 1169 | COUNT=$((COUNT + 1)) 1170 | done 1171 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1172 | A simple script to demonstarte for loop [ C syntax ] 1173 | 1174 | Source Code: 1175 | 1176 | #!/bin/bash 1177 | 1178 | COUNT=0 1179 | 1180 | for ((i = 0; i < 5; i++)) 1181 | do 1182 | echo "Loop count is ${COUNT}" 1183 | COUNT=$((COUNT + 1)) 1184 | done 1185 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1186 | A script to show the usage of command line arguments, Here we access positional arguments using $1, $2 … 1187 | 1188 | Source Code: 1189 | 1190 | #!/bin/bash 1191 | 1192 | echo "Total no. of argument: $#" 1193 | 1194 | echo "Program name: $0" 1195 | echo "1st argument: $1" 1196 | echo "2nd argument: $2" 1197 | echo "3rd argument: $3" 1198 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1199 | A script to show the usage of command line arguments, Here we access arguments by iterating over $@ 1200 | 1201 | Source Code: 1202 | 1203 | #!/bin/bash 1204 | 1205 | echo "Total no. of argument: $#" 1206 | echo "Argument list: $@" # Commonly used 1207 | echo "Argument list: $*" 1208 | 1209 | # Iterate over arguments ($@) 1210 | for ARG in $@ 1211 | do 1212 | echo $ARG 1213 | done 1214 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1215 | A script to show the usage of function 1216 | 1217 | Source Code: 1218 | 1219 | 1220 | print_hello#!/bin/bash 1221 | 1222 | # Function definition 1223 | function print_hello() 1224 | { 1225 | echo "=====" 1226 | echo "Hello" 1227 | echo "=====" 1228 | } 1229 | 1230 | # Call the function - print_hello 1231 | print_hello 1232 | 1233 | print_hello 1234 | print_hello 1235 | print_hello 1236 | print_hello 1237 | 1238 | 1239 | #print_hello 1240 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1241 | A script to show the usage of function and how to pass arguments 1242 | 1243 | Source Code: 1244 | 1245 | #!/bin/bash 1246 | 1247 | # Function definition 1248 | function find_sum() 1249 | { 1250 | SUM=`expr $1 + $2` 1251 | echo $SUM 1252 | } 1253 | 1254 | # Pass arguments 10 and 20 to find_sum function 1255 | find_sum 10 20 # 30 1256 | 1257 | # Save the output of function in a variable 1258 | RESULT=`find_sum 100 200` 1259 | echo $RESULT # 300 1260 | 1261 | 1262 | num1=5 1263 | num2=5 1264 | 1265 | 1266 | sample1.sh 1267 | 1268 | #!/bin/bash 1269 | num1=$1 1270 | num2=$2 1271 | 1272 | num3=$num1 + $num2 1273 | 1274 | num3=$1 + $2 + $3 1275 | 1276 | echo $num3 1277 | 1278 | sh sample1.sh 34 45 43 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1288 | A script to show the usage of function and how to pass arguments Inside function: 1289 | $# – Gives no. of arguments 1290 | $@ – Contains the arguments to function 1291 | Accessing function arguments is similar to accessing command line arguments 1292 | 1293 | Source Code: 1294 | 1295 | #!/bin/bash 1296 | 1297 | # Function definition 1298 | function find_sum() 1299 | { 1300 | echo "Arg count: $#" 1301 | echo "Arg list: $@" 1302 | SUM=0 1303 | # Iterate over function arguments 1304 | for ARG in $@ 1305 | do 1306 | SUM=`expr $ARG + $SUM` 1307 | done 1308 | 1309 | echo $SUM 1310 | } 1311 | 1312 | # Call find_sum with many arguments 1313 | find_sum 1 2 3 4 5 1314 | 1315 | find_sum 10 20 1316 | 1317 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1318 | A script to show how to declare an array and access its elements 1319 | 1320 | Source Code: 1321 | 1322 | #!/bin/bash 1323 | 1324 | # Declare an array 1325 | FRUITS=(apple mango banana orange) 1326 | 1327 | # Print value of each element 1328 | echo "element 0: ${FRUITS[0]}" 1329 | echo "element 1: ${FRUITS[1]}" 1330 | echo "element 2: ${FRUITS[2]}" 1331 | echo "element 3: ${FRUITS[3]}" 1332 | 1333 | # Print size / length of array 1334 | echo "Length: ${#FRUITS[@]}" 1335 | echo "Whole array: ${FRUITS[@]}" 1336 | echo "Whole array: ${FRUITS[*]}" 1337 | 1338 | echo "Looping over array elements" 1339 | # Iterate over array elements 1340 | for ITEM in ${FRUITS[@]} 1341 | do 1342 | echo $ITEM 1343 | done 1344 | 1345 | 1346 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1347 | A script to store all cmd line arguments to a array and prints 1348 | 1349 | Source Code: 1350 | 1351 | #!/bin/bash 1352 | 1353 | ARG=($*) 1354 | 1355 | echo ${ARG[0]} 1356 | echo ${ARG[1]} 1357 | echo ${ARG[2]} 1358 | echo ${ARG[3]} 1359 | echo ${ARG[4]} 1360 | 1361 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1362 | A script to demonstrate different types of array access 1363 | 1364 | Source Code: 1365 | 1366 | #!/bin/bash 1367 | # 1368 | 1369 | array=(zero one two three four five) 1370 | 1371 | # Element 0 1 2 3 4 5 1372 | echo ${array[0]} # zero 1373 | echo ${array:0} # zero, Parameter expansion of first element,+ starting at position # 0 (1st character). 1374 | echo ${array:1} # ero, Parameter expansion of first element, + starting at position # 1 (2nd character). 1375 | echo "--------------" 1376 | echo ${#array[0]} # 4, Length of first element of array. 1377 | echo ${#array} # 4, Length of first element of array. (Alternate notation) 1378 | echo ${#array[1]} # 3, Length of second element of array. Arrays in Bash have zero-based indexing. 1379 | echo ${#array[*]} # 6, Number of elements in array. 1380 | echo ${#array[@]} # 6, Number of elements in array. 1381 | echo "--------------" 1382 | 1383 | # Quoting permits embedding whitespace within individual array elements. 1384 | array2=([0]="first element" [1]="second element" [3]="fourth element") 1385 | 1386 | echo "The ${array2[0]}" # first element 1387 | echo "The ${array2[1]}" # second element 1388 | echo "The ${array2[2]}" # Skipped in initialization, and therefore null. 1389 | echo "The ${array2[3]}" # fourth element 1390 | echo "The lenght of ${array2[0]} ${#array2[0]}" # 13 (length of first element) 1391 | echo "The number of elements in the array ${#array2[*]}" # 3 (number of elements in array) 1392 | 1393 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1394 | A script to demostrate usage of sed command 1395 | 1396 | Source Code: 1397 | 1398 | #!/bin/bash 1399 | 1400 | # Basic text substitution using sed 1401 | echo "Bash Scripting Bash Language" | sed 's/Bash/Perl/' 1402 | 1403 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | -------------------------------------------------------------------------------- /Maven_Build_Tool/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ####################### 3 | Day 26: 2nd Sep. 2024 4 | ####################### 5 | 6 | 7 | Overview of Various Build Tools 8 | What is Maven 9 | Maven Architecture 10 | Maven Plugins 11 | Maven Archetypes 12 | Maven Commands 13 | Integration of Jacoco Plugin for Code Coverage 14 | Overview of Maven Applications 15 | 16 | 17 | Application Build Tool ::: 18 | 19 | What is Application Build ? 20 | 21 | Build --> It is a process of Compiling the source code and create artifacts. 22 | 23 | Eg.: Java Program ==> High Level Language 24 | Code Compilation 25 | Create Artifacts --> Artifacts are the Binary Code(*.war/*.jar/*.exec) 26 | 27 | Build Tools 28 | - Java Applications : 29 | 30 | - Maven / Gradle / Ant 31 | 32 | 33 | Maven Build Tool ::: 34 | 35 | - Is a Java Application Build Tool, used to compile the Java application source code, Perform Unit Testing, Create Artifacts. 36 | 37 | 38 | Java Program ::: 39 | 40 | javac - java compiler 41 | 42 | 43 | Environment : 44 | 45 | Non-Prod Environments 46 | 47 | Dev Environment: 48 | - Create Source Code 49 | 50 | Build Environment: 51 | - Build the Source Code 52 | - Build Tools like Maven 53 | - Unit Testing 54 | 55 | Test Environment : 56 | QA Testing 57 | UAT Testing 58 | 59 | 60 | Dev Environment: 61 | 62 | Developers' Workflow :: 63 | 64 | 1. Create Program : *.java 65 | 66 | 2. Compile 67 | 68 | 3. Create artifacts 69 | 70 | 4. Test the program - Unit Testing using Unit Testing Tool like JUnit 71 | 72 | 5. Push the Changes to Remote github repository 73 | 74 | Tools required to perform these activities ::: 75 | 76 | Tools ::: 77 | 78 | - Eclipse based IDEs - like Eclipse for Java,Pycharm,Intellij, Visual Studio, Visual Studio Code 79 | - Source Code Management Tool - like github/AWS Code Commit/Azure Repos 80 | - Jdk, Maven, JUnit Testing Tool, git 81 | 82 | 83 | 84 | Build Environment: 85 | 86 | Using DevOps Approach :: 87 | Automate :: 88 | 89 | - Identify/Clone the Source Code from Github Repository 90 | - Build the code - Compile and create artifacts 91 | - Unit Testing 92 | - Verify the Unit Test Coverage 93 | - Archive the Artifacts in the Artifactory Library 94 | - Promote the Application to higher testing Environment(QA) 95 | - Notify the Testing/Development Team 96 | 97 | Continuous Integration : 98 | - It is the capabililty of Application Development Team to Continously Integrate the Code Changes for further Testing, without impacting others. 99 | 100 | Tools : 101 | - Eclipse based IDEs - like Eclipse for Java,Pycharm,Intellij, Visual Studio, Visual Studio Code 102 | - Source Code Management Tool - like github/AWS Code Commit/Azure Repos 103 | - Jenkins/AWS Code Pipeline/Azure Pipeline, Docker, Kubernetes, Ansible 104 | 105 | 106 | Source Code -- Version Controlled using GIThub 107 | 108 | signin.java_v1.0 ---> Create Artifacts ==> signin.war_v1.0 109 | signin.java_v1.1 ---> Create Artifacts ==> signin.war_v1.1 110 | 111 | 112 | Artifactory Library -- Used to Version Control the Artifacts 113 | - Jfrog Artifactory 114 | - Azure Artifacts 115 | 116 | 117 | 118 | How to Perform Application Build, Unit Testing ? 119 | 120 | - Using Maven Build Tool 121 | - Maven is Java Application Build Tool 122 | - Maven is used to Compile the Source Code 123 | - Create Artifacts 124 | - Perform Unit Testing 125 | (Unit Testing is a process of testing the changes done by the developers) 126 | - Maven can verify the Code Coverage 127 | 128 | 129 | sum(a,b) 130 | { 131 | a = 4 132 | b = 5 133 | c = a + b 134 | return c 135 | } 136 | 137 | 138 | Application Build Process : 139 | 140 | Input : Source Code - *.java (github repositories) 141 | 142 | Output : Artifacts - *.war (Artifactory Libraries) 143 | 144 | Maven - Build Tool 145 | 146 | How Maven Works ?? 147 | 148 | 149 | Application Source Code Repository : 150 | 151 | Developer create POM.XML File to perform Maven Build 152 | 153 | Build Tools - Maven - used to build Java applications 154 | 155 | Using Maven : 156 | Application Build - Compile the code, create artifacts, perform unit-testing 157 | 158 | - Build - It is a process of compiling the source code and create artifacts(Binaries - *.war / *.jar/ *.exec) 159 | - Unit Testing 160 | 161 | Maven Project : 162 | 163 | pom.xml - Project Object Model : 164 | 165 | - Will be part of the Java Application Project - Source Code Repository 166 | - It is used to define the properties of application artifacts 167 | - It is used to define dependencies and the plugins required to perform build/unit-testing 168 | 169 | Maven Repository : https://mvnrepository.com/ 170 | 171 | - Maven Repositories Contains the Maven Dependencies and Plugins 172 | - During Build, Maven refer to this Repositories and Download the Dependencies to perform Application Build, Unit Testing etc... 173 | 174 | Eg.: 175 | Build Environment (VM) ::: 176 | 177 | Build the application --> Jdk, Maven 178 | 179 | Unit Testing - Junit Testing Tool 180 | 181 | Maven Goals : 182 | This defines the actions we perform using Maven 183 | 184 | ● mvn compile - to compile the source code 185 | ● mvn test - to compile and execute junit test cases 186 | ● mvn package - to compile, test and create artifacts in the target folder of Project Library 187 | ● mvn clean - to clean the target folder. 188 | 189 | Eg.: 190 | 191 | mvn clean package 192 | 193 | 194 | 195 | Java Web Application Project : - 196 | 197 | My_Web_App - Folder 198 | 199 | Maven Project Structure ::: # Java Maven Desktop/Console/terminal Application; 200 | 201 | MVN_Project1 # Project Name 202 | src 203 | main # Maintain the source code *.java - Business Logic 204 | *.java 205 | test # Maintain the Test Cases and Test Data - JUnit 206 | *.java 207 | target 208 | artifacts *.war / *.jar 209 | pom.xml ==> defines the application artifacts, plugins and all the required depedencies 210 | 211 | JRE_Libraries 212 | MVN_Libraries 213 | 214 | Java Code Coverage - JaCoCo ::: 215 | 216 | 217 | 218 | org.jacoco 219 | jacoco-maven-plugin 220 | 0.8.12 221 | 222 | 223 | 224 | Next ::: 225 | 226 | Build Orchestration Tool - Jenkins 227 | 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /Monitoring/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ####################### 3 | Day 44: 7th Oct. 2024 4 | ####################### 5 | 6 | Fundamentals of Prometheus and Grafana 7 | 8 | Continuous Monitoring : 9 | - It is used to monitor the infra-structure and Applications based on the monitorig frequency 10 | 11 | - Infra-Structure Monitoring 12 | - Prometheus/Grafana/Dyna-trace/Nagios/Splunk 13 | - Used ot Monitor the CPU/Memory utilizations 14 | 15 | - Application Monitoring 16 | 17 | - AppDynamics / DataDog 18 | 19 | - Production Support / Monitoring Team ==> 24/7 need for production 20 | 21 | Production Server ::: -> req. no. of cpus, ram .. 22 | 23 | - Deploy the applications 24 | 25 | 26 | 27 | Prometheus ==> Monitoring Tool 28 | 29 | Grafana ==> Visualization Tool 30 | 31 | 32 | Architecture of Monitoring Tool ::: 33 | 34 | - Prometheus Architecture 35 | 36 | - Time Series Database ===================> Grafana 37 | 38 | - PromQL 39 | 40 | - Install and Configure Prometheus and Grafana 41 | run as a web services 42 | 43 | https://prometheus.io/download/ 44 | 45 | 46 | 47 | - Create Monitoring Dashboards using Grafana 48 | 49 | Next : 50 | 51 | Setup Prometheus, Node Exporter & Grafana 52 | Create Grafana Dashbroads 53 | 54 | 55 | 56 | ####################### 57 | Day 45: 9th Oct. 2024 58 | ####################### 59 | 60 | 61 | Setup Prometheus, Node Exporter & Grafana 62 | 63 | Monitoring Server --> Install Prometheus & Grafana 64 | 65 | Target_Server --> Install Node_Exporter 66 | 67 | AC * A_Nodes 68 | 69 | 70 | -------------------------------------------------------------------------------- /Monitoring/Promethes_Grafana_Setup.txt: -------------------------------------------------------------------------------- 1 | #Install Prometheus & Grafana : 2 | 3 | ### Goto https://prometheus.io/download/ 4 | 5 | wget https://github.com/prometheus/prometheus/releases/download/v2.48.0-rc.0/prometheus-2.48.0-rc.0.linux-amd64.tar.gz 6 | 7 | 8 | tar -zxvf prometheus-2.48.0-rc.0.linux-amd64.tar.gz 9 | 10 | 11 | ###===> Create following file: 12 | 13 | sudo vi /etc/systemd/system/prometheus.service 14 | #------------------------------------------------------------------------- 15 | 16 | [Unit] 17 | Description=Prometheus Server 18 | Documentation=https://prometheus.io/docs/introduction/overview/ 19 | After=network-online.target 20 | 21 | [Service] 22 | User=root 23 | Restart=on-failure 24 | 25 | ExecStart=/root/prometheus-2.48.0-rc.0.linux-amd64/prometheus --config.file=/root/prometheus-2.48.0-rc.0.linux-amd64/prometheus.yml 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | 30 | #------------------------------------------------------------------------- 31 | 32 | sudo systemctl daemon-reload 33 | sudo systemctl status prometheus 34 | sudo systemctl start prometheus 35 | systemctl enable prometheus 36 | 37 | :9090 38 | http://43.204.238.185:9090/ 39 | 13.235.80.50 40 | 41 | 3.110.190.177:9090 42 | ####************************************* ********************************** 43 | 44 | 45 | #Install Grafana : 46 | 47 | ### Goto https://grafana.com/grafana/download 48 | 49 | ###select OSS Edition. 50 | #Choose Linux 51 | 52 | ## Linux Distribution : 53 | 54 | Red Hat, CentOS, RHEL, and Fedora(64 Bit)SHA256: 55 | 56 | wget https://dl.grafana.com/oss/release/grafana-9.1.2-1.x86_64.rpm 57 | 58 | sudo yum install grafana-9.1.2-1.x86_64.rpm -y 59 | 60 | 61 | sudo /bin/systemctl enable grafana-server.service 62 | sudo /bin/systemctl start grafana-server.service 63 | sudo /bin/systemctl status grafana-server.service 64 | 65 | :3000 66 | http://43.204.238.185:3000/ 67 | 68 | 3.110.190.177:3000 69 | default user name & password : admin & admin 70 | 71 | 72 | ###********************************************************************* 73 | 74 | ###Install Node Exporters: 75 | 76 | ### Goto https://prometheus.io/download/ 77 | 78 | ## Search for Node Exporter: 79 | ##Copy Link Linux address 80 | ### https://github.com/prometheus/node_exporter/releases/download/v1.4.0-rc.0/node_exporter-1.4.0-rc.0.linux-amd64.tar.gz 81 | 82 | 83 | ###Goto the server you wish to monitor and install Node Exporter : 84 | 85 | https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz 86 | 87 | wget https://github.com/prometheus/node_exporter/releases/download/v1.4.0-rc.0/node_exporter-1.4.0-rc.0.linux-amd64.tar.gz 88 | 89 | tar -zxvf node_exporter-1.4.0-rc.0.linux-amd64.tar.gz 90 | 91 | ###===> Create following file: 92 | 93 | sudo vi /etc/systemd/system/node_exporter.service 94 | #------------------------------------------------------------------------- 95 | 96 | [Unit] 97 | Description=Prometheus Server 98 | Documentation=https://prometheus.io/docs/introduction/overview/ 99 | After=network-online.target 100 | 101 | [Service] 102 | User=root 103 | Restart=on-failure 104 | 105 | ExecStart=/root/node_exporter-1.4.0-rc.0.linux-amd64/node_exporter 106 | 107 | [Install] 108 | WantedBy=multi-user.target 109 | 110 | #------------------------------------------------------------------------- 111 | 112 | sudo systemctl daemon-reload 113 | sudo systemctl status node_exporter 114 | sudo systemctl start node_exporter 115 | 116 | hostname 117 | 118 | hostname -i 119 | 120 | ### copy the IP Address of the server you wish to monitor 121 | 122 | ## Goto to Prometheus Server :: 123 | 124 | ### installation path 125 | cd /root/prometheus-2.38.0.linux-amd64 126 | 127 | vi prometheus.yml 128 | ## Add the target with valid node_exporter port as mentioned below: 129 | 130 | - targets: ["172.31.7.220:9100"] 131 | 132 | 133 | ## Restart Prometheus: 134 | 135 | sudo systemctl restart prometheus 136 | sudo systemctl status prometheus 137 | 138 | ###Goto Prometheus server : 139 | 140 | :9090 141 | http://13.232.146.141:9090/ 142 | 143 | ## in the query field type up and click on execute to see the list of servers up for monitoring 144 | 145 | 146 | ##******************************************************************************************************* 147 | 148 | ###Create Prometheus Data Source in Grafana 149 | 150 | ###Goto Grafana 151 | 152 | ##:3000 153 | ##http://13.232.146.141:3000/ 154 | 155 | Click on settings button --> Data Source --> Add Data Source --> Select Prometheus 156 | 157 | http://13.127.218.51/:9090/ 158 | 159 | http://43.204.38.168:9090/ 160 | 161 | Enter in the Name field as Prometheus 162 | Enter in the url field as the prometheus-server url with port eg.: :9090 | http://13.232.146.141:9090/ 163 | 164 | Click on Save & Test --- for Data Source is working 165 | Click on Back Button 166 | See the Prometheus Data Source Created 167 | 168 | 169 | Test in Prometheus-server query 170 | 171 | https://prometheus.io/docs/prometheus/latest/querying/examples/ 172 | 173 | sum by(mode)(irate(node_cpu_seconds_total{mode!="idle"}[5m])) > 0 174 | 175 | sum by(mode)(irate(node_cpu_seconds_total{mode!="idle"}[5m])) > 0 176 | 177 | Goto grafana and cl 178 | 179 | time() - node_boot_time_seconds{} 180 | 181 | 100 * (1 - ((avg_over_time(node_memory_MemFree_bytes[10m]) + avg_over_time(node_memory_Cached_bytes[10m]) + avg_over_time(node_memory_Buffers_bytes[10m])) / avg_over_time(node_memory_MemTotal_bytes[10m]))) 182 | 183 | 184 | AppDynamics ==> 185 | DynaTrace ==> 186 | 187 | -------------------------------------------------------------------------------- /Project/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | 3 | ####################### 4 | Day 49: 17th Oct. 2024 5 | ####################### 6 | 7 | Capstone Project :::: 8 | 9 | Domain Knowledge : 10 | 11 | - Banking / Retail / HealthCare / Insurance / Auto 12 | 13 | 14 | ####################### 15 | Day 50: 18th Oct. 2024 16 | ####################### 17 | 18 | Monolith Application Architecture ::: 19 | 20 | - Application is tightly coupled. 21 | - It is not easy to split and deploy any function independently 22 | 23 | - Only Continuous Delivery can be possible with the Monolith Application Architecture 24 | 25 | Micro-Service Based Application Architecture :: 26 | 27 | - Application is loosely coupled. 28 | - The functions/Modules are called as microservice 29 | - Each Micro-Service can be independently created, test, and deployed to prod, without any manual intervension 30 | 31 | - Continuous Deployment can be possible with the Micro-Service Based Application Architecture 32 | 33 | 34 | 35 | 36 | DevOps Assessment : 37 | 38 | - Interact with all the teams and collect the detailed requirements 39 | 40 | 41 | 42 | Phase 1 : 43 | -> Infra-Structure Provisioning and Configurations 44 | - Using Terraform and Ansible 45 | - Using AWS Console 46 | 47 | 48 | Phase 2 : 49 | -> Automation of Application Builds & Deployments 50 | - Using Jenkins CICD Pipelines 51 | 52 | 53 | Phase 3 : 54 | -> Monitoring of Infra-Structure 55 | - Using Prometheus & Grafana 56 | 57 | 58 | What are the Servers(VM) needed ? 59 | 60 | What are the tools to be configured in each server ? 61 | 62 | What are the stages of CICD Pipeline ? 63 | 64 | 65 | 66 | Implementation Procedures/Steps ::: 67 | 68 | ##################################### For More Details refer to ::: Class Notes & Recording of ==> Day 40: 27th Sep. 2024 69 | 70 | 71 | 1. List of Server(VMs)? 72 | 73 | - Infra-Structure Perspective 74 | 75 | - Create AWS EC2 Instances - Terraform 76 | - Configure the servers - Ansible 77 | 78 | 79 | - DevOps Perspective - Create CI/CD Pipeline to automate build and deployments 80 | 81 | - Jenkins_Master Node # VM1 82 | Jenkins_Slave Node # VM2 83 | Kubernetes_Master # VM3 84 | Kubernetes_WorkerNode1 # VM4 85 | Kubernetes_WorkerNode2 # VM5 86 | 87 | 88 | - Production Support/Monitor Teams' Perspective 89 | 90 | - Monitor the Kubernetes Cluster/Jenkins_Slave_Nodes using Prometheus & Grafana 91 | 92 | 93 | Servers ::: 94 | 95 | Jenkins_Master --> # To create CICD Pipeline Jobs and schedule it to run in Slave Nodes 96 | 97 | Build_Server-Jenkins_Slave --> # Compile the Source Code 98 | (Perform Application Build and Docker Build) # Perform Unit Testing 99 | # Create Artifacts 100 | # Create Application Image 101 | # Publish Application Image to DockerHub Registry 102 | 103 | Kubernetes_Master --> Schedule Pod Deployments 104 | Kubernetes_WorkNode1 --> Execute the Pods 105 | Kubernetes_WorkNode2 --> Execute the Pods 106 | 107 | 108 | 2. Tools :::: 109 | 110 | Jenkins_Master ---> # jdk, jenkins, git 111 | Build_Server-Jenkins_Slave ---> # git, jdk, maven, docker 112 | Kubernetes_Master ---> # All Kubernetes Components 113 | Kubernetes_WorkNode1 114 | Kubernetes_WorkNode2 115 | 116 | Maintain DockerHub Credentials in the Jenkins Credential Manager 117 | goto jenkins dashboard 118 | -- Manage Jenkins 119 | -- Credential 120 | -- using dockerhub username and access token 121 | 122 | 123 | Integration of Kubernetes Master Node with Jenkins Master Node. 124 | 125 | - Using Publish over ssh plugins, integrate Kubernetes_Master Node to Jenkins Master Node 126 | - And Execute kubectl create command using Publish over ssh plugins 127 | 128 | --> 1. Create a devopsadmin - User in Kubernetes_Master 129 | --> 2. Create SSH Keys to devopsadmin - User 130 | --> 3. Ensure that devopsadmin - User have access to execute kubectl commands 131 | --> 4. Use, the Kubernetes - Master Node's - Private IP Address,User_Name and Credential to config in Jenkins - Publish Over SSH 132 | --> 5. Create a Pipeline Deployment Stage using Publish Over SSH Plugins step 133 | - To copy the kubernetes manifest file - *.yaml file from jenkins_Slave Node to Kubernetes Master Node. 134 | - To execute a command : kubectl apply -f kubernetesdeploy.yaml 135 | 136 | Check list : 137 | 138 | Input Source Code Repository : https://github.com/StarAgileDevOpsTraining/star-agile-banking-finance.git 139 | 140 | Firstly, fork the repository and use your own repository in the pipeline 141 | 142 | 1. Launch all the Required VMs ==> AWS AMI - Ubuntu v22.04 - (Create using Terraform/AWS Console) 143 | 2. Ensure all the Required Ports are enabled using Security Group(Inbound Rules) 144 | 3. Install all the Required Tools in each VM ==> Manual / Ansible Playbooks 145 | 4. Create User in all the Required VMs with proper ssh keys to enable authentication 146 | 5. Setup the connection between the servers 147 | 6. Validate the Connection 148 | 7. Create CICD Pipeline with all these 6 stages 149 | 8. Validate the CICD Pipeline for Application Build, Docker Images, and Deployments in Kubernetes 150 | 151 | Enhance the project using github webhook(Make the code changes and trigger the build) & Email Notification 152 | 153 | 154 | 155 | 3. CICD Pipeline Stages ::: 156 | 157 | - SCM Checkout 158 | 159 | - Application Build 160 | 161 | - Application Image Build 162 | 163 | - Login to DockerHub 164 | 165 | - Publish Application Image to DockerHub Container Registry 166 | 167 | - Deploy the Application Images to Target Environments(DEV/STAGE/PROD) using Kubernetes 168 | 169 | 170 | pipeline { 171 | agent { label 'slave1' } 172 | 173 | environment { 174 | DOCKERHUB_CREDENTIALS=credentials('dockerloginid') 175 | } 176 | 177 | stages { 178 | stage('SCM_Checkout') 179 | steps { 180 | echo 'Perform SCM Checkout' 181 | git 'https://github.com/SA-AWS-DevOps-July24/BankingApp.git' 182 | } 183 | } 184 | stage('Application Build') { 185 | steps { 186 | echo 'Perform Application Build' 187 | sh 'mvn clean package' 188 | } 189 | } 190 | stage('Docker Build') { 191 | steps { 192 | echo 'Perform Docker Build' 193 | sh "docker build -t loksaieta/bankapp-eta-app:${BUILD_NUMBER} ." 194 | sh "docker tag loksaieta/bankapp-eta-app:${BUILD_NUMBER} loksaieta/bankapp-eta-app:latest" 195 | sh 'docker image list' 196 | } 197 | } 198 | stage('Login to Dockerhub') { 199 | steps { 200 | echo 'Login to DockerHub' 201 | sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' 202 | 203 | } 204 | } 205 | stage('Publish the Image to Dockerhub') { 206 | steps { 207 | echo 'Publish to DockerHub' 208 | sh "docker push loksaieta/bankapp-eta-app:latest" 209 | } 210 | } 211 | stage('Deploy to Kubernetes Cluster') { 212 | steps { 213 | script { 214 | sshPublisher(publishers: [sshPublisherDesc(configName: 'SA_WD_Kubernetes_Master', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'kubectl apply -f kubernetesdeploy.yaml', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '.', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.yaml')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) 215 | } 216 | } 217 | } 218 | } 219 | } 220 | 221 | apiVersion: apps/v1 222 | kind: Deployment 223 | metadata: 224 | name: bankapp-eta-deploy 225 | labels: 226 | app: bankapp-eta-app 227 | spec: 228 | replicas: 3 229 | selector: 230 | matchLabels: 231 | app: bankapp-eta-app 232 | template: 233 | metadata: 234 | labels: 235 | app: bankapp-eta-app 236 | spec: 237 | containers: 238 | - name: bankapp-eta-container 239 | image: loksaieta/bankapp-eta-app 240 | ports: 241 | - containerPort: 8082 242 | --- 243 | apiVersion: v1 244 | kind: Service 245 | metadata: 246 | name: bankapp-eta-np-service 247 | labels: 248 | app: bankapp-eta-app 249 | spec: 250 | selector: 251 | app: bankapp-eta-app 252 | 253 | type: NodePort 254 | ports: 255 | - nodePort: 31030 256 | port: 8082 257 | targetPort: 8082 258 | 259 | 260 | 261 | ####################### 262 | Day 51: 21st Oct. 2024 263 | ####################### 264 | 265 | Demo Banking Project : 266 | 267 | Jenkins FAQs 268 | 269 | Docker FAQs 270 | 271 | 272 | Core Concepts 273 | 274 | Hands-On Experience on Core Concepts 275 | 276 | FAQs 277 | 278 | Project --> 279 | 280 | What is the project is all about ? 281 | 282 | What are all the Tools used in the project? 283 | 284 | What is your roles & Responsibilies in your project ? 285 | 286 | What are the Challenges faced ? 287 | 288 | E_Mail Notifications in Jenkins pipeline stages 289 | 290 | 291 | 292 | Use Case :: 293 | 294 | Scenario 1: 295 | 296 | Pipeline 1 : Infra-Structure Provisioning & Configurations 297 | 298 | - SCM_Checkout --> Create New_Test_Server(Terraform) --> Configure New_Test_Server(Ansible) 299 | 300 | Pipeline 2 : CICD 301 | 302 | - SCM_Checkout --> Application Build --> Deploy the Changes to New_Test_Server --> Automated_Testing 303 | | 304 | | 305 | Generate Test Reports 306 | 307 | Scenario 2: 308 | 309 | Pipeline 1 : Test Server Provisioning,Configurations & CICD 310 | 311 | SCM_Checkout --> Application_Build --> Create New_Test_Server(Terraform) --> Configure New_Test_Server(Ansible) 312 | | 313 | | 314 | | 315 | Deploy the Changes to New_Test_Server 316 | | 317 | | 318 | | 319 | Automated_Testing 320 | | 321 | | 322 | | 323 | Generate & Email the Test Reports 324 | | 325 | | 326 | | 327 | Destroy New_Test_Server 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | -------------------------------------------------------------------------------- /Python/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | ####################### 3 | Day 46: 10th Oct. 2024 4 | ####################### 5 | 6 | Fundamentals of Python ::: 7 | 8 | 1. Overview of Python 9 | 2. Features, Benefits, Uses of Python 10 | 3. Installation and Setup of Python Environment 11 | 4. Various Types of Sequencesin Python 12 | 5. File Operations 13 | 6. Python Functions 14 | 7. OOPs Concepts 15 | 8. Modules 16 | 9. Errors and Exception Handling 17 | 10. Python Console based application and Web Application using Flask 18 | 11. Deploying and Consuming Python Applications 19 | 20 | Shell Scripting ?? 21 | 22 | Programming Languages ==> Used to Develop Business Applications 23 | 24 | (vs) 25 | 26 | Scripting Languages ==> Used to perform any process automation 27 | 28 | 29 | Use-Cases ::: 30 | 31 | Scripting Languages ::: 32 | 33 | 34 | Common Features or Concepts ??? 35 | 36 | 37 | Integrated Development Environment for Python - IDLE 38 | 39 | Pycharm 40 | 41 | Visual Studio Code 42 | 43 | 44 | Validation Program : 45 | 46 | The User Credentials -- for login_page 47 | - Involves Database validation 48 | 49 | - Programming Languages - Java/C# 50 | 51 | Validation Program : 52 | 53 | Client Side Scripting 54 | 55 | - Scripting Languages 56 | 57 | xxxx@yyyy.com 58 | 59 | xxxx 60 | 61 | xxx#asdf.com 62 | 63 | xxx@adfs 64 | 65 | 66 | Tools --> 67 | 68 | Logical Thinking! 69 | 70 | 71 | Programming/Scripting Logic ???? 72 | 73 | Python -- Tools 74 | 75 | 76 | Problem Statement :: 77 | - 78 | 79 | What are all the steps involved to Create the program / source code? 80 | 81 | Analyze the Requirement 82 | Design the solution 83 | -> Algorithms 84 | - Step-by-Step process to achieve any task 85 | - Written in high-level language. It is independent of any Programming/Scripting Languages 86 | - Algorithms should always be an optimized one 87 | - It should be reusable and easily maintainable 88 | 89 | -> PsudoCode 90 | - Step-by-Step process to achieve any task 91 | - It is based on the programming/Scripting Language 92 | 93 | -> Program workflow - Flowcharts -- graphical views 94 | 95 | Create a program/source code using actual programming/Scripting Language 96 | 97 | 1. 98 | a = 60 99 | 100 | b = 30 101 | 102 | c = 87 103 | 104 | 105 | Which is greatest number ? result is ' c ' 106 | 107 | Algorithm to find the greatest of these three numbers : 108 | 109 | 110 | 2. 111 | 112 | a = 70 113 | 114 | b = 40 115 | 116 | Swap the number : 117 | 118 | ==> Output : a = 40 & b = 70 119 | 120 | a,b = b,a # Is this valid ? 121 | 122 | 123 | 124 | use new variable c ? 125 | 126 | c = a 127 | 128 | a = b 129 | 130 | b = c 131 | 132 | 3. 133 | 134 | a = * 135 | 136 | b = $ 137 | 138 | Swap a and b : 139 | 140 | ==> Output : a = $ & b = * 141 | 142 | 143 | 4. 144 | 145 | a = * 146 | 147 | 148 | Print : 149 | 150 | * 151 | 152 | 153 | 154 | 5. a = * 155 | 156 | Print output : 157 | 158 | * 159 | * * 160 | * * * 161 | * * * * 162 | * * * * * 163 | 164 | 165 | 6. a = * 166 | 167 | Print output : 168 | 169 | * * * * * 170 | * * * 171 | * 172 | * * * 173 | * * * * * 174 | 175 | 176 | 7. a = 1 177 | 178 | Print output : 179 | 180 | 1 181 | 182 | 2 2 183 | 184 | 3 3 3 185 | 186 | 4 4 4 4 187 | 188 | 5 5 5 5 5 189 | 190 | 191 | 192 | Working with Python ::: 193 | 194 | - Install Python # https://www.python.org/downloads/ 195 | 196 | - Install IDE - Visual Studio Code 197 | 198 | 199 | 200 | Data :: 201 | 202 | 203 | variable a = 5 204 | 205 | variable b = "Hello" 206 | 207 | 208 | 209 | 210 | Functions ::: 211 | 212 | - Function is a collection of variables and commands used to perform any task. 213 | 214 | 215 | >>>print("Hello") 1000 times ? 216 | Hello 217 | 218 | Varibles 219 | ==> Local Varibles that are defined within the functions 220 | ==> Global Variables that are defined outside the functions 221 | 222 | Scope of the Variable is based on the declaration. 223 | 224 | 225 | 226 | z = 100; 227 | 228 | print(z) # will work ==> 100 229 | 230 | def sum() # Function Definition 231 | { 232 | a = 5 233 | b = 10 234 | print(a) # will work 235 | c = a + b # 15! 236 | global z 237 | print(z) # 100 238 | z = 300 239 | print(z) # 300 240 | 241 | } 242 | 243 | print(a) # will not work | Function call 244 | print(z) # 300 # Updated data 245 | 246 | 247 | 248 | 249 | ####################### 250 | Day 47: 14th Oct. 2024 251 | ####################### 252 | 253 | Python Fundamentals ::: 254 | 255 | 256 | ansible_facts{ 257 | os_family : "Debian"; 258 | os_Type : "Linux" 259 | } 260 | 261 | 262 | 263 | Email_ID = "asdfasdfa@asdf.com" 264 | 265 | Comm_Address = """asdfasdfasdfasd 266 | asdfasdfasdfasdf 267 | adfsdfasdfasdfasdf""" 268 | 269 | 270 | 271 | 272 | Var1 = ansible_facts 273 | 274 | x = 5 275 | 276 | 277 | 278 | print str1 ==> # Print entire value 279 | 280 | 281 | Array # Is a group of variables with same name and datatype. 282 | # Each Element in array is identified by an index 283 | # Index are used to uniquely identify the elment in array. 284 | 285 | Eg.: a[5] a = {1,2,3,4,5} 286 | 287 | a[0] = 1 288 | 289 | a[1] = 2 290 | 291 | a[4] = 5 292 | 293 | 294 | In python, we have list that is similar to array 295 | List can have different types of data. 296 | 297 | 298 | list1 = [1,2,3,"hi","Hello"] 299 | 300 | sum(int a, int b) 301 | { 302 | c = a + b 303 | } 304 | 305 | 306 | List ===> [1,2,"hello"] # Updatable 307 | 308 | Set ===> {1,2,3,4} # Unique, Updatable 309 | 310 | Tuple ===> (1,2,3,4) # Non-Updatable 311 | 312 | Dictionary ===> {key1:value1,key2:value2} # Json file handling 313 | 314 | if 315 | { 316 | if 317 | { 318 | if 319 | { 320 | 321 | } 322 | } 323 | 324 | } 325 | 326 | sa-instance1[5] = 327 | 328 | resource "aws_instance" "sa-instance1" { 329 | 330 | ami = "ami-0dee22c13ea7a9a67" 331 | instance_type = "t2.micro" 332 | key_name = "ali-key" 333 | count = 5 334 | 335 | tags = { 336 | Name = "Terrfaorm-TestInstance1" 337 |   } 338 | } 339 | resource "aws_instance" "sa-instance2" { 340 | 341 | ami = "ami-0dee22c13ea7a9a67" 342 | instance_type = "t2.medium" 343 | key_name = "ali-key" 344 | 345 | tags = { 346 | Name = "Terrfaorm-TestInstance1" 347 |   } 348 | } 349 | sir in the above resource "aws_instance" "sa-instance1" 350 | can you explain this line? 351 | this is from terraform module 352 | 353 | 354 | 355 | ####################### 356 | Day 48: 16th Oct. 2024 357 | ####################### 358 | 359 | On Visual Studio Code 360 | 361 | Install Python extension for Visual Studio Code 362 | 363 | 364 | x = 5 365 | y = 6 366 | print("Value of x:", x) 367 | print("Value of y:", y) 368 | print(8) 369 | print(x) 370 | 371 | 372 | x = input("Number: ") 373 | 374 | if x < 0 or x > 10: 375 | print("Invalid number") 376 | else: 377 | print("Good choice") 378 | 379 | 380 | 381 | 382 | year 2024 383 | months 12 384 | weeks 4 385 | days 7 386 | 387 | 388 | 389 | 390 | numbers = [2,3,4,5,6] # index start from 0. i.e., -> i[0]=2,i[1]=3,i[2]=4.....i[4]=6 391 | n=len(numbers) # 5 392 | 393 | for(i=0;i True, print 394 | print(i) # 0, 395 | print(numbers[i]) # 2, 396 | # Add 1 to i ==> 397 | # i = 1; 1 < 5 ==> True, print 398 | # 1, 399 | # 3, 400 | # Add 1 to i ==> 401 | # i = 2; 2 < 5 ==> True, print 402 | # 2, 403 | # 4, 404 | # Add 1 to i ==> 405 | # i = 3; 3 < 5 ==> True, print 406 | # 3, 407 | # 5, 408 | # Add 1 to i ==> 409 | # i = 4; 4 < 5 ==> True, print 410 | # 4, 411 | # 6, 412 | # Add 1 to i ==> 413 | # i = 5; 5 < 5 ==> False, EXIT from loop 414 | 415 | 416 | list1 = [1,2,3,4,5,6,7,8,9,10] 417 | n=len(list1) 418 | 419 | for(i=0;i Collection of Functions and Variables 440 | 441 | - Object -> Instance of Class 442 | 443 | Class devOps { 444 | aws() # Modules - Functions 445 | azure() 446 | } 447 | 448 | Class devOps1 { 449 | aws() 450 | azure() 451 | } 452 | 453 | devOps d; 454 | 455 | d.aws() 456 | 457 | d.azure() 458 | 459 | 460 | devOps1 d1; 461 | 462 | d1.aws() 463 | 464 | d1.azure() 465 | 466 | 467 | Inheritance ==> 468 | 469 | Class1 470 | { 471 | function1() 472 | function2() 473 | } 474 | 475 | Class2 : Class1 476 | { 477 | function3() 478 | function4() 479 | } 480 | 481 | Class1 obj1 482 | 483 | obj1.function1() 484 | obj1.function2() 485 | 486 | Class2 obj2 487 | 488 | obj2.function1() 489 | obj2.function3() 490 | obj2.function4() 491 | 492 | def sum(list): 493 | sum = 0 494 | for e in list: 495 | sum = sum + e 496 | return sum 497 | mylist = [1,2,3,4,5] 498 | print(sum(mylist)) 499 | 500 | How to develop Web Applications using Python. 501 | 502 | s1.json 503 | 504 | { 505 | "name" : "XYZ", 506 | "Dept" : "IT" 507 | } 508 | 509 | pyconsoleapp1.py 510 | 511 | filename = "s1.json" 512 | with open(filename) as f: 513 | lines = f.readlines() 514 | print(lines) 515 | i = 1 516 | for line in lines: 517 | print(str(i) + " " + line), 518 | i = i + 1 519 | 520 | 521 | py ./pyconsoleapp1.py 522 | 523 | 524 | 525 | Next :::: 526 | 527 | Web Application Server -> flask & Django Web Application Framework to develop web apps. 528 | 529 | 530 | flask WAS 531 | 532 | localhost web application 533 | 534 | 535 | 536 | Core Projects :::: 537 | 538 | 539 | 540 | ####################### 541 | Day 49: 17th Oct. 2024 542 | ####################### 543 | 544 | Python Web Application using flask Web Application Server. 545 | 546 | Prepare the python project to create web application 547 | 548 | Flask WAS 549 | 550 | Demo using Python Web Application 551 | 552 | 553 | Capstone Project Discussion: 554 | 555 | 556 | 1. Python web application : 557 | 558 | Open Visual Studio Code 559 | Create Project Folder : 560 | 561 | ################################## 562 | 563 | Folder Structure : 564 | 565 | My-WebApp-Project 566 | app.py 567 | templates 568 | sample.html 569 | 570 | ################################## 571 | 572 | Open New Terminal : 573 | 574 | Install : Web Application Framework 575 | pip install flask 576 | 577 | Create app.py 578 | 579 | from flask import Flask, render_template 580 | 581 | app = Flask(__name__) 582 | 583 | @app.route('/') 584 | 585 | def sample(): 586 | return render_template("sample.html") 587 | 588 | if "__name__" == "__main__": 589 | app.run(debug=True) 590 | 591 | 592 | Create "templates" folder at root level ::: 593 | Create Html files :: eg. sample.html 594 | 595 | 596 | 597 | 598 | 599 | www.loksaieta.com 600 | 601 | 602 | 603 |
604 | Spidertocat 606 |

Hello Everyone

607 |

Python Demo...

608 |
609 | 610 | 611 | 612 | 613 | set FLASK_APP=sample 614 | 615 | python -m flask run 616 | 617 | 618 | 619 | #python boto3 / terraform / cloudformation 620 | 621 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 622 | -------------------------------------------------------------------------------- /Python/Python Programming Excercise.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SA-AWS-DevOps-July24/Training_Documents/d981e63f09bf56f2374fce08d46c598d7ce9dc8d/Python/Python Programming Excercise.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Training_Documents 2 | Training_Documents 3 | -------------------------------------------------------------------------------- /Terraform/Class_Notes.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | Day 43: 4th Oct. 2024 3 | ####################### 4 | 5 | 6 | Terraform ::: 7 | 8 | - Is a IAC Tool - Used to Provision the Infra-Structure 9 | 10 | - Terraform uses HCL - Hashi-Corp Declarative Language (JSON file format) 11 | 12 | - Terraform Working Model 13 | 14 | --> Identify the Scope of the Infra-Structure (AWS/Azure) 15 | 16 | --> Write the Terraform Script 17 | 18 | --> Perform Terraform Init - Initialize the Terraform Providers 19 | - To Download Terraform Provider to Terraform Project 20 | 21 | --> Perform Terraform Plan - Preview the Terraform Script 22 | 23 | --> Perform Terraform Apply - To Implement the actual Changes to the target infra-structure 24 | 25 | 26 | Working with Terraform ::: 27 | 28 | - Install Terraform --> Local Windows Machine / Linux Machine 29 | 30 | https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli 31 | 32 | https://developer.hashicorp.com/terraform/install 33 | 34 | 35 | Using Manual Approach - Install Terraform on local windows machine 36 | 37 | - Download Windows AMD64 Version Terraform -- zipfile 38 | - Right Click and Extract all 39 | - Get the Extracted Terraform Folder 40 | - Get the terraform - binary file 41 | 42 | - Setup Environment Variable for terraform binary file 43 | - from windows start menu, search for enviroment variable 44 | - click of edit enviroment variable setting 45 | - find system properties dialog 46 | - select enviroment variables button 47 | - On Environment Variables Dialog 48 | - goto to System Variable 49 | - Select path variable and edit 50 | - Click on New 51 | - add C:\Softwares\terraform_1.7.2_windows_amd64 52 | - apply the changes and close the settings 53 | 54 | - Install Visual Studio Code - IDE used to create Terraform Projects 55 | 56 | https://code.visualstudio.com/download 57 | 58 | 59 | - Open Visual Studio Code - Create Terraform Project 60 | 61 | Next ::: 62 | 63 | --> Define the Terraform Script 64 | 65 | --> Provision the Resources 66 | 67 | --> Concepts related to Terraform 68 | 69 | --> Prometheus and Grafana 70 | 71 | 72 | 73 | 74 | ####################### 75 | Day 44: 7th Oct. 2024 76 | ####################### 77 | 78 | - Terraform Working Model 79 | 80 | --> Identify the Scope of the Infra-Structure (AWS/Azure) 81 | 82 | --> Write the Terraform Script 83 | 84 | --> Perform Terraform Init - Initialize the Terraform Providers 85 | - To Download Terraform Provider to Terraform Project 86 | 87 | --> Perform Terraform Plan - Preview the Terraform Script 88 | 89 | --> Perform Terraform Apply - To Implement the actual Changes to the target infra-structure 90 | 91 | 92 | 93 | How to provision EC2 Instance and other assosicated resources on AWS using Terraform 94 | 95 | - Open Visual Studio Code - Create Terraform Project 96 | 97 | On Visual Studio Code : Install Terraform Extension for Visual Studio Code 98 | 99 | HashiCorp Terraform 100 | 101 | 102 | Create AWS Access Key and AWS Secret Key 103 | 104 | 105 | Using Terraform : 106 | 107 | >> Create/Add Resources + 108 | 109 | >> Change/Modify Resources ~ 110 | 111 | >> Delete/Destroy Resources - 112 | 113 | 114 | 115 | Terraform State File 116 | ==> Is used by Terraform to maintain the state of the resources in the target infra-structure. 117 | 118 | ==> Preserve the Terraform State File !!!! 119 | 120 | 121 | terraform apply -auto-approve 122 | 123 | terraform import ! 124 | 125 | - Generate a state file 126 | 127 | 128 | 129 | Terraform ==> Resource Provisioning 130 | 131 | Ansible ==> Configuration Management Tools 132 | 133 | -------------------------------------------------------------------------------- /Terraform/Terraform_Scripts.txt: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "ap-south-1" 3 | access_key = "AsadfXWY" 4 | secret_key = "LasdfaasdfT" 5 | } 6 | 7 | # Create AWS Instance 8 | 9 | resource "aws_instance" "sa-instance1" { 10 | 11 | ami = "ami-0dee22c13ea7a9a67" 12 | instance_type = "t2.micro" 13 | key_name = "may20-keypair" 14 | 15 | tags = { 16 | Name = "SA-TestInstance1" 17 | } 18 | } 19 | 20 | 21 | + => Add new resource 22 | ~ => update any existing resource 23 | - => Delete any existing resource 24 | 25 | 26 | terraform init 27 | 28 | terraform plan 29 | 30 | terraform apply 31 | 32 | terraform destroy 33 | 34 | terraform state list 35 | 36 | terraform apply -auto-approve 37 | 38 | 39 | 40 | ***************************************************************************************** 41 | 42 | 43 | 44 | 45 | Install Terraform --> Local Windows Machine!!! 46 | 47 | Use Command prompt to run Terraform commands like : terraform init, terraform plan, terraform apply, etc.. 48 | 49 | Create the Config file ? 50 | 51 | Visual Studio Code to create or develop Terraform Config files! i.e., *.tf files 52 | 53 | 54 | 55 | 56 | 57 | 58 | provider "aws" { 59 | region = "ap-south-1" 60 | access_key = "AKF" 61 | secret_key = "3i+D" 62 | } 63 | 64 | 65 | # Create VPC 66 | 67 | resource "aws_vpc" "myvpc9" { 68 | cidr_block = "10.0.0.0/16" 69 | instance_tenancy = "default" 70 | 71 | tags = { 72 | Name = "myvpc9" 73 | } 74 | } 75 | 76 | # Create Subnet 77 | 78 | resource "aws_subnet" "mysubnet9" { 79 | vpc_id = aws_vpc.myvpc9.id 80 | cidr_block = "10.0.1.0/24" 81 | 82 | tags = { 83 | Name = "mysubnet9" 84 | } 85 | } 86 | 87 | # Internet Gateway 88 | 89 | resource "aws_internet_gateway" "mygw9" { 90 | vpc_id = aws_vpc.myvpc9.id 91 | 92 | tags = { 93 | Name = "mygw9" 94 | } 95 | } 96 | 97 | # Route Table 98 | 99 | resource "aws_route_table" "myrt9" { 100 | vpc_id = aws_vpc.myvpc9.id 101 | 102 | route { 103 | cidr_block = "0.0.0.0/0" 104 | gateway_id = aws_internet_gateway.mygw9.id 105 | } 106 | 107 | tags = { 108 | Name = "myrt9" 109 | } 110 | } 111 | 112 | # Route Table Association 113 | 114 | resource "aws_route_table_association" "myrta9" { 115 | subnet_id = aws_subnet.mysubnet9.id 116 | route_table_id = aws_route_table.myrt9.id 117 | } 118 | 119 | # Security Groups 120 | 121 | resource "aws_security_group" "mysg9" { 122 | name = "mysg9" 123 | description = "Allow inbound traffic" 124 | vpc_id = aws_vpc.myvpc9.id 125 | 126 | ingress { 127 | description = "HTTP" 128 | from_port = 80 129 | to_port = 80 130 | protocol = "tcp" 131 | cidr_blocks = ["0.0.0.0/0"] 132 | } 133 | 134 | ingress { 135 | description = "SSH" 136 | from_port = 22 137 | to_port = 22 138 | protocol = "tcp" 139 | cidr_blocks = ["0.0.0.0/0"] 140 | } 141 | 142 | egress { 143 | from_port = 0 144 | to_port = 0 145 | protocol = "-1" 146 | cidr_blocks = ["0.0.0.0/0"] 147 | ipv6_cidr_blocks = ["::/0"] 148 | } 149 | 150 | tags = { 151 | Name = "mysg9" 152 | } 153 | } 154 | 155 | # Create Instance 156 | 157 | resource "aws_instance" "instance9" { 158 | ami = "ami-0f58b397bc5c1f2e8" 159 | instance_type = "t2.micro" 160 | associate_public_ip_address = true 161 | subnet_id = aws_subnet.mysubnet9.id 162 | vpc_security_group_ids = [aws_security_group.mysg9.id] 163 | key_name = "awskey-124" 164 | 165 | tags = { 166 | Name = "Dummy_Server0" 167 | } 168 | } 169 | 170 | 171 | -------------------------------------------------------------------------------- /dummy: -------------------------------------------------------------------------------- 1 | 2 | ~~~~~~~~~~~~~~~~~~~~~~~ 3 | Day 2: 14th July 2024 4 | ~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | 7 | Introduction to Cloud Platform 8 | 9 | AWS Free Tier Account 10 | 11 | Login to AWS Console 12 | 13 | Create EC2 Instances(Virtual Machines) 14 | 15 | Linux 16 | 17 | 18 | 19 | On-premises Environments 20 | 21 | Servers,Storage,Networking,Dbase 22 | 23 | Software - Cost 24 | 25 | Cloud Environments ::: 26 | 27 | Core Linux Administration ::: 28 | 29 | Linux Machine 30 | 31 | Hypervisor & VMs - 16 GB of RAM 2CPU 32 | 33 | 34 | Create AZURE / AWS - Account 35 | 36 | Create VMs 37 | 38 | 39 | Telecomm - SP1 -- Introduce a new service to their customers -> ASAP! IT Services 40 | Build Servers/Test Servers/Deployment servers 41 | 42 | SP2 43 | 44 | 45 | 46 | AWS Free Tier Account -- https://aws.amazon.com/console/ 47 | 48 | Active Email_ID & Mobile Number 49 | Active Credit/Debit Card - enabled with International Trancsaction 50 | 12 Months free tier account - 51 | 52 | 53 | 54 | Login to AWS Console 55 | 56 | Create EC2 Instances(Virtual Machines) 57 | 58 | Linux 59 | 60 | 61 | AWS Account Creation Process! 62 | 63 | https://aws.amazon.com/console/ 64 | 65 | 66 | Login to AWS Console ::: 67 | 68 | - Login as a root user (Using Email_ID & Password) # Default 69 | 70 | (or) 71 | 72 | - IAM User # Not Now! 73 | 74 | In AWS Cloud platform ::: 75 | 76 | Regions (Locations) 77 | 78 | Availability Zones (Data Centers) 79 | 80 | 81 | Upon Login to AWS Console 82 | - Choose set AWS Region. 83 | - Create the resources within that regions 84 | 85 | 86 | Billing Management ::: 87 | 88 | Free Tier :: 89 | 90 | 91 | Create EC2 Instances(Virtual Machines) ::: 92 | 93 | Select EC2 Service 94 | 95 | From EC2 Dashboard - Select Launch Instance 96 | 97 | 98 | How to Access the remote service? 99 | 100 | www.gmail.com 101 | 102 | - Web Browser 103 | - Authentication - UserName & Password 104 | 105 | 106 | AWS Platform 107 | EC2 Instance (Virtual Machine) 108 | 109 | - SSH Connection Protocol 110 | 111 | - Authentication Types : 112 | - Password Based Authentication 113 | - Token Based Authentication 114 | - Key Based Authentication 115 | - Public key and private key 116 | - Passwordless Authentication 117 | 118 | 119 | 1 VM == 750 Hrs/Month 120 | 121 | 10 VMs == 75 Hrs/Month 122 | 123 | It is always recommended to STOP the EC2 Instance if it is not in use! 124 | 125 | 126 | AMI 127 | 128 | Choose : Ubuntu v22.04 LTS AMI 129 | 130 | 131 | Windows 132 | Linux 133 | Mac 134 | 135 | 136 | Linux based AMI ::: 137 | 138 | Linux Open-Source Operating System : 139 | 140 | UNIX OS 141 | 142 | - Linux Distribution 143 | Package Manager (Used to Install/Uninstall/Upgrade the packages) 144 | Debian/Ubuntu apt-get / apt 145 | Centos/RHEL yum 146 | Fedora dnf 147 | Previous version of Fedora uses yum package manager 148 | 149 | 150 | Window OS --> 151 | 152 | - Windows Installer! -> Package Manager for Windows OS 153 | - Used to Install/Uninstall/Upgrade the packages ad 154 | 155 | 156 | 157 | 158 | Created the Instance ::: 159 | 160 | Running 161 | 162 | Instance ID (Uniquely Generated) 163 | 164 | Name/Tag (We assign) 165 | 166 | Host Name : 167 | 168 | Public IP Address (Will Change everytime we restart the Instance) 169 | 170 | Private IP Address (Constant IP Address, exist till you terminate the Instance) 171 | 172 | 173 | 174 | How to Connect to EC2 Instances ::: 175 | 176 | 177 | - Authentication Types : 178 | - Password Based Authentication 179 | - Token Based Authentication 180 | - Key Based Authentication 181 | - Public key and private key 182 | - Passwordless Authentication 183 | 184 | 185 | Host_Name 186 | User_Name 187 | Credentials 188 | 189 | - EC2 Instance Connect (Thru Browser - AWS Console) 190 | 191 | - SSH Agents : (Tool installed in the client machine to access Linux VMs) 192 | MobaXterm - https://mobaxterm.mobatek.net/download.html 193 | https://mobaxterm.mobatek.net/download-home-edition.html - Choose Installer Edition 194 | Download *.zip 195 | Extract & run the exec file 196 | 197 | Open MobaXterm Tool 198 | Select Session - Setting 199 | - Remote Host :Public IP Address 200 | - User Name : ubuntu 201 | - Advanced Setting 202 | - Choose Private key check box 203 | - browse thru the *.pem from downloads folder 204 | Putty 205 | 206 | - Terminal : # Ubuntu/Mac Users 207 | 208 | 209 | Create AWS Account 210 | 211 | Login to AWS Console as a root 212 | 213 | Goto EC2 Instance Dashboard 214 | 215 | Create EC2 Instance 216 | - Create Key Pair 217 | 218 | Connect to EC2 Instance using EC2 Instance Connect (Thru Browser - AWS Console) 219 | 220 | 221 | Fundamentals of Linux Operating System :: 222 | 223 | Overview of Linux 224 | Linux Architecture 225 | Linux Distributions 226 | Basic Linux Commands 227 | File Permission Management 228 | User Creation 229 | Shell Scripts 230 | SSH and VI Utility - Remote Server Access 231 | 232 | 233 | 234 | Operating System :: 235 | 236 | What is an Operating System ??? 237 | 238 | - Is an interface between the user application and the Hardware. 239 | 240 | Windows 241 | Linux 242 | Mac 243 | 244 | Android 245 | 246 | High End computation Servers 247 | 248 | - Reliable OS 249 | - Linux Based OS 250 | 251 | OS Architecture :: 252 | 253 | Linux - Kernel is the core of Linux 254 | 255 | Manage the Underlying Hardware, User Applications, External Resources, 256 | 257 | It create the process 258 | Each and every process runs in its own address space/volume 259 | Dedicated/Isolated path 260 | 261 | OS Kernel 262 | Namespace 263 | Control Group 264 | 265 | 266 | Executed as Command Line Utilities 267 | 268 | Traditional Linux are CUI (Command User Interface) Based 269 | 270 | Windows are GUI (Graphical User Interface) based 271 | 272 | Linux Distribution ::: 273 | 274 | AWS Cloud --> Ubuntu v22.04 ===> Azure --> Ubuntu v22.04 275 | 276 | 277 | 278 | - Linux Distribution 279 | Package Manager (Used to Install/Uninstall/Upgrade the packages) 280 | Debian/Ubuntu apt-get / apt 281 | Centos/RHEL yum 282 | Fedora dnf 283 | Previous version of Fedora uses yum package manager 284 | 285 | All the package Manager should be executed as a root user. 286 | 287 | 288 | 289 | Basic Linux Commands ::: 290 | 291 | 292 | sudo -i # To elevate the access to root level 293 | hostname -i 294 | clear 295 | ls 296 | pwd # present working directory 297 | 298 | 299 | 300 | ~~~~~~~~~~~~~~~~~~~~~~~ 301 | Day 3: 20th July 2024 302 | ~~~~~~~~~~~~~~~~~~~~~~~ 303 | 304 | Fundamentals of Linux Operating System :: 305 | 306 | Overview of Linux 307 | Linux Architecture 308 | Linux Distributions 309 | Basic Linux Commands 310 | File Permission Management 311 | User Creation 312 | Shell Scripts 313 | SSH and VI Utility - Remote Server Access 314 | 315 | 316 | 317 | - Linux Distribution 318 | Package Manager (Used to Install/Uninstall/Upgrade the packages) 319 | Debian/Ubuntu apt-get / apt 320 | Centos/RHEL yum 321 | Fedora dnf 322 | Previous version of Fedora uses yum package manager 323 | 324 | Why we need Linux ??? 325 | 326 | Linux OS 327 | 328 | Install and Manage all the DevOps Tools on Linux Machines 329 | 330 | Open-Source DevOps Tools : 331 | 332 | git,jenkins,docker,kubernetes/Prometheus/Grafana,ansible,terraform 333 | 334 | 335 | 336 | What is your role here ??? 337 | 338 | 339 | 1. Install the DevOps Tools 340 | 2. Manage the Tools -- Periodically Clean-up/Upgrade the tools 341 | 3. Remote access to the servers 342 | Client - Server Architecture 343 | 344 | Server 345 | - Client1,2,3,4,5 346 | 347 | 4. DevOps Team can Administrate the Linux Machines 348 | 349 | 1. Package Management - install/uninstall/upgrade 350 | 2. File Management 351 | 3. User Management 352 | 4. Access Management 353 | 5. Remote Server Management 354 | 6. Process Automation 355 | 356 | Working with Linux OS : 357 | 358 | - Basic Linux Commands 359 | 360 | clear 361 | 362 | root user will have complete admin access to Linux Machine. 363 | 364 | - Linux Distribution 365 | Package Manager (Used to Install/Uninstall/Upgrade the packages) 366 | Debian/Ubuntu apt-get / apt 367 | Centos/RHEL yum 368 | Fedora dnf 369 | Previous version of Fedora uses yum package manager 370 | 371 | 372 | 1. Package Management - install/uninstall/upgrade 373 | clear # Clean the Command 374 | sudo -i # to elevate the access to root level 375 | Used to execute package manager 376 | 377 | apt update -y # used to update the default packages 378 | 379 | git,maven,docker,jenkin,ansible 380 | 381 | apt install git -y 382 | 383 | git --version 384 | 385 | apt install maven -y 386 | 387 | apt install tree -y 388 | 389 | apt install nginx -y 390 | 391 | apt remove git -y 392 | 393 | apt upgrade git -y 394 | 395 | 396 | File related commands ::: 397 | 398 | 2. File Management 399 | 400 | Directory # Is folder - collections of files & sub-folders 401 | - File Access Mode 402 | - Read/Write/Execute 403 | 404 | 405 | For any user in Linux, will have a home directory 406 | 407 | pwd # show Present working directory 408 | 409 | cd # Change Directory 410 | 411 | cd / # Control will be take to the root directory at the system level 412 | 413 | cd ~ # Control will be taken to the home directory of the user level 414 | 415 | exit # Used to logout from a user 416 | 417 | ls # Used to List the files and directories of the current path 418 | 419 | echo # Used to print the message on terminal/Console 420 | 421 | Create the files ::: 422 | 423 | 1. echo "Hello Everyone" >> file1.txt # Create the file 424 | echo "Session1" > file.txt 425 | 426 | cat file1.txt # To print the content of the file 427 | 428 | 2. touch file2.txt # Used to create empty file 429 | 430 | 3. vi file3.txt # Create or edit a file using vi editor 431 | 432 | 433 | Press i # goto insert mode 434 | Type the file contents 435 | 436 | Press ===> esc key 437 | Type ===> :wq # Save and Exit from vi editor 438 | Type ===> :q! # Exit from vi editor without saving the changes 439 | 440 | 441 | ll # Long List 442 | 443 | mkdir # Make / Create Directory 444 | 445 | cd .. # go back to previous directory 446 | 447 | 448 | Working with Directories :::: 449 | 450 | Hidden Files/Directories --> 451 | 452 | all the hidden files/directories will be prefixed with . 453 | 454 | 455 | echo "rec1" >> .s1.txt # Create a hidden file 456 | 457 | mkdir .dir2 # Create Hidden Directory 458 | 459 | mv s1.txt payment.text # Rename a file 460 | 461 | mv s2.txt subdir1/ # Move the file from one dir to another 462 | 463 | cp s1.txt subdir1/ # Copy the file from one dir to another 464 | 465 | rm -rf subdir1/ # Remove the folder 466 | 467 | rm file1.txt # Remove the file 468 | 469 | rm *.java # Remove Multiple files using wild-card symbol * 470 | 471 | rm file1.txt file2.txt # Remove multiple files 472 | 473 | 474 | 475 | What is Deployment ?? 476 | 477 | Copying the artifacts from one machine to another machine 478 | 479 | Dev Server *.war 480 | 481 | Test Server *.war 482 | 483 | 484 | 485 | ll # Long List 486 | 487 | First 1 character are used to identify the type of component and its access level 488 | 489 | 490 | Project Folder -- Source Code & Program to execute 491 | 492 | 493 | Owner 494 | 495 | Group of Users 496 | 497 | Public/Common User 498 | 499 | 500 | User: Dev - Group: Development Team 501 | 502 | 503 | drwxrwxr-x 2 ubuntu ubuntu 4096 Jul 20 06:35 dir1/ 504 | 505 | 506 | drwxrwxr-x 507 | 508 | ---------- 509 | 510 | - # Used to identify the type of component - file/directory 511 | # Possibel values are ====> '-' and 'd' 512 | 513 | --- # Owner : Possible values are rwx Read / Write / Execute 514 | 515 | --- # User Group : Possible values are rwx Read / Write / Execute 516 | 517 | --- # Possible values are rwx Read / Write / Execute 518 | 519 | 520 | Eg.: 521 | 522 | payment.java 523 | 524 | 525 | -rwx------ # Owner of the file can have Read / Write / Execute access. 526 | 527 | -rw------- # Owner of the file can have Read and Write access. 528 | 529 | -rwxr----- # Owner of the file can have Read / Write / Execute access. 530 | # User Group can just read the file 531 | 532 | -rwxrw-r-- # Owner of the file can have Read / Write / Execute access. 533 | # User Group can just read & Write the file 534 | # Common user can just read the file content 535 | 536 | 537 | chmod 538 | 539 | https://chmod-calculator.com/ 540 | 541 | 542 | 543 | User Management ::: 544 | 545 | - How to create Users on linux Machine 546 | 547 | - How to login to that user 548 | 549 | - Setup the Access to that user 550 | 551 | - Define ownership 552 | 553 | 554 | DevOps ::: 555 | 556 | Create some Virtual Machines ::: 557 | 558 | server (VM) 559 | Clients (VM) 1,2,3,4,5 560 | 561 | 562 | Create : devopsadmin user 563 | 564 | Remote Server ::: 565 | 566 | SSH Protocol : 567 | 568 | Host Name 569 | 570 | User Name 571 | 572 | User Credentials 573 | 574 | 575 | 576 | ls -a # Used to get the list of all components including hidden files and directories 577 | 578 | 579 | Is SSH :: 580 | 581 | By Default : 582 | 583 | Key based authentication ::: 584 | 585 | Public Key 586 | 587 | Private Key 588 | 589 | Password based authentication ::: 590 | 591 | 592 | cd /etc # Directory maintains all the packages and system properties 593 | 594 | cat /etc/passwd # Used to get the list of users 595 | 596 | cat /etc/group # Used to get the list of user groups 597 | 598 | 599 | user1 600 | 601 | user2 602 | 603 | dev_group 604 | 605 | Install Docker -- Container Engine 606 | 607 | docker group 608 | 609 | devopsadmin 610 | 611 | Group level Access 612 | 613 | 614 | Create New Linux User ::: 615 | 616 | Excute these commands as a root user: 617 | 618 | #useradd devuser1 619 | 620 | useradd devuser2 -s /bin/bash -m -d /home/devuser2 # Create User 621 | 622 | su - devuser2 # Login to that user 623 | 624 | How to create password for Linux users 625 | 626 | passwd 627 | 628 | passwd devuser2 # Create Password 629 | 630 | New Password : # Is a Hidden field Enter valid password 631 | 632 | Re-Type New Password : # Is a Hidden field re-type & confirm password 633 | 634 | 635 | --------------------------------------------------------------------------------