DevOps

 @neowinx

Pedro Flores

}

 @neowinx

Pedro Flores

About us

Ing. Marcelo Denis

Contenido

  • Introduccion / DevOps Tools
  • Conceptos básicos de Linux / Conceptos básicos de redes
  • Conceptos básicos de las aplicaciones / Repaso GIT
  • Introducción a Jenkins / Complementos e integraciones de Jenkins
  • Administración de Sistemas con Jenkins / Pipelines
  • Review de Docker / Comandos de Docker
  • Docker Run / Docker Images
  • Docker Engine Storage y Networking / Docker Registry
  • Introduccion a Kubernetes / Kubernetes Setup
  • Conceptos de Kubernetes / Introducción a YAML
  • AWS Basics
  • Azure Basics
  • Introducción a Terraform / Introducción a la Infraestructura como Código
  • Primeros pasos con Terraform / Fundamentos de Terraform
  • Gitlab integration
     

LINUX

¿Porqué Linux?

¿Porqué Linux?

¿Porqué Linux?

¿Porqué Linux?

- 2013 Docker

- 2016 Docker for Windows

WSL?

El Subsistema de Windows para Linux (WSL) es una función de Windows que permite a los desarrolladores ejecutar un entorno Linux sin necesidad de una máquina virtual independiente o arranque dual.

Linux Basics

  • Linux CLI
  • VIM Editor
  • Package Management
  • Service Management

Linux Basics Crash Course

WSL

VirtualBox

virt-manager

Tipos de Shell

❯ echo $SHELL
/bin/bash
❯ cat /etc/shell
/bin/bash
/bin/dash
/bin/sh
/bin/zsh
❯ chsh
Password:
Changing the login shell for neowinx
Enter the new value, or press ENTER for the default
        Login Shell [/bin/zsh]:

Bourne Shell (Sh Shell)

C Shell (csh o tcsh)

Z Shell

Bourne again Shell (bash)

Terminal Emulators

Terminal Emulators

Windows Terminal

Comandos Básicos

Imprimir en la pantalla

❯ echo Hola
Hola

Listar archivos y directorios

❯ ls
Archivo.txt mi_dir1 archivo2.conf

Cambiar directorio

❯ cd mi_dir

Presentar Directorio de Trabajo

❯ pwd
/home/mi_dir1

Crear Directorios

❯ mkdir nuevo_directorio

Comandos Múltiples

❯ cd nuevo_directorio; mkdir www; pwd
/home/mi_dir1/nuevo_directorio

Comandos - Directorios

/tmp/america/paraguay/asuncion

Crear una jerarquía de directorios

❯ mkdir /tmp/america
❯ mkdir /tmp/america/paraguay
❯ mkdir /tmp/america/paraguay/asuncion
❯ mkdir -p /tmp/america/paraguay/asuncion
❯ rm -r /tmp/mi_dir1

Remover directorio

❯ cp -r mi_dir1 /tmp/my_dir1

Copiar directorio

Comandos - Archivos

Crear una jerarquía de directorios

❯ touch nuevo_archivo.txt

Agregar contenido a un archivo

❯ cat > nuevo_archivo.txt
Este es un ejemplo de contenido

CTRL+D

❯ cat nuevo_archivo.txt

Ver contenido de archivos

❯ cp nuevo_archivo.txt copia_archivo.txt

Copiar arhivo

❯ mv nuevo_archivo.txt archivo_ejemplo.txt

Mover (Renombrar) archivos

❯ rm nuevo_archivo.txt

Remover (Borrar) archivos

VI Editor

<!DOCTYPE html>
<html>
<body>

<h1>The VIM Poem</h1>

<p> The wise man said just walk this way</p>
<p> To the dawn of the light </p>
<p> The wind will blow into your face </p>
<p> As the years pass you by </p>
<p> Hear this voice from deep inside </p>
<p> It's the call of your heart </p>
<p> Close your eyes and your will find </p>
<p> The passage out of the dark </p>
<p> V-I-M </p>
<p> Will you send me an angel </p>
<p> V-I-M </p>

</body>
</html>
cat index.html

VI Editor

vim index.html

COMMAND

MODE

INSERT

MODE

COMMAND

MODE

