v0.8.36 add options to k3s
This commit is contained in:
parent
080b006d6e
commit
404235a9e2
4 changed files with 18 additions and 14 deletions
|
@ -18,7 +18,7 @@ apply plugin: 'kotlinx-serialization'
|
|||
|
||||
|
||||
group = 'org.domaindrivenarchitecture.provs'
|
||||
version = '0.8.36-SNAPSHOT'
|
||||
version = '0.8.36'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.domaindrivenarchitecture.provs.extensions.server_software.k3s.application
|
||||
|
||||
import org.domaindrivenarchitecture.provs.core.Prov
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.installK3sServer
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.domain.installK3sServer
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.domaindrivenarchitecture.provs.extensions.server_software.k3s
|
||||
package org.domaindrivenarchitecture.provs.extensions.server_software.k3s.domain
|
||||
|
||||
import org.domaindrivenarchitecture.provs.core.Prov
|
||||
import org.domaindrivenarchitecture.provs.core.ProvResult
|
||||
|
@ -8,21 +8,27 @@ import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstall
|
|||
|
||||
/**
|
||||
* Installs a k3s server.
|
||||
* If docker is true, then k3s will be installed with docker option and also docker will be installed (may conflict if docker is already existing).
|
||||
* If host is specified, then tls (if configured) also applies to host.
|
||||
* If docker is true, then docker will be installed (may conflict if docker is already existing) and k3s will be installed with docker option.
|
||||
* If tlsHost is specified, then tls (if configured) also applies to the specified host.
|
||||
*/
|
||||
fun Prov.installK3sServer(docker: Boolean = false, host: String? = null) = task {
|
||||
val tls = host?.let { "INSTALL_K3S_EXEC=\"--tls-san ${it}\"" } ?: ""
|
||||
fun Prov.installK3sServer(docker: Boolean = false, tlsHost: String? = null, options: String? = null) = task {
|
||||
val tlsSanOption = tlsHost?.let { "--tls-san ${it}" } ?: ""
|
||||
|
||||
val k3sOptions = if (tlsHost == null && options == null)
|
||||
""
|
||||
else
|
||||
"INSTALL_K3S_EXEC=\"$options $tlsSanOption\""
|
||||
|
||||
aptInstall("curl")
|
||||
if (!chk("k3s -version")) {
|
||||
if (docker) {
|
||||
// might not work if docker already installed
|
||||
sh("""
|
||||
curl https://releases.rancher.com/install-docker/19.03.sh | sh
|
||||
curl -sfL https://get.k3s.io | sh -s - --docker
|
||||
curl -sfL https://get.k3s.io | $k3sOptions sh -s - --docker
|
||||
""".trimIndent())
|
||||
} else {
|
||||
cmd("curl -sfL https://get.k3s.io | $tls sh -")
|
||||
cmd("curl -sfL https://get.k3s.io | $k3sOptions sh -")
|
||||
}
|
||||
} else {
|
||||
ProvResult(true)
|
||||
|
@ -38,5 +44,3 @@ fun Prov.uninstallK3sServer() = task {
|
|||
fun Prov.applyK3sConfig(configAsYaml: String) = task {
|
||||
cmd(echoCommandForText(configAsYaml) + " | sudo k3s kubectl apply -f -")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import org.domaindrivenarchitecture.provs.core.Prov
|
|||
import org.domaindrivenarchitecture.provs.core.ProvResult
|
||||
import org.domaindrivenarchitecture.provs.core.remote
|
||||
import org.domaindrivenarchitecture.provs.core.repeatTaskUntilSuccess
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.applyK3sConfig
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.installK3sServer
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.domain.applyK3sConfig
|
||||
import org.domaindrivenarchitecture.provs.extensions.server_software.k3s.domain.installK3sServer
|
||||
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ fun main() {
|
|||
val host = "123.34.56.78"
|
||||
|
||||
remote(host, "root").task {
|
||||
installK3sServer(host = host)
|
||||
installK3sServer(tlsHost = host)
|
||||
applyK3sConfig(appleConfig())
|
||||
|
||||
// optional check
|
||||
|
|
Loading…
Reference in a new issue