Add Profile on LXD Linux Container

Menambahkan Profile pada LXD linux container

Baca juga: Install LXD (Linux Container) on Ubuntu 20.04

  • Tambahkan lxc profile dengan nama proxy-80 dan proxy-80-only
root@LXC:~/sys-ops.id# lxc profile create proxy-80
root@LXC:~/sys-ops.id# lxc profile create proxy-80-only
  • Cek list profile lxc
root@LXC:~/sys-ops.id# lxc profile list
+---------------+---------+
|     NAME      | USED BY |
+---------------+---------+
| default       | 2       |
+---------------+---------+
| proxy-80      | 0       |
+---------------+---------+
| proxy-80-only | 0       |
+---------------+---------+

  • Menambahkan proxy port forwarding pada profile
  • Tambahkan proxy hostport80 pada profile proxy-80 dengan listen port 7080 dari server host supaya terhubung pada port 80 lxc container
  • Tambahkan proxy hostport80 pada profile proxy-80-only dengan listen port 9080 dari server host supaya terhubung pada port 80 lxc container
root@LXC:~/sys-ops.id# lxc profile device add proxy-80 hostport80 proxy connect="tcp:127.0.0.1:80" listen="tcp:0.0.0.0:7080"
Device hostport80 added to proxy-80
-----
root@LXC:~/sys-ops.id# lxc profile device add proxy-80-only hostport80 proxy connect="tcp:127.0.0.1:80" listen="tcp:0.0.0.0:9080"
Device hostport80 added to proxy-80-only
  • Tambahkan storage pool pada profile proxy-80
root@LXC:~/sys-ops.id# lxc profile device add proxy-80 root disk path=/ pool=sys-ops.id
Device root added to proxy-80
  • Tambahkan network pada profile proxy-80
root@LXC:~/sys-ops.id# lxc profile device add proxy-80 eth0 name=eth0 network=lxdbr0 type=nic
Device eth0 added to proxy-80
  • Cek status profile proxy-80
root@LXC:~/sys-ops.id# lxc profile show proxy-80
config: {}
description: Proxy-80 Profile
devices:
  eth0:
    network: lxdbr0
    type: nic
  hostport80:
    connect: tcp:127.0.0.1:80
    listen: tcp:0.0.0.0:7080
    type: proxy
  root:
    path: /
    pool: sys-ops.id
    type: disk
name: proxy-80
used_by: []
  • Cek status profile proxy-80-only
root@LXC:~/sys-ops.id# lxc profile show proxy-80-only
config: {}
description: Proxy-80-only Profile
devices:
  hostport80:
    connect: tcp:127.0.0.1:80
    listen: tcp:0.0.0.0:9080
    type: proxy
name: proxy-80-only
used_by: []
  • Cek status profile device
root@LXC:~/sys-ops.id# lxc profile device show proxy-80
eth0:
  network: lxdbr0
  type: nic
hostport80:
  connect: tcp:127.0.0.1:80
  listen: tcp:0.0.0.0:7080
  type: proxy
root:
  path: /
  pool: sys-ops.id
  type: disk

  • Menambahkan linux container baru dengan spesifik profile
root@LXC:~/sys-ops.id# lxc launch images:ubuntu/focal/amd64 ubuntu-test -p proxy-80
  • Cek status profile linux container
root@LXC:~/sys-ops.id# lxc list -c n,s,4,a,b,P,s
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
|           NAME            |  STATE  |         IPV4         | ARCHITECTURE | STORAGE POOL | PROFILES |  STATE  |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-container     | RUNNING | 10.101.10.139 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-lxd-dashboard | RUNNING | 10.101.10.174 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-test               | RUNNING | 10.101.10.104 (eth0) | x86_64       | sys-ops.id   | proxy-80 | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+

  • Menambahkan profile proxy-80-only pada linux container ubuntu-2004-lxd-dashboard
root@LXC:~/sys-ops.id# lxc profile add ubuntu-2004-lxd-dashboard proxy-80-only
Profile proxy-80-only added to ubuntu-2004-lxd-dashboard
  • Cek status profile linux container ubuntu-2004-lxd-dashboard
root@LXC:~/sys-ops.id# lxc list -c n,s,4,a,b,P,s
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
|           NAME            |  STATE  |         IPV4         | ARCHITECTURE | STORAGE POOL |   PROFILES    |  STATE  |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-2004-container     | RUNNING | 10.101.10.139 (eth0) | x86_64       | sys-ops.id   | default       | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-2004-lxd-dashboard | RUNNING | 10.101.10.174 (eth0) | x86_64       | sys-ops.id   | default       | RUNNING |
|                           |         |                      |              |              | proxy-80-only |         |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-test               | RUNNING | 10.101.10.104 (eth0) | x86_64       | sys-ops.id   | proxy-80      | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
  • Menerapkan profile default pada linux container ubuntu-2004-lxd-dashboard
root@LXC:~/sys-ops.id# lxc profile assign ubuntu-2004-lxd-dashboard default
Profiles default applied to ubuntu-2004-lxd-dashboard
  • Cek status profile linux container ubuntu-2004-lxd-dashboard
root@LXC:~/sys-ops.id# lxc list -c n,s,4,a,b,P,s
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
|           NAME            |  STATE  |         IPV4         | ARCHITECTURE | STORAGE POOL | PROFILES |  STATE  |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-container     | RUNNING | 10.101.10.139 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-lxd-dashboard | RUNNING | 10.101.10.174 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-test               | RUNNING | 10.101.10.104 (eth0) | x86_64       | sys-ops.id   | proxy-80 | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
  • Hapus profile pada linux container
root@LXC:~/sys-ops.id# lxc list -c n,s,4,a,b,P,s
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
|           NAME            |  STATE  |         IPV4         | ARCHITECTURE | STORAGE POOL |   PROFILES    |  STATE  |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-2004-container     | RUNNING | 10.101.10.139 (eth0) | x86_64       | sys-ops.id   | default       | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-2004-lxd-dashboard | RUNNING | 10.101.10.174 (eth0) | x86_64       | sys-ops.id   | default       | RUNNING |
|                           |         |                      |              |              | proxy-80-only |         |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+
| ubuntu-test               | RUNNING | 10.101.10.104 (eth0) | x86_64       | sys-ops.id   | proxy-80      | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+---------------+---------+

root@LXC:~/sys-ops.id# lxc profile remove ubuntu-2004-lxd-dashboard proxy-80-only
Profile proxy-80-only removed from ubuntu-2004-lxd-dashboard

root@LXC:~/sys-ops.id# lxc list -c n,s,4,a,b,P,s
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
|           NAME            |  STATE  |         IPV4         | ARCHITECTURE | STORAGE POOL | PROFILES |  STATE  |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-container     | RUNNING | 10.101.10.139 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-2004-lxd-dashboard | RUNNING | 10.101.10.174 (eth0) | x86_64       | sys-ops.id   | default  | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+
| ubuntu-test               | RUNNING | 10.101.10.104 (eth0) | x86_64       | sys-ops.id   | proxy-80 | RUNNING |
+---------------------------+---------+----------------------+--------------+--------------+----------+---------+

  • Menghapus profile device
root@LXC:~/sys-ops.id# lxc profile device remove proxy-80 hostport80
Device hostport80 removed from proxy-80
  • Menghapus profile LXC container
root@LXC:~/sys-ops.id# lxc profile delete proxy-80

herdiana3389

A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.