how to install maas with docker container

  • build docker image for maas

originally, I wanted to do these steps in Dockerfile.

RUN apt update && apt install -y maas
RUN maas init
RUN systemctl enable maas-regiond
RUN systemctl enable maas-rackd
RUN systemctl enable maas-dhcpd
RUN systemctl enable maas-proxy


installing maas requires interactive user input like area info for tzdata.
however, docker build process is completely non-interactive and there is no way to input such data during the build process. so, building maas image should be decomposed to several steps.
the overall process is as below.

  1. Dockerfile.maas-systemd is used for preparing systemd docker image.
  2. run the built docker image and install maas manually on running docker.
  3. commit the configured maas docker to an intermediate docker image.
  4. Dockerfile.maas-configure is used for configuring maas service and entry point of committed image.
  5. clean intermediate images

  • detail steps
[step1]
cat Dockerfile.maas-systemd
FROM sang0627/systemd
MAINTAINER "Moon-Sang Lee" <sang0627@gmail.com>
ENV container docker

docker build -t sang0627/maas-systemd -f Dockerfile.maas-systemd .
[step2]
docker run -it --name maas-systemd sang0627/maas-systemd /bin/bash
  apt update && apt install -y maas
  maas init
[step3]
docker commit maas-systemd sang0627/maas-installed
docker stop maas-systemd
docker rm maas-systemd
[step4]
cat Dockerfile.maas-configure
FROM sang0627/maas-installed
MAINTAINER "Moon-Sang Lee" <sang0627@gmail.com>
ENV container docker
RUN systemctl enable maas-regiond
RUN systemctl enable maas-rackd
RUN systemctl enable maas-dhcpd
RUN systemctl enable maas-proxy
STOPSIGNAL SIGRTMIN+3
CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]

docker build -t sang0627/maas -f Dockerfile.maas-configure .
docker run -d --name maas -p 5240:5240 --security-opt seccomp=unconfined \
        --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
        -t sang0627/maas
docker push sang0627/maas
[step5]
docker image rm sang0627/maas-installed
docker image rm sang0627/maas-configure

browse http://:5240/MAAS/ and follow configuration guides
id/passwd = $myid/$mypasswd (i.e. determined at maas init)


in case of seperate installation of regiond and rackd, refer to below URL.
https://github.com/att-comdev/maas


redefining ENTRYPOINT in Dockerfile
finalize building maas docker with redefining ENTRYPOINT, since commit may corrupted step1’s systemd ENTRYPOINT. (i.e. or step1’s build process may corrupt systemd ENTRYPOINT)


  • configure maas network
[subnet configuration]
eth0: WAN
eth1: (mrnode does not use this interface but k8s uses this as internal network)
eth2: (mrnode does not use this interface but k8s uses this as internal network)
eth3: IPMI subnet which uses 192.168.1.0/24

docker network ls
docker network create --subnet=192.168.1.0/24 netIPMI
docker network connect netIPMI maas

ifconfig
brctl show
brctl addif br-xxxxxx eth3
route -n

running the final maas docker in one command

docker run -d --name maas --network netIPMI -p 5240:5240 \
        --security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock \
        -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
        -t sang0627/maas

reference
https://maas.io/how-it-works
https://maas.io/install
https://maas.io/tour
https://ubuntu.com/blog/multi-tenancy-in-maas
https://ubuntu.com/blog/hardware-discovery-and-kernel-auto-configuration-in-maas

https://github.com/att-comdev/maas
https://github.com/ARTbio/maas-docker
https://opendev.org/airship/maas/src/branch/master
https://hub.docker.com/r/ubuntudesign/maas

Leave a Reply

Your email address will not be published. Required fields are marked *