3 minute read

Prerequisites

Install Juju

Create Juju Controller VMs

  • On KVM host, create a create-juju-controllers.sh bash file.
cat << "EOF" > create-juju-controllers.sh
#!/bin/bash
VM_NAMES=(
sofyan01-juju01-rack01
sofyan01-juju02-rack02
sofyan01-juju03-rack03
)

for VM_NAME in ${VM_NAMES[@]}; do
  qemu-img create -f qcow2 /data/vms/$VM_NAME-vda.qcow2 40G >/dev/null
  virt-install --virt-type kvm \
    --name $VM_NAME \
    --os-type=linux --os-variant=ubuntu18.04 \
    --ram=8192 --vcpus=4 \
    --cpu host-passthrough,cache.mode=passthrough \
    --pxe --graphics vnc \
    --boot network,hd \
    --network bridge=virbr2 \   # bridge that used on oam network
    --network bridge=virbr2 \
    --disk path=/data/vms/$VM_NAME-vda.qcow2,bus=scsi \
    --noautoconsole --noreboot >/dev/null && virsh destroy $VM_NAME >/dev/null

  UUID=$(virsh dumpxml $VM_NAME | grep uuid | perl -lape 's/\s\s.\w+.(.*)<.*/$1/gm')
  MAC1=$(virsh dumpxml $VM_NAME | grep "mac address" | perl -lape 's/.*<\w+\s\w+..(.*).../$1/gm' | awk 'NR==1')
  MAC2=$(virsh dumpxml $VM_NAME | grep "mac address" | perl -lape 's/.*<\w+\s\w+..(.*).../$1/gm' | awk 'NR==2')
    echo
    echo "$VM_NAME UUID: $UUID"
    echo "$VM_NAME MAC1: $MAC1"
    echo "$VM_NAME MAC2: $MAC2"
    echo
done
EOF
  • Create juju vms and take a note for uuid & mac addresses.
    bash create-juju-controllers.sh
    

Add Juju Controller Machines on MaaS

  • Login to maas01 as maas user (create one if no exist), make sure maas nodes could SSH to KVM host using PubKey authentication, verify use this command:
virsh -c qemu+ssh://root@10.101.1.1/system list
  • If works, let’s continue to add juju machine to MaaS.

    Login to MaaS dashboard on: http://10.101.1.11:80/MAAS

  • On Machines tab, click Add machine. Put any juju vm information (including mac address & uuid). For example:

      Machine name       : sofyan01-juju01-rack01
      Domain             : maas
      Architecture       : amd64/generic
      Minimum kernel     : bionic (hwe-18.04)
      zone               : default
      MAC1               : <mac_address>
      Power Type         : virsh (virtual system)
      Address            : qemu+ssh://root@10.101.1.1/system
      Virsh ID           : <uuid>
    
  • Click Save machine. Do this to all juju vms.

  • Create subnets and spaces on MaaS. Go to Subnets tab. Make sure to create appropriate subnets, vlans, and fabrics like below.

Space Name              VLAN			DHCP     Fabric        Subnet
oam-space 	        untagged 	        Enabled  Management   10.101.1.0/24 (oam)
internal-space 	    5 (internal)    	Disabled Bond0 	      192.168.5.0/24 (internal)
ceph-replica-space 	6 (ceph-replica)    Disabled Bond0 	      192.168.6.0/24 (ceph-replica)
overlay-space    	8 (overlay) 	    Disabled Bond0 	      192.168.8.0/24 (overlay)
external-space 	    untagged    	    Disabled Bond0 	      10.11.12.0/24 (external)
dns-space          11 (dns)             Disabled Bond0 	      10.11.13.6.0/24 (dns)
ceph-access-space 	7 (ceph-access) 	Disabled Bond1 	      7.8.9.0/24 (ceph-access)
  • Back to Machines tab. Click one of juju machines, navigate to Network section. Create bondm and use proper ip address. (do this to all juju machines)

  • Move to Configuration tab. Add juju-controller tags. (do this to all juju machines)

  • If all machines are on Ready state, we can continue to the next steps.

Install Juju

  • Install juju client on all maas nodes.
snap install juju --channel 2.8

Add MaaS to Juju

  • Create a maas-cloud.yaml file. (maas01 only)
vim maas-cloud.yaml
---
clouds:
  sofyan:
    type: maas
    auth-types: [oauth1]
    endpoint: http://10.101.1.11:5240/MAAS
  • Add cloud juju. (maas01 only)
juju add-cloud --client -f maas-cloud.yaml sofyan
  • Verify the cloud. (maas01 only)
juju list-clouds

Add MaaS Credentials

  • Create a maas-credentials.yaml file. (maas01 only)
credentials:
  sofyan:
    root:
      auth-type: oauth1
      maas-oauth: $(maas apikey --username=root)
juju add-credential --client -f maas-credential.yaml sofyan
juju credentials

Bootstrap Juju Controller

  • Create juju-config.yaml file, then bootstrap juju controller with it. (maas01 only)
cat << 'EOF' > juju-config.yaml
default-series: bionic
default-space: oam-space
juju-ha-space: oam-space
juju-mgmt-space: oam-space
EOF
juju bootstrap --config=juju-config.yaml --bootstrap-constraints="tags=juju-controller" sofyan sofyan01-maas01-rack01
  • Wait until the bootstrap is completed, then enable the Juju HA.
juju enable-ha -n3
  • Check machine status.
root@sofyan01-maas001-rack001:~# juju switch controller
root@sofyan01-maas001-rack001:~# juju status
Model       Controller             Cloud/Region   Version  SLA          Timestamp       Notes
controller  sofyan01-maas001-rack001  sofyan/default  2.8.0    unsupported  09:53:12+07:00

Machine  State    DNS         Inst id                Series  AZ       Message
0        started  10.101.1.21  aoxm4lza                  bionic  default  Deployed
1        started  10.101.1.22  sofyan01-juju002-rack002  bionic  default  Deployed
2        started  10.101.1.23  sofyan01-juju003-rack003  bionic  default  Deployed
  • If there is any problem when you want to SSH maas nodes, just change permission of this directories.
chmod go-w /root
chown root /root
chown root /root/.ssh
  • Now, juju are on position we can deploy like OpenStack more easily using Juju.