refactor provisionK3s
This commit is contained in:
parent
7ca6723b4d
commit
876836f6a3
1 changed files with 33 additions and 26 deletions
|
@ -6,43 +6,50 @@ import org.domaindrivenarchitecture.provs.server.domain.k8s_grafana_agent.provis
|
|||
import org.domaindrivenarchitecture.provs.server.infrastructure.*
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Installs a k3s server.
|
||||
*/
|
||||
|
||||
fun Prov.provisionK3s(cli: K3sCliCommand) = task {
|
||||
|
||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
|
||||
|
||||
if (cli.submodules == null) {
|
||||
provisionNetwork(k3sConfig)
|
||||
if (k3sConfig.reprovision && testConfigExists()) {
|
||||
deprovisionK3sInfra()
|
||||
}
|
||||
|
||||
installK3s(k3sConfig)
|
||||
|
||||
if (k3sConfig.certmanager != null) {
|
||||
provisionK3sCertManager(k3sConfig.certmanager)
|
||||
}
|
||||
|
||||
if (k3sConfig.echo == true) {
|
||||
provisionK3sEcho(k3sConfig.fqdn, k3sConfig.certmanager?.letsencryptEndpoint)
|
||||
}
|
||||
|
||||
if (grafanaConfigResolved != null) {
|
||||
provisionGrafanaAgent(grafanaConfigResolved)
|
||||
}
|
||||
|
||||
if (cli.applicationFileName != null) {
|
||||
provisionK3sApplication(cli.applicationFileName)
|
||||
}
|
||||
// full k3s
|
||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||
provisionK3s(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
||||
} else {
|
||||
// submodules only
|
||||
provisionMeissaDesktopSubmodules(cli.submodules, grafanaConfigResolved)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a k3s server.
|
||||
*/
|
||||
fun Prov.provisionK3s(k3sConfig: K3sConfig, grafanaConfigResolved: GrafanaAgentConfigResolved?, applicationFileName: ApplicationFileName?) = task {
|
||||
provisionNetwork(k3sConfig)
|
||||
if (k3sConfig.reprovision && testConfigExists()) {
|
||||
deprovisionK3sInfra()
|
||||
}
|
||||
|
||||
installK3s(k3sConfig)
|
||||
|
||||
if (k3sConfig.certmanager != null) {
|
||||
provisionK3sCertManager(k3sConfig.certmanager)
|
||||
}
|
||||
|
||||
if (k3sConfig.echo == true) {
|
||||
provisionK3sEcho(k3sConfig.fqdn, k3sConfig.certmanager?.letsencryptEndpoint)
|
||||
}
|
||||
|
||||
if (grafanaConfigResolved != null) {
|
||||
provisionGrafanaAgent(grafanaConfigResolved)
|
||||
}
|
||||
|
||||
if (applicationFileName != null) {
|
||||
provisionK3sApplication(applicationFileName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Prov.provisionMeissaDesktopSubmodules(submodules: List<String>, grafanaConfigResolved: GrafanaAgentConfigResolved?) = task {
|
||||
if (submodules.contains(ServerSubmodule.GRAFANA.name.lowercase())) {
|
||||
if (grafanaConfigResolved == null) {
|
||||
|
|
Loading…
Reference in a new issue