forked from ss/sovereign-stack
Implement LXD projects.
This commit is contained in:
parent
f5deac4874
commit
9c518e47e2
@ -83,6 +83,7 @@ export LXD_UBUNTU_BASE_VERSION="jammy"
|
|||||||
export BASE_IMAGE_VM_NAME="ss-base-${LXD_UBUNTU_BASE_VERSION//./-}"
|
export BASE_IMAGE_VM_NAME="ss-base-${LXD_UBUNTU_BASE_VERSION//./-}"
|
||||||
export BASE_LXC_IMAGE="ubuntu/$LXD_UBUNTU_BASE_VERSION/cloud"
|
export BASE_LXC_IMAGE="ubuntu/$LXD_UBUNTU_BASE_VERSION/cloud"
|
||||||
export UBUNTU_BASE_IMAGE_NAME="ss-ubuntu-${LXD_UBUNTU_BASE_VERSION//./-}"
|
export UBUNTU_BASE_IMAGE_NAME="ss-ubuntu-${LXD_UBUNTU_BASE_VERSION//./-}"
|
||||||
|
export DOCKER_BASE_IMAGE_NAME="ss-docker-${LXD_UBUNTU_BASE_VERSION//./-}"
|
||||||
|
|
||||||
# Deploy a registry cache on your management machine.
|
# Deploy a registry cache on your management machine.
|
||||||
export DEPLOY_MGMT_REGISTRY=false
|
export DEPLOY_MGMT_REGISTRY=false
|
||||||
|
@ -23,6 +23,12 @@ fi
|
|||||||
|
|
||||||
. ./project_env.sh
|
. ./project_env.sh
|
||||||
|
|
||||||
|
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
||||||
|
if lxc project list | grep -q "$PROJECT_NAME"; then
|
||||||
|
lxc project switch "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
for VM in www btcpayserver; do
|
for VM in www btcpayserver; do
|
||||||
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
||||||
|
|
||||||
@ -39,6 +45,19 @@ for VM in www btcpayserver; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if lxc network list -q | grep -q ss-ovn; then
|
||||||
|
lxc network delete ss-ovn
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! lxc info | grep "project:" | grep -q default; then
|
||||||
|
lxc project switch default
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if lxc project list | grep -q "$PROJECT_NAME"; then
|
||||||
|
lxc project delete "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
# delete the base image so it can be created.
|
# delete the base image so it can be created.
|
||||||
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
||||||
lxc delete -f "$BASE_IMAGE_VM_NAME"
|
lxc delete -f "$BASE_IMAGE_VM_NAME"
|
||||||
|
@ -155,12 +155,26 @@ if ! command -v lxc >/dev/null 2>&1; then
|
|||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if lxc network list --format csv | grep -q lxdbr1; then
|
||||||
|
lxc network delete lxdbr1
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install dependencies.
|
# install dependencies.
|
||||||
|
ssh -t "ubuntu@$FQDN" 'sudo apt update && sudo apt upgrade -y && sudo apt install htop dnsutils nano -y'
|
||||||
if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then
|
if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then
|
||||||
|
ssh -t "ubuntu@$FQDN" 'sudo snap install lxd --channel=5.11/stable'
|
||||||
|
sleep 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# install OVN for the project-specific bridge networks
|
||||||
|
ssh -t "ubuntu@$FQDN" "sudo apt-get install -y ovn-host ovn-central"
|
||||||
|
|
||||||
|
ssh -t "ubuntu@$FQDN" "sudo ovs-vsctl set open_vswitch . external_ids:ovn-remote=unix:/var/run/ovn/ovnsb_db.sock external_ids:ovn-encap-type=geneve external_ids:ovn-encap-ip=127.0.0.1"
|
||||||
|
|
||||||
# if the DATA_PLANE_MACVLAN_INTERFACE is not specified, then we 'll
|
# if the DATA_PLANE_MACVLAN_INTERFACE is not specified, then we 'll
|
||||||
# just attach VMs to the network interface used for for the default route.
|
# just attach VMs to the network interface used for for the default route.
|
||||||
if [ -z "$DATA_PLANE_MACVLAN_INTERFACE" ]; then
|
if [ -z "$DATA_PLANE_MACVLAN_INTERFACE" ]; then
|
||||||
@ -182,9 +196,20 @@ networks:
|
|||||||
description: "ss-config,${DATA_PLANE_MACVLAN_INTERFACE:-error}"
|
description: "ss-config,${DATA_PLANE_MACVLAN_INTERFACE:-error}"
|
||||||
type: bridge
|
type: bridge
|
||||||
config:
|
config:
|
||||||
|
ipv4.address: 10.9.9.1/24
|
||||||
|
ipv4.dhcp.ranges: 10.9.9.10-10.9.9.127
|
||||||
ipv4.nat: true
|
ipv4.nat: true
|
||||||
ipv6.address: none
|
ipv6.address: none
|
||||||
dns.mode: managed
|
dns.mode: managed
|
||||||
|
- name: lxdbr1
|
||||||
|
description: "Non-natting bridge for ovn networks to connect to."
|
||||||
|
type: bridge
|
||||||
|
config:
|
||||||
|
ipv4.address: 10.10.10.1/24
|
||||||
|
ipv4.dhcp.ranges: 10.10.10.10-10.10.10.63
|
||||||
|
ipv4.ovn.ranges: 10.10.10.64-10.10.10.254
|
||||||
|
ipv4.nat: false
|
||||||
|
ipv6.address: none
|
||||||
profiles:
|
profiles:
|
||||||
- config: {}
|
- config: {}
|
||||||
description: "default profile for sovereign-stack instances."
|
description: "default profile for sovereign-stack instances."
|
||||||
|
@ -17,8 +17,8 @@ if lxc image list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
|||||||
lxc image rm "$BASE_IMAGE_VM_NAME"
|
lxc image rm "$BASE_IMAGE_VM_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
if lxc image list | grep -q "$DOCKER_BASE_IMAGE_NAME"; then
|
||||||
lxc image rm "$UBUNTU_BASE_IMAGE_NAME"
|
lxc image rm "$DOCKER_BASE_IMAGE_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURRENT_PROJECT="$(lxc info | grep "project:" | awk '{print $2}')"
|
CURRENT_PROJECT="$(lxc info | grep "project:" | awk '{print $2}')"
|
||||||
@ -39,6 +39,11 @@ if lxc network list --format csv | grep -q lxdbr0; then
|
|||||||
lxc network delete lxdbr0
|
lxc network delete lxdbr0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if lxc network list --format csv | grep -q lxdbr1; then
|
||||||
|
lxc network delete lxdbr1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if lxc storage list --format csv | grep -q ss-base; then
|
if lxc storage list --format csv | grep -q ss-base; then
|
||||||
lxc storage delete ss-base
|
lxc storage delete ss-base
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user