Profile retele si volume in LXD
Postat la Mon 23 April 2018 in tutoriale, lxd, lxc
Inainte de a prezenta modul de lucru cu containere e bine sa prezint cateva elemente folosite in mediul LXD:
- profile (profile)
- retele (network)
- stocare si volume (storage and volume)
Profile
VM se pot defini prin profile unde sunt / pot fi predefinite:
- interfetele de retea
- retele unde se conecteaza
- numarul de core-uri
- RAM
- spatiul pe disk
Initial se creaza profilul default:
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: lxd001
type: disk
name: default
used_by: []
ce defineste VM ca se va conecta cu interfata eth0 la bridge br0 si va avea partia / pe pool lxd001 definit anterior de marime nedefinita.
Un profil mai complex cu doua interfete si partitia / de 25G:
config: {}
description: Dual link profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
eth1:
name: eth1
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default=lxd001
size: 25GB
type: disk
name: dual-25G
used_by: []
Mai multe informatii legate de parametrii de confgurare gasiti aici.
Operatii asupra profilelor:
lxc profile list
lxc profile show default
lxc profile create dual
lxc profile edit dual
lxc profile delete dual
Retele
Retele la care sunt conectate VM se definesc prin bridge-uri, care pot fi conectate via NAT la reteaua fizica a gazdei, pot oferi servicii de dhcp si DNS pe IPV4 si IPV6:
config:
ipv4.address: 10.213.199.1/24
ipv4.nat: "true"
ipv6.address: none
ipv6.nat: "false"
description: Internal network
name: lxdbr0
type: bridge
used_by:[]
managed: true
status: Created
locations:
- none
Mai multi parametrii de configurare va sunt explicati in pagina dedicata din documentatie
Aceste retele pot fi atasate la VM sau profile prin interfete virtuale.
Operatii asupra retelelor:
lxc network list
lxc network show lxdbr0
lxc network create lxdbr0
lxc network edit lxdbr0make
lxc network delete lxdbr0
lxc network attach-profile dual lxdbr0 eth1 eth1
Volume
Discurile virtuale - volume - se definesc ca dataset-uri in sistemul de fisiere ZFS. Acestea se pot crea, atasa prin profile sau ulterior
config:
size: 10GB
volatile.idmap.last: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
description: ""
name: data01
type: custom
used_by:[]
location: none
Descrierea optiunilor le gasiti in sectiunea dedicata din documentatie
Operatii asupra volumelor:
lxc storage volume list
lxc storage volume show lxd001 data01
lxc storage volume create lxd001 data01
lxc storage volume create lxd001 data01 size=10GB
lxc storage volume attach lxd001 data01 node1 lxd001/custom/data01 /mnt/upload
lxc storage volume detach lxd001 data01 node1
lxc storage volume delete lxd001 data01
Daca nu se specifica marimea volumului (dataset ZFS) acesta va putea ocupa tot spatiul disponibil. Ulterior marimea dataset-ului - quota poate fi modificata prin ZFS:
zfs get quota lxd001/containers/salt-master
NAME PROPERTY VALUE SOURCE
lxd001/containers/salt-master quota none default
zfs set quota=25GB lxd001/containers/salt-master
zfs get quota lxd001/containers/salt-master
NAME PROPERTY VALUE SOURCE
lxd001/containers/salt-master quota 25G local
Dar quota unui volum ofera siguranta ca spatiul este rezervat complet pentru volum. Aici intervine reservation care face acest lucru
zfs get reservation lxd001/containers/salt-master
NAME PROPERTY VALUE SOURCE
lxd001/containers/salt-master reservation none default
zfs set reservation=25GB lxd001/containers/salt-master
zfs get reservation lxd001/containers/salt-master
NAME PROPERTY VALUE SOURCE
lxd001/containers/salt-master reservation 25G local
Articolul face parte din seria Virtualizare cu LXD