prepare dual-stack
This commit is contained in:
parent
bfc459b667
commit
09c90f1297
5 changed files with 76 additions and 18 deletions
11
.run/provs-server.run.xml
Normal file
11
.run/provs-server.run.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="provs-server" type="JetRunConfigurationType">
|
||||||
|
<option name="MAIN_CLASS_NAME" value="org.domaindrivenarchitecture.provs.server.application.ApplicationKt" />
|
||||||
|
<module name="provs.main" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="k3s -r statistics.test.meissa-gmbh.de -u root -k" />
|
||||||
|
<shortenClasspath name="NONE" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
|
@ -2,8 +2,17 @@ package org.domaindrivenarchitecture.provs.server.infrastructure
|
||||||
|
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.echoCommandForText
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDirs
|
||||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createFileFromResourceTemplate
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileExists
|
||||||
|
|
||||||
|
// TODO: jem - 2022.01.24 - these are global vars without scope / ns !
|
||||||
|
val k3sConfigFile = "/etc/rancher/k3s/config.yaml"
|
||||||
|
val k3sResourcePath = "org/domaindrivenarchitecture/provs/infrastructure/k3s/"
|
||||||
|
|
||||||
|
fun Prov.testConfigExists(): Boolean {
|
||||||
|
return fileExists(k3sConfigFile)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs a k3s server.
|
* Installs a k3s server.
|
||||||
|
@ -11,30 +20,52 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInsta
|
||||||
* If tlsHost is specified, then tls (if configured) also applies to the specified host.
|
* If tlsHost is specified, then tls (if configured) also applies to the specified host.
|
||||||
*/
|
*/
|
||||||
fun Prov.provisionK3sInfra(docker: Boolean = false, tlsHost: String? = null, options: String? = null) = task {
|
fun Prov.provisionK3sInfra(docker: Boolean = false, tlsHost: String? = null, options: String? = null) = task {
|
||||||
val tlsSanOption = tlsHost?.let { "--tls-san ${it}" } ?: ""
|
if (!testConfigExists()) {
|
||||||
|
createDirs("/etc/rancher/k3s/", sudo = true)
|
||||||
|
createFileFromResourceTemplate(
|
||||||
|
k3sConfigFile,
|
||||||
|
"config.yaml.template",
|
||||||
|
k3sResourcePath,
|
||||||
|
mapOf("loopback_ipv4" to "192.168.5.1", "loopback_ipv6" to "fc00::5:1",
|
||||||
|
"node_ipv4" to "159.69.176.151", "node_ipv6" to "2a01:4f8:c010:2f72::1"),
|
||||||
|
"644",
|
||||||
|
sudo = true
|
||||||
|
)
|
||||||
|
// TODO: verify the download !
|
||||||
|
//cmd("curl -sfL https://get.k3s.io | sh -")
|
||||||
|
|
||||||
val k3sAllOptions = if (tlsHost == null && options == null)
|
/*
|
||||||
""
|
|
||||||
else
|
|
||||||
"INSTALL_K3S_EXEC=\"$tlsSanOption ${options ?: ""}\""
|
|
||||||
|
|
||||||
aptInstall("curl")
|
org/domaindrivenarchitecture/provs/infrastructure/k3s/config.yaml.template.template
|
||||||
if (!chk("k3s -version")) {
|
|
||||||
if (docker) {
|
val tlsSanOption = tlsHost?.let { "--tls-san ${it}" } ?: ""
|
||||||
// might not work if docker already installed
|
|
||||||
sh("""
|
val k3sAllOptions = if (tlsHost == null && options == null)
|
||||||
|
""
|
||||||
|
else
|
||||||
|
"INSTALL_K3S_EXEC=\"$tlsSanOption ${options ?: ""}\""
|
||||||
|
|
||||||
|
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 https://releases.rancher.com/install-docker/19.03.sh | sh
|
||||||
curl -sfL https://get.k3s.io | $k3sAllOptions sh -s - --docker
|
curl -sfL https://get.k3s.io | $k3sAllOptions sh -s - --docker
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
} else {
|
)
|
||||||
cmd("curl -sfL https://get.k3s.io | $k3sAllOptions sh -")
|
} else {
|
||||||
|
cmd("curl -sfL https://get.k3s.io | $k3sAllOptions sh -")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
ProvResult(true)
|
ProvResult(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun Prov.uninstallK3sServer() = task {
|
fun Prov.uninstallK3sServer() = task {
|
||||||
cmd("sudo /usr/local/bin/k3s-uninstall.sh")
|
cmd("sudo /usr/local/bin/k3s-uninstall.sh")
|
||||||
|
@ -44,3 +75,4 @@ fun Prov.uninstallK3sServer() = task {
|
||||||
fun Prov.applyK3sConfig(configAsYaml: String) = task {
|
fun Prov.applyK3sConfig(configAsYaml: String) = task {
|
||||||
cmd(echoCommandForText(configAsYaml) + " | sudo k3s kubectl apply -f -")
|
cmd(echoCommandForText(configAsYaml) + " | sudo k3s kubectl apply -f -")
|
||||||
}
|
}
|
||||||
|
*/
|
|
@ -18,7 +18,7 @@ fun Prov.provisionNetwork() = task {
|
||||||
loopbackFile,
|
loopbackFile,
|
||||||
"99-loopback.yaml.template",
|
"99-loopback.yaml.template",
|
||||||
resourcePath,
|
resourcePath,
|
||||||
mapOf("ip" to "192.168.5.1/32"),
|
mapOf("loopback_ipv4" to "192.168.5.1/32", "loopback_ipv6" to "fc00::5:1/128"),
|
||||||
"644",
|
"644",
|
||||||
sudo = true
|
sudo = true
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
etcd-disable-snapshots: true
|
||||||
|
default-local-storage-path: /var
|
||||||
|
flannel-backend: none
|
||||||
|
disable-network-policy: true
|
||||||
|
cluster-cidr:
|
||||||
|
- 10.42.0.0/16
|
||||||
|
- fd42::/48
|
||||||
|
service-cidr:
|
||||||
|
- 10.43.0.0/16
|
||||||
|
- fd43::/112
|
||||||
|
node-ip:
|
||||||
|
- ${node_ipv4}
|
||||||
|
- ${node_ipv6}
|
||||||
|
bind-address: ${loopback_ipv4}
|
|
@ -6,4 +6,5 @@ network:
|
||||||
match:
|
match:
|
||||||
name: lo
|
name: lo
|
||||||
addresses:
|
addresses:
|
||||||
- $ip
|
- ${loopback_ipv4}
|
||||||
|
- ${loopback_ipv6}
|
||||||
|
|
Loading…
Reference in a new issue