Files
provider-kairos/internal/services/edgevpn.go
mudler 0517b1e766 Add kubeVIP support with p2p hybrid mode
In this way, the p2p API will just run the co-ordination to setup KubeVIP automatically
to the new cluster.

Signed-off-by: Ettore Di Giacinto <mudler@mocaccino.org>
2022-12-05 11:53:33 +01:00

103 lines
2.5 KiB
Go

package services
import (
"github.com/kairos-io/kairos/pkg/machine/openrc"
"github.com/kairos-io/kairos/pkg/machine/systemd"
"github.com/kairos-io/kairos/pkg/machine"
"github.com/kairos-io/kairos/pkg/utils"
)
const edgevpnOpenRC string = `#!/sbin/openrc-run
depend() {
after net
provide edgevpn
}
supervisor=supervise-daemon
name="edgevpn"
command="edgevpn"
supervise_daemon_args="--stdout /var/log/edgevpn.log --stderr /var/log/edgevpn.log"
pidfile="/run/edgevpn.pid"
respawn_delay=5
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
if [ -f /etc/systemd/system.conf.d/edgevpn-kairos.env ]; then source /etc/systemd/system.conf.d/edgevpn-kairos.env; fi
set +o allexport`
const edgevpnAPIOpenRC string = `#!/sbin/openrc-run
depend() {
after net
provide edgevpn
}
supervisor=supervise-daemon
name="edgevpn"
command="edgevpn api --enable-healthchecks"
supervise_daemon_args="--stdout /var/log/edgevpn.log --stderr /var/log/edgevpn.log"
pidfile="/run/edgevpn.pid"
respawn_delay=5
set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
if [ -f /etc/systemd/system.conf.d/edgevpn-kairos.env ]; then source /etc/systemd/system.conf.d/edgevpn-kairos.env; fi
set +o allexport`
const edgevpnAPISystemd string = `[Unit]
Description=P2P API Daemon
After=network.target
[Service]
EnvironmentFile=/etc/systemd/system.conf.d/edgevpn-kairos.env
LimitNOFILE=49152
ExecStart=edgevpn api --enable-healthchecks
Restart=always
[Install]
WantedBy=multi-user.target`
const edgevpnSystemd string = `[Unit]
Description=EdgeVPN Daemon
After=network.target
[Service]
EnvironmentFile=/etc/systemd/system.conf.d/edgevpn-%i.env
LimitNOFILE=49152
ExecStart=edgevpn
Restart=always
[Install]
WantedBy=multi-user.target`
const EdgeVPNDefaultInstance string = "kairos"
func EdgeVPN(instance, rootDir string) (machine.Service, error) {
if utils.IsOpenRCBased() {
return openrc.NewService(
openrc.WithName("edgevpn"),
openrc.WithUnitContent(edgevpnOpenRC),
openrc.WithRoot(rootDir),
)
}
return systemd.NewService(
systemd.WithName("edgevpn"),
systemd.WithInstance(instance),
systemd.WithUnitContent(edgevpnSystemd),
systemd.WithRoot(rootDir),
)
}
func P2PAPI(rootDir string) (machine.Service, error) {
if utils.IsOpenRCBased() {
return openrc.NewService(
openrc.WithName("edgevpn"),
openrc.WithUnitContent(edgevpnAPIOpenRC),
openrc.WithRoot(rootDir),
)
}
return systemd.NewService(
systemd.WithName("edgevpn"),
systemd.WithUnitContent(edgevpnAPISystemd),
systemd.WithRoot(rootDir),
)
}