INSERT

MODE

VI Editor - Command Mode

Movimiento

Borrar

Copiar y Pegar

Scroll Up y Scroll Down

VI Editor - Command Mode

Comando

Guardar

Salir (Descartar)

Guardar y Salir

VI Editor - Command Mode

Encontrar

Cuentas de Usuario

❯ whoami
mateo
❯ id
uid=1001(mateo) gid=1001(mateo) groups=1001(mateo)
❯ su pedro
Password:
❯ ssh pedro@192.168.1.2

mateo

Cuentas de Usuario

❯ ls /root
ls: cannot open directory /root: Permission denied

mateo

❯ sudo ls /root
anaconda-ks.cfg  initial-setup-ks.cfg

SUDO

/etc/sudoers

root

Descarga de Archivos

❯ curl http://www.algun-sitio.com/algun-archivo.txt -O
algun-archivo.txt
❯ wget -O http://www.algun-sitio.com/algun-archivo.txt -O algun-archivo.txt
algun-archivo.txt

Checkear la distro Linux

❯ cat /etc/*release*
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
❯ ls /etc/*release*
/etc/centos-release			/etc/redhat-release
/etc/centos-release-upstream		/etc/redhat-release

Package Managers

❯ rpm -i telnet.rpm

Instalar Paquete

❯ dpkg -i telnet.deb
❯ rpm -e telnet.rpm

Desinstalar Paquete

❯ dpkg -r telnet.deb
❯ rpm -q telnet.rpm

Buscar Paquete

❯ rpm -s telnet.deb

telnet.{deb,rpm}

DPKG

RPM

Package Managers

❯ rpm -i telnet.rpm

Instalar Paquete

❯ dpkg -i telnet.deb
❯ rpm -e telnet.rpm

Desinstalar Paquete

❯ dpkg -r telnet.deb
❯ rpm -q telnet.rpm

Buscar Paquete

❯ rpm -s telnet.deb

ansible.{deb,rpm}

DPKG

RPM

?

?

?

?

APT / YUM

ansible

DPKG

RPM

❯ apt install telnet

Instalar Paquete

❯ yum install telnet

APT

YUM

PyYAML

python

sshpass

❯ /etc/apt/sources.list.d/
❯ /etc/yum/repos.d/

APT - Repositorios

❯ cat /etc/apt/sources.list
# deb http://snapshot.debian.org/archive/debian/20230502T000000Z bullseye main
deb http://deb.debian.org/debian bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20230502T000000Z bullseye-security main
deb http://deb.debian.org/debian-security bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20230502T000000Z bullseye-updates main
deb http://deb.debian.org/debian bullseye-updates main

APT - Repositorios

Package: ansible
Version: 2.10.7+merged+base+2.10.8+dfsg-1
Installed-Size: 198790
Maintainer: Lee Garrett <debian@rocketjump.eu>
Architecture: all
Replaces: ansible-base (<= 2.10.5+dfsg-2)
Depends: python3-cryptography, python3-jinja2, python3-packaging, python3-yaml, python3:any, openssh-client | python3-paramiko (>= 2.6.0), python3-pycryptodome, python3-distutils, python3-dnspython, python3-httplib2, python3-netaddr
Recommends: python3-argcomplete, python3-jmespath, python3-kerberos, python3-libcloud, python3-selinux, python3-winrm, python3-xmltodict
Suggests: cowsay, sshpass
Breaks: ansible-base (<= 2.10.5+dfsg-2)
Description: Configuration management, deployment, and task execution system
Homepage: https://www.ansible.com
Description-md5: de0a87781a6b6efa86ca20d1d1c64ce8
Tag: admin::automation, admin::configuring, admin::file-distribution,
 admin::package-management, implemented-in::python,
 interface::commandline, role::program, use::configuring,
 works-with::software:running
Section: admin
Priority: optional
Filename: pool/main/a/ansible/ansible_2.10.7+merged+base+2.10.8+dfsg-1_all.deb
Size: 17685468
MD5sum: 159657e0be3d3f212fde43db1ac986cd
SHA256: 66474117b31f9b0bc816331c7b5f7424c77a496db5063da0d761cdbc814ef644

APT - Repositorios

apt update
apt install software-properties-common
apt install gpg
apt-add-repository ppa:ansible/ansible
apt list ansible -a
ansible/jammy 7.5.0-1ppa~jammy all
ansible/jammy 2.10.7+merged+base+2.10.8+dfsg-1 all
apt install ansible=7.5.0-1ppa~jammy

Servicios

systemctl start httpd
systemctl stop httpd
systemctl status httpd
systemctl enable httpd
systemctl disable httpd

Start HTTPD service

Stop HTTPD service

Check HTTPD service status

Configure HTTPD service status

Configure HTTPD to not start at startup

service httpd start

Start HTTPD service

Servicios

systemctl start my_app
systemctl stop my_app

/etc/systemd/system

Servicios

/etc/systemd/system

my_app.service
[Service]
ExecStart=

Servicios

/etc/systemd/system

my_app.service
[Service]
ExecStart=/usr/bin/python3 /opt/code/my_app.py
systemctl daemon-reload
systemctl start my_app

Servicios

systemctl daemon-reload
systemctl start my_app
my_app.service
[Service]
ExecStart=/usr/bin/python3 /opt/code/my_app.py

/etc/systemd/system

systemctl status my_app
systemctl stop my_app

Servicios

systemctl daemon-reload
systemctl start my_app
my_app.service
[Service]
ExecStart=/usr/bin/python3 /opt/code/my_app.py

[Install]
WantedBy=multi-user.service

/etc/systemd/system

systemctl status my_app
systemctl stop my_app
systemctl enable my_app

Servicios

systemctl daemon-reload
systemctl start my_app
my_app.service
[Unit]
Description=Mi aplicacion web python

[Service]
ExecStart=/usr/bin/python3 /opt/code/my_app.py

[Install]
WantedBy=multi-user.service

/etc/systemd/system

systemctl status my_app
systemctl stop my_app
systemctl enable my_app

Servicios

systemctl daemon-reload
systemctl start my_app
my_app.service
[Unit]
Description=Mi aplicacion web python

[Service]
ExecStart=/usr/bin/python3 /opt/code/my_app.py
ExecStartPre=/opt/code/configure_db.sh
ExecStartPost=/opt/code/email_status.sh
Restart=always

[Install]
WantedBy=multi-user.service

/etc/systemd/system

systemctl status my_app
systemctl stop my_app
systemctl enable my_app

Service Unit File - Docker

Networking

Lo suficiente...

  • Switching
  • Routing
  • Default Gateway
  • DNS Configurations on Linux

Switching

A

B

??

Switching

A

B

eth0

eth0

❯ ip link

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 18:c0:4d:01:e5:7f brd ff:ff:ff:ff:ff:ff
❯ ip link

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 18:c0:4d:01:e5:7f brd ff:ff:ff:ff:ff:ff
❯ ip addr add 192.168.1.10/24 dev eth0
❯ ip addr add 192.168.1.11/24 dev eth0
❯ ping 192.168.1.11
PING 192.168.0.1 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=64 time=2.02 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=64 time=1.45 ms

192.168.1.0

Routing

Routing

192.168.1.1

192.168.2.1

Gateway

192.168.1.1

192.168.2.1

❯ ip route
❯ ip route add 192.168.2.0/24 dev via 192.168.1.1
❯ ip route

192.168.2.0 via 192.168.1.1 dev eth0

Gateway

192.168.1.1

192.168.2.1

❯ ip route add 192.168.1.0/24 dev via 192.168.2.1
❯ ip route

192.168.1.0 via 192.168.2.1 dev eth0
❯ ip route
❯ ip route add 192.168.2.0/24 dev via 192.168.1.1
❯ ip route

192.168.2.0 via 192.168.1.1 dev eth0

Default Gateway

192.168.1.1

192.168.2.1

172.217.194.0

216.134.45.0

16.44.53.0

❯ ip route add 192.168.1.0/24 dev via 192.168.2.1
❯ ip route

192.168.1.0 via 192.168.2.1 dev eth0
172.217.194.0 via 192.168.2.1 dev eth0
❯ ip route add 172.217.194.0/24 dev via 192.168.2.1

Default Gateway

192.168.1.1

192.168.2.1

172.217.194.0

216.134.45.0

16.44.53.0

❯ ip route add 192.168.1.0/24 via 192.168.2.1
❯ ip route

default via 192.168.2.1 dev eth0
❯ ip route add default via 192.168.2.1

Default Gateway

192.168.1.1

192.168.2.1

172.217.194.0

216.134.45.0

16.44.53.0

❯ ip route add 192.168.1.0/24 via 192.168.2.1
❯ ip route

default via 192.168.2.1 dev eth0
0.0.0.0 via 192.168.2.1 dev eth0
❯ ip route add default via 192.168.2.1

Default Gateway

192.168.1.1

192.168.2.1

172.217.194.0

216.134.45.0

16.44.53.0

❯ ip route add 192.168.1.0/24 via 192.168.2.1
❯ ip route

default via 192.168.2.1 dev eth0
0.0.0.0 via 192.168.2.1 dev eth0
192.168.2.0 via 0.0.0.0 dev eth0
❯ ip route add default via 192.168.2.1
❯ ping 192.168.2.5

Connect: Network is unreachable

192.168.1.5

192.168.1.6

192.168.2.6

192.168.2.5

eth0

eth0

eth1

eth0

??

❯ ping 192.168.2.5

Connect: Network is unreachable
❯ ip route add 192.168.2.0/24 via 192.168.1.6
❯ ping 192.168.2.5
 
❯ ip route add 192.168.1.0/24 via 192.168.2.6

192.168.1.5

192.168.1.6

192.168.2.6

192.168.2.5

eth0

eth0

eth1

eth0

??

❯ ping 192.168.2.5
 

192.168.1.5

192.168.1.6

192.168.2.6

192.168.2.5

eth0

eth0

eth1

eth0

❯ cat /proc/sys/net/ipv4/ip_forward
 0
❯ echo 1 > /proc/sys/net/ipv4/ip_forward
 1
❯ ping 192.168.2.5

Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
Reply from 192.168.2.5: bytes=32 time=4ms TTL=117
/etc/sysctl.conf

net.ip4.ip_forward = 1

Take aways

❯ ip link
❯ ip addr
❯ ip addr add 192.168.1.10/24 dev eth0
❯ ip route
❯ ip route add 192.168.1.0/24 via 192.168.2.1
❯ cat /proc/sys/net/ipv4/ip_forward
1

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

eth0

C

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

db

eth0

C

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

eth0

eth0

eth0

eth0

Z

D

L

K

eth0

C

DNS

eth0

eth0

192.168.1.0

192.168.1.10

192.168.1.11

eth0

eth0

eth0

eth0

Z

D

L

K

eth0

C

DNS

eth0

DNS

eth0

192.168.1.0

192.168.1.10

DNS

eth0

192.168.1.100

TEST

eth0

192.168.1.115

DNS

eth0

192.168.1.0

192.168.1.10

DNS

eth0

192.168.1.100

TEST

eth0

192.168.1.115

??

DNS

eth0

192.168.1.0

192.168.1.10

DNS

eth0

192.168.1.100

TEST

eth0

192.168.1.115

www.facebook.com

Domain Names

Nombres de Dominio

www.facebook.com

www.behance.com

www.google.com

www.mti.edu

www.codepen.io

www.kubernetes.io

www.standfor.edu

www.un.org

www.speedtest.net

www.care.org

Domain Names

Nombres de Dominio

www.facebook

www.behance

www.google

www.mti

www.codepen

www.kubernetes

www.standford

www.un

www.speedtest

www.care

.com

.net

.io

.edu

.org

Domain Names

Nombres de Dominio

google

.com

www

.

Root

Top Level Domain Name

Subdomain

maps

drive

apps

mail

Domain Names

google

.com

.

apps

apps.google.com

216.58.221.78

apps.google.com => 216.58.221.78

(Cache)

Org

DNS

Root

DNS

.com

DNS

google

DNS

Search Domain

Org

DNS

mycompany.com

mail

drive

www

pay

hr

Search Domain

Org

DNS

mycompany.com

mail

drive

www

pay

hr

web

nfs

hr

sql

DNS Tools

nsloookup

DNS Tools

dig

DevOps

By Pedro Flores

DevOps

  • 106