[DOCKER] Creating an Ubuntu 18.04 + MAAS2.4 environment starting from 0

Introduction

Currently, there is a project to build a MAAS + kubernetes environment in-house.
I will describe what I did and what I stumbled upon.

Goal

Build a server on Ubuntu and deploy Ubuntu OS in an independent network via PXE boot.

Precautions before introduction

Make sure that DHCP does not exist on the network where the MAAS server exists.
When DHCP builds a MAAS server on an existing network, it conflicts with the existing DHCP because the MAAS server will become a DHCP server in later settings.
When DHCP conflicts, terminals in the network will not be able to communicate outside the network if they get it from the MAAS server when reacquiring an IP address.
Also, terminals that are supposed to be MAAS clients will not be able to communicate stably with the MAAS server.
(I checked various articles, but the current situation is unsolved)

Construction terminal

MAAS server terminal (IP: 192.168.200.1)
MAAS client terminal (IP: 192.168.200.151)
macbookpro

Ubuntu installation

ubuntu download

Download the Ubuntu Server ISO image from the URL below.

http://releases.ubuntu.com/18.04/

Create boot disk for Ubuntu image

Burn the Ubuntu ISO image to your USB stick to create the installation media.

Check USB memory

After inserting the USB memory into the MAC, start up the terminal and check the location of the disk.

diskutil list
Screenshot 2018-05-20 19.18.13.png

When the command was executed, the USB memory was / dev / disk2, so format this once in MS-DOS format.

diskutil eraseDisk MS-DOS UNTITLED /dev/disk2

Unmount the formatted USB stick and create a boot disk with the dd command.

diskutil unmountDisk /dev/disk2
sudo dd if=./Downloads/ubuntu-18.04-live-server-amd64.iso of=/dev/disk2 bs=4028

Coffee time because it takes some time.
Remove the device when the image is complete.

If you're stuck,

diskutil eject /dev/disk2

Execute

to remove the USB memory. </ P>

Install Ubuntu image

Plug the USB created earlier into the terminal for the MAAS server, specify USB boot on the BOOT screen, and start the installation.
Specifying the BOOT device differs depending on the machine, so it is omitted.

Installation options are optional.

MAAS installation

Install the MAAS package on the server.

$ sudo apt -y update
$ sudo apt -y upgrade
$ sudo apt -y install maas

Create an administrator user when the installation is complete.
Set required user name, password, address, etc.
Since the SSH key will be registered later, leave it blank and enter through.

$ sudo maas createadmin

When the creation is completed, log in with "MAAS server address: 5240 / MAAS /".

MAAS settings

The login screen will appear, so
Log in as the created user.

Screenshot 2018-05-22 14.24.41.png

After logging in, the intro page will appear.
You don't have to mess with the settings.

In the latter image, select the Ubuntu OS image to download.
If you check the version you want, the download will start automatically, so wait for a while.

Click Continue when the download is complete and the "Status" is "Synced"

Screenshot 2018-05-22 14.24.59.png
Screenshot 2018-05-22 14.25.20.png

Generate a key on the Ubuntu server side to move to the screen for entering the private key.
Enter repeatedly without specifying anything.

$ sudo ssh-keygen -t rsa

Because the key is generated in the .ssh folder on the server,
Copy the contents of your public key.

cat .ssh/id_rsa.pub

After copying, return to the MAAS management server, change Source to Upload, paste the contents of the key you copied earlier on the next input screen, and click Import.
If there is no problem, click "Go to dashboard".

Screenshot 2018-05-22 14.25.54.png

As a preparation, select untagged for the network VLAN you want to deploy in the "Subnets" page at the top of the MAAS top page.

Screenshot 2018-05-23 12.28.03.png

Select "Provide DHCP" from "Take action" at the top of the screen.

Screenshot 2018-05-23 12.32.09.png
68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f64616464393437352d626531372d663134302d343534662d3738653037616661623833342e706e67.png

The DHCP range of the MAAS server will appear, so if you specify an arbitrary number and select "Provide DHCP", the DHCP item on the same page will be enabled, and the network range added to "Reserved ranges" will be Is displayed.

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f61386132633162382d666161392d373463342d343033302d6465343265633232393032652e706e67.png

This completes the preparations.

Deploy MAAS client
68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f39303965386538342d303465642d316430392d623232342d3663613962366132383333352e706e67.png

Move the PXE boot item to the first place in the boot order in the BOOT order of the terminal that will be the MAAS client.
After that, when the client is turned on, it automatically starts communicating with the MAAS server and turns off.
After the power is turned off, the terminal will be added to "Machines" on the management screen of MAAS.
(The name of the terminal is tentative and the name of the animal is entered)

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f32366162613330652d373034352d313963662d323831332d3630303036356336396365362e706e67.png

Select the added machine and rename it first.

Screenshot 2018-05-23 16.03.41.png

Select the power option in "Power configuration" in "Configration".
This time, select "Manual".

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f66666561643063632d323034382d313363342d386665652d3363303734316634656464362e706e67.png

On the "Machines" page, check the checkbox of the terminal, select "Commission" from "Take action", and then turn on the power of the client terminal.

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f35316137386634322d373239632d333466652d386265312d6133303934666434366330632e706e67.png

Communication with the server will start again, so wait until the end.
When the Commission is completed successfully, "Status" will be "Ready" on the server management screen.

Select "Deploy" from "Take action", select any OS, start the deployment, and turn on the client.

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3235393334332f66633432313464632d663562382d643934382d653133302d3335616265613531353863312e706e67.png

Since the OS is deployed from the server, wait for a while, and if the Status column changes to the OS name on the management screen, it will succeed

.

About network settings of client terminal

The client terminal of MAAS is basically DHCP, but it can also be specified as Static.

In that case, before deploying the OS, select "Actions"-"Edit Physical" in "Interfaces" in the information page of the terminal, change "Auto assign" to "Static", and specify an arbitrary address. To.

Screenshot 2018-05-22 13.54.10.png
Screenshot 2018-05-22 13.54.26.png

I stumbled

After installing the MAAS server, DHCP is Enabled on the setting screen, but the address is not distributed to the client.

Solution
Select the machine in "Name" in "Controllers" at the top of the management screen (there should be only one at the beginning)
In the Services item in the moved page, "dhcpd" may not have a green mark, so once MAAS is restarted, it will have a green mark.

If that doesn't work,

sudo dpkg-reconfigure maas-rack-controller

sudo apt-get install maas-rack-controller
 sudo maas-rack register --url http: // MAAS server address: 5240 /  



 Sometimes it was cured with 

.

Reference page
Create a Bootable USB from an ISO image on Mac OS X-only one stronger per day < br> MAAS environment construction and Ubuntu deployment --Qiita
SSH connection using public key cryptography (Kihon) --Qiita

Recommended Posts