2021-10-29 17:12:13 +00:00
|
|
|
# lxd / maas issue. either upgrade lxd or maas to 3.1
|
|
|
|
sudo snap switch --channel=4.19/stable lxd
|
|
|
|
sudo snap refresh lxd
|
|
|
|
|
2021-10-27 10:57:40 +00:00
|
|
|
#get local interface name (this assumes a single default route is present)
|
|
|
|
export INTERFACE=$(ip route | grep default | cut -d ' ' -f 5)
|
|
|
|
export IP_ADDRESS=$(ip -4 addr show dev $INTERFACE | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
|
|
|
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
|
|
|
sysctl -p
|
|
|
|
iptables -t nat -A POSTROUTING -o $INTERFACE -j SNAT --to $IP_ADDRESS
|
|
|
|
#TODO inbound port forwarding/load balancing
|
|
|
|
# Persist NAT configuration
|
|
|
|
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
|
|
|
|
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
|
|
|
|
apt-get install iptables-persistent -y
|
|
|
|
# LXD init
|
|
|
|
cat /tmp/lxd.cfg | lxd init --preseed
|
|
|
|
# Wait for LXD to be ready
|
|
|
|
lxd waitready
|
|
|
|
# Initialise MAAS
|
|
|
|
maas init region+rack --database-uri maas-test-db:/// --maas-url http://${IP_ADDRESS}:5240/MAAS
|
|
|
|
sleep 15
|
|
|
|
# Create MAAS admin and grab API key
|
|
|
|
maas createadmin --username admin --password admin --email admin
|
|
|
|
export APIKEY=$(maas apikey --username admin)
|
|
|
|
# MAAS admin login
|
|
|
|
maas login admin 'http://localhost:5240/MAAS/' $APIKEY
|
|
|
|
# Configure MAAS networking (set gateways, vlans, DHCP on etc)
|
|
|
|
export SUBNET=10.10.10.0/24
|
|
|
|
export FABRIC_ID=$(maas admin subnet read "$SUBNET" | jq -r ".vlan.fabric_id")
|
|
|
|
export VLAN_TAG=$(maas admin subnet read "$SUBNET" | jq -r ".vlan.vid")
|
|
|
|
export PRIMARY_RACK=$(maas admin rack-controllers read | jq -r ".[] | .system_id")
|
|
|
|
maas admin subnet update $SUBNET gateway_ip=10.10.10.1
|
|
|
|
maas admin ipranges create type=dynamic start_ip=10.10.10.200 end_ip=10.10.10.254
|
|
|
|
maas admin vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK
|
|
|
|
maas admin maas set-config name=upstream_dns value=8.8.8.8
|
|
|
|
# Add LXD as a VM host for MAAS
|
|
|
|
maas admin vm-hosts create password=password type=lxd power_address=https://${IP_ADDRESS}:8443 project=maas
|
|
|
|
|
2021-11-02 11:27:14 +00:00
|
|
|
# creating VMs
|
|
|
|
# TODO find out the name of our vm host, and store this id in a variable
|
2021-10-27 10:57:40 +00:00
|
|
|
maas admin vm-hosts read | jq '.[] | select (.name=="proud-possum") | .name, .id'
|
|
|
|
# add a VM
|
2021-11-02 11:27:14 +00:00
|
|
|
# TODO use the variable for the VM host ID (below it is static 1)
|
2021-10-29 17:12:13 +00:00
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=8192 architecture="amd64/generic" storage="main:100(pool1)"
|
2021-10-27 10:57:40 +00:00
|
|
|
|
2021-10-27 11:08:31 +00:00
|
|
|
# Juju (note, this section requires manual intervention)
|
2021-10-27 10:57:40 +00:00
|
|
|
sudo snap install juju --classic
|
2021-10-27 11:08:31 +00:00
|
|
|
sed -i 's/IP_ADDRESS/${IP_ADDRESS}/' maas-cloud.yaml
|
2021-10-27 10:57:40 +00:00
|
|
|
juju add-cloud --local maas-cloud maas-cloud.yaml
|
|
|
|
juju add-credential maas-cloud
|
|
|
|
juju clouds --local
|
|
|
|
juju credentials
|
2021-10-29 17:12:13 +00:00
|
|
|
juju bootstrap maas-cloud
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# fire up the juju gui to view the fun
|
|
|
|
juju gui
|
|
|
|
# get coffee
|
|
|
|
|
|
|
|
|
|
|
|
# get some storage going
|
|
|
|
# https://jaas.ai/ceph-base
|
|
|
|
# https://jaas.ai/canonical-kubernetes/bundle/471
|
2021-11-02 11:27:14 +00:00
|
|
|
|
|
|
|
# TODO do we need to create ceph-mon machines?
|
|
|
|
|
2021-10-29 17:12:13 +00:00
|
|
|
juju deploy -n 3 ceph-mon
|
|
|
|
|
|
|
|
# add some machines for ceph-osd, 2 disks each
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=2048 architecture="amd64/generic" storage="main:8(pool1),ceph:80(pool1)"
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=2048 architecture="amd64/generic" storage="main:8(pool1),ceph:80(pool1)"
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=2048 architecture="amd64/generic" storage="main:8(pool1),ceph:80(pool1)"
|
|
|
|
|
|
|
|
juju deploy --config ceph-osd.yaml cs:ceph-osd -n 3
|
|
|
|
juju add-relation ceph-mon ceph-osd
|
|
|
|
|
|
|
|
# add some machines for kubernetes-core
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=4096 architecture="amd64/generic" storage="main:24(pool1)"
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=4096 architecture="amd64/generic" storage="main:24(pool1)"
|
|
|
|
maas admin vm-host compose 1 cores=4 cpu_speed=300 memory=4096 architecture="amd64/generic" storage="main:24(pool1)"
|
|
|
|
|
|
|
|
# deploy kubernetes-core with juju
|
|
|
|
juju deploy kubernetes-core
|
|
|
|
# add the new kubernetes as a cloud to juju
|
|
|
|
mkdir ~/.kube
|
|
|
|
juju scp kubernetes-master/0:/home/ubuntu/config ~/.kube/config
|
|
|
|
|
|
|
|
# add storage relations
|
|
|
|
juju add-relation ceph-mon:admin kubernetes-master
|
|
|
|
juju add-relation ceph-mon:client kubernetes-master
|
|
|
|
|
|
|
|
# add k8s to juju
|
|
|
|
juju add-k8s my-k8s
|
|
|
|
juju bootstrap my-k8s
|
|
|
|
|
|
|
|
# add a model (k8s namespace) to the cluster
|
|
|
|
juju add-model k8s-model my-k8s
|
|
|
|
|
|
|
|
# add an LMA model to the cluster
|
|
|
|
juju add-model lma my-k8s
|
|
|
|
|
|
|
|
juju deploy lma-light --channel=edge --trust
|
|
|
|
#juju destroy-controller -y --destroy-all-models --destroy-storage maas-cloud-default
|