Open8

SDN

masainomasaino
$ docker import cEOS-lab-4.25.1F.tar ceos:4.25.1F
sha256:cfc9238775466cd246a24a213852cb235d2c36256c81e9969f89d431a49b4649

$ docker images
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
ceos                           4.25.1F             cfc923877546        6 minutes ago       1.69GB
docker create \
  --name=ceos1 \
  --privileged \
  -e INTFTYPE=eth \
  -e ETBA=1 \
  -e SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  -e CEOS=1 -e EOS_PLATFORM=ceoslab \
  -e container=docker \
  -i -t ceos:4.25.1F /sbin/init \
  systemd.setenv=INTFTYPE=eth \
  systemd.setenv=ETBA=1 \
  systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  systemd.setenv=CEOS=1 \
  systemd.setenv=EOS_PLATFORM=ceoslab \
  systemd.setenv=container=docker
 
docker create \
  --name=ceos2 \
  --privileged \
  -e INTFTYPE=eth \
  -e ETBA=1 \
  -e SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  -e CEOS=1 -e EOS_PLATFORM=ceoslab \
  -e container=docker \
  -i -t ceos:4.25.1F /sbin/init \
  systemd.setenv=INTFTYPE=eth \
  systemd.setenv=ETBA=1 \
  systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  systemd.setenv=CEOS=1 \
  systemd.setenv=EOS_PLATFORM=ceoslab \
  systemd.setenv=container=docker
$ docker container ls -a
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                        PORTS               NAMES
4089be1d512b        ceos:4.25.1F                   "/sbin/init systemd.…"   12 seconds ago      Created                                           ceos2
f755ff0e0f85        ceos:4.25.1F                   "/sbin/init systemd.…"   2 minutes ago       Created                                           ceos1
$ docker network create net1
$ docker network create net2
 
$ docker network connect net1 ceos1
$ docker network connect net1 ceos2
$ docker network connect net2 ceos1
$ docker network connect net2 ceos2

$ docker network ls
NETWORK ID          NAME                                DRIVER              SCOPE
e892c34cf966        net1                                bridge              local
d3c6db6e5114        net2                                bridge              local

適宜詳細を確認

$ docker container inspect ceos1
$ docker network inspect net1
$ docker start ceos1
$ docker start ceos2
ceos1
ceos2
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
4089be1d512b        ceos:4.25.1F        "/sbin/init systemd.…"   10 minutes ago      Up 4 seconds                            ceos2
f755ff0e0f85        ceos:4.25.1F        "/sbin/init systemd.…"   12 minutes ago      Up 5 seconds                            ceos1

APIアクセスのためのコントロールプレーンなネットワークをつくる

$ docker network create bridge-ceos
$ docker network connect bridge-ceos ceos1
$ docker network connect bridge-ceos ceos2

masainomasaino

AホストからAPIへアクセスするためにポートマッピングを足してみる

docker create \
  --name=ceos6 \
  -p 8080:80 \
  --privileged \
  -e INTFTYPE=eth \
  -e ETBA=1 \
  -e SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  -e CEOS=1 -e EOS_PLATFORM=ceoslab \
  -e container=docker \
  -i -t ceos:4.25.1F /sbin/init \
  systemd.setenv=INTFTYPE=eth \
  systemd.setenv=ETBA=1 \
  systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 \
  systemd.setenv=CEOS=1 \
  systemd.setenv=EOS_PLATFORM=ceoslab \
  systemd.setenv=container=docker

-p は認識されている

$ docker inspect container ceos3
[
    {
        "Id": "c472c9298e4f373dc3d8626106a62aac570731cb341b04a93f96af24baf1b311",
        "Created": "2021-03-10T04:38:53.937799004Z",
        "Path": "/sbin/init",
        "Args": [
            "-p",
            "8080:80",
            "systemd.setenv=INTFTYPE=eth",
            "systemd.setenv=ETBA=1",
            "systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1",
            "systemd.setenv=CEOS=1",
            "systemd.setenv=EOS_PLATFORM=ceoslab",
            "systemd.setenv=container=docker"
        ],

が...

$ curl localhost:8080
curl: (7) Failed to connect to localhost port 8080: Connection refused

ネットワークのホストモードの指定をはずしたらいけた - ちゃんとPORTSがしていされている

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
3a61f13b3761        ceos:4.25.1F        "/sbin/init systemd.…"   18 seconds ago      Up 1 second         0.0.0.0:8080->80/tcp   ceos6

それで、mappingも反応している

$ docker port ceos6 80
0.0.0.0:8080

応答が変わった

$ curl localhost:8080
curl: (52) Empty reply from server

デフォルトだとマネジメントはこんな感じ

localhost#show management api http-commands 
Enabled:            No
HTTPS server:       enabled, set to use port 443
HTTP server:        shutdown, set to use port 80
Local HTTP server:  shutdown, no authentication, set to use port 8080
Unix Socket server: shutdown, no authentication
VRFs:               None
Hits:               0
Last hit:           never
Bytes in:           0
Bytes out:          0
Requests:           0
Commands:           0
Duration:           0.000 seconds
SSL Profile:        none
FIPS Mode:          No
QoS DSCP:           0
Log Level:          none
CSP Frame Ancestor: None
TLS Protocols:      1.0 1.1 1.2

設定をいれる

localhost#conf t
localhost(config)#management api http-commands 
localhost(config-mgmt-api-http-cmds)#no protocol http
localhost(config-mgmt-api-http-cmds)#protocol http
localhost(config-mgmt-api-http-cmds)#no shutdown 
localhost(config-mgmt-api-http-cmds)#wr mem
Copy completed successfully.

動いている感

localhost(config)#show management api http-commands 
Enabled:            Yes
HTTPS server:       running, set to use port 443
HTTP server:        running, set to use port 80
Local HTTP server:  shutdown, no authentication, set to use port 8080
Unix Socket server: shutdown, no authentication
VRFs:               default
Hits:               0
Last hit:           never
Bytes in:           0
Bytes out:          0
Requests:           0
Commands:           0
Duration:           0.000 seconds
SSL Profile:        none
FIPS Mode:          No
QoS DSCP:           0
Log Level:          none
CSP Frame Ancestor: None
TLS Protocols:      1.0 1.1 1.2
masainomasaino

WebUIにログインするためにユーザーをつくる

localhost#conf t
localhost(config)#username me secret 0 imyme