星期六, 8月 25, 2018

netbox with docker in azure

netbox with docker in azure

看到 digital ocean 出了一個專案 netbox 就想說來試試看

上面看到有人有做 docker 的版本

OS:  openSUSE Leap 42.3  in Azure

首先登入 Azure 的 openSUSE Leap 42.3

切換成 root
> sudo   su -

啟動 docker 服務
# systemctl  start  docker

安裝 docker-compose 指令
# zypper  install  docker-compose

Clone 專案
# git  clone  -b   master  https://github.com/ninech/netbox-docker.git

Cloning into 'netbox-docker'...
remote: Counting objects: 652, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 652 (delta 44), reused 72 (delta 38), pack-reused 563
Receiving objects: 100% (652/652), 214.17 KiB | 5.22 MiB/s, done.
Resolving deltas: 100% (355/355), done.

觀察資訊
# ls
.bash_history  .gnupg bin netbox-docker

進到專案目錄
# cd   netbox-docker/

openSUSE Leap 42.3 預設用的 docker-compose 版本比較舊 ( 1.8.1 )
  • openSUSE Leap 15 版本就夠新了1.17


先移除舊版的 docker-compose 1.8.1
# zypper  remove  docker-compose

Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
 docker-compose

1 package to remove.
After the operation, 512.8 KiB will be freed.
Continue? [y/n/...? shows all options] (y): y
(1/1) Removing docker-compose-1.8.1-13.1.noarch ..................................................................................[done]

下載最新版的 docker-compose

# sudo curl  -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)  -o   /usr/local/bin/docker-compose

 % Total    % Received % Xferd  Average Speed Time    Time Time Current
                                Dload Upload Total Spent Left  Speed
100   617 0   617 0  0 5300 0 --:--:-- --:--:-- --:--:--  5318
100 11.2M  100 11.2M  0 0 18.1M      0 --:--:-- --:--:-- --:--:-- 42.1M


加上執行權限
# chmod  +x   /usr/local/bin/docker-compose

確認 docker-compose 版本
# /usr/local/bin/docker-compose  --version
docker-compose version 1.22.0, build f46880fe

如果不想輸入絕對路徑可以登出再登入

執行 docker-compose  pull
# /usr/local/bin/docker-compose  pull

Pulling postgres      ... done
Pulling redis         ... done
Pulling netbox-worker ... done
Pulling netbox        ... done
Pulling nginx         ... done

觀察相關資訊
# docker   images

REPOSITORY          TAG IMAGE ID            CREATED SIZE
ninech/netbox       latest 4a7492cae085        3 days ago 480MB
redis               4-alpine 08bef618c30a        3 weeks ago 28.7MB
postgres            10.4-alpine 962ed899c609        4 weeks ago 72.9MB
nginx               1.15-alpine 36f3464a2197        4 weeks ago 18.6MB


使用 docker-compose 來佈署
# /usr/local/bin/docker-compose   up    -d

Creating network "netbox-docker_default" with the default driver
Creating volume "netbox-docker_netbox-static-files" with local driver
Creating volume "netbox-docker_netbox-nginx-config" with local driver
Creating volume "netbox-docker_netbox-media-files" with local driver
Creating volume "netbox-docker_netbox-report-files" with local driver
Creating volume "netbox-docker_netbox-postgres-data" with local driver
Creating volume "netbox-docker_netbox-redis-data" with local driver
Creating netbox-docker_postgres_1      ... done
Creating netbox-docker_redis_1    ... done
Creating netbox-docker_netbox-worker_1 ... done
Creating netbox-docker_netbox_1        ... done
Creating netbox-docker_nginx_1         ... done

觀察相關資訊
# docker  ps
CONTAINER ID        IMAGE   COMMAND  CREATED STATUS              PORTS NAMES
62ef5260ecc1        nginx:1.15-alpine   "nginx -c /etc/net..."  About a minute ago Up 56 seconds       80/tcp, 0.0.0.0:32768->8080/tcp   netbox-docker_nginx_1
f2d531e60cde        ninech/netbox:latest   "/opt/netbox/docke..."  About a minute ago Up About a minute                                     netbox-docker_netbox_1
1011ab8e3225        ninech/netbox:latest   "python3 /opt/netb..."  About a minute ago Up About a minute                                     netbox-docker_netbox-worker_1
cd6f25108265        redis:4-alpine   "docker-entrypoint..."  About a minute ago Up About a minute   6379/tcp netbox-docker_redis_1
af54cd3234aa        postgres:10.4-alpine   "docker-entrypoint..."  About a minute ago Up About a minute   5432/tcp netbox-docker_postgres_1

可以觀察 docker-compose.yml 或是 docker ps 知道, 目前走 port 32768   

也可以使用 指令查詢
# /usr/local/bin/docker-compose  port   nginx 8080
0.0.0.0:32768

在 Azure 上面的網路安全群組開放  port 32768



點選  右上方的 login
輸入預設的帳號 admin
密碼 admin
進行登入


使用 admin 登入之後就可以針對 Site 還有其他的物件進行新增以及修改


不過當然第一要務就是去修改密碼吧 :)

然後預設建立的 API Token 應該也可以刪除重新建立



看了一下, 目前沒有語系以及中文化設定
但是也是一個管理機櫃或是機器的好選項

找天來嘗試一下管理

~  enjoy it


Reference



沒有留言: