provision ipv4 / dual now works till flannel
This commit is contained in:
parent
c7448b0a2f
commit
c2b36de571
7 changed files with 49 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="provs-server" type="JetRunConfigurationType">
|
<configuration default="false" name="provs-server statistics.dev" type="JetRunConfigurationType">
|
||||||
<option name="MAIN_CLASS_NAME" value="org.domaindrivenarchitecture.provs.server.application.ApplicationKt" />
|
<option name="MAIN_CLASS_NAME" value="org.domaindrivenarchitecture.provs.server.application.ApplicationKt" />
|
||||||
<module name="provs.main" />
|
<module name="provs.main" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="k3s -r statistics.test.meissa-gmbh.de -u root -k" />
|
<option name="PROGRAM_PARAMETERS" value="k3s -r statistics.test.meissa-gmbh.de -u root -k" />
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.domaindrivenarchitecture.provs.server.infrastructure.provisionNetwork
|
||||||
* 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.provisionK3s() = task {
|
fun Prov.provisionK3s() = task {
|
||||||
provisionNetwork()
|
provisionNetwork(loopbackIpv4 = "192.168.5.1", loopbackIpv6 = "fc00::5:1")
|
||||||
provisionK3sInfra()
|
provisionK3sInfra(tlsName = "statistics.prod.meissa-gmbh.de", nodeIpv4 = "162.55.166.39", nodeIpv6 = "2a01:4f8:c010:622b::1",
|
||||||
|
loopbackIpv4 = "192.168.5.1", loopbackIpv6 = "fc00::5:1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.*
|
||||||
|
|
||||||
// TODO: jem - 2022.01.24 - these are global vars without scope / ns !
|
// TODO: jem - 2022.01.24 - these are global vars without scope / ns !
|
||||||
val k3sConfigFile = "/etc/rancher/k3s/config.yaml"
|
val k3sConfigFile = "/etc/rancher/k3s/config.yaml"
|
||||||
val k3sCalicoFile = "/etc/rancher/k3s/calico.yaml"
|
val k3sCalicoFile = "/var/lib/rancher/k3s/server/manifests/calico.yaml"
|
||||||
val k3sInstallFile = "/usr/local/bin/k3s-install.sh"
|
val k3sInstallFile = "/usr/local/bin/k3s-install.sh"
|
||||||
val k3sResourcePath = "org/domaindrivenarchitecture/provs/infrastructure/k3s/"
|
val k3sResourcePath = "org/domaindrivenarchitecture/provs/infrastructure/k3s/"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ fun Prov.testConfigExists(): Boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Prov.deprovisionK3sInfra() = task {
|
fun Prov.deprovisionK3sInfra() = task {
|
||||||
deleteFile(k3sCalicoFile, sudo = true)
|
//deleteFile(k3sCalicoFile, sudo = true)
|
||||||
deleteFile(k3sInstallFile, sudo = true)
|
deleteFile(k3sInstallFile, sudo = true)
|
||||||
cmd("k3s-uninstall.sh")
|
cmd("k3s-uninstall.sh")
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,38 @@ fun Prov.deprovisionK3sInfra() = task {
|
||||||
* 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 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.
|
* 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(tlsName: String, nodeIpv4: String, loopbackIpv4: String, loopbackIpv6: String,
|
||||||
deprovisionK3sInfra()
|
nodeIpv6: String? = null, docker: Boolean = false, tlsHost: String? = null) = task {
|
||||||
|
val isDualStack = nodeIpv6?.isNotEmpty() ?: false
|
||||||
|
if (testConfigExists()) {
|
||||||
|
deprovisionK3sInfra()
|
||||||
|
}
|
||||||
if (!testConfigExists()) {
|
if (!testConfigExists()) {
|
||||||
createDirs("/etc/rancher/k3s/", sudo = true)
|
createDirs("/etc/rancher/k3s/", sudo = true)
|
||||||
|
var k3sConfigFileName = "config.yaml.template"
|
||||||
|
var k3sConfigMap: Map<String, String> = mapOf("loopback_ipv4" to loopbackIpv4, "loopback_ipv6" to loopbackIpv6,
|
||||||
|
"node_ipv4" to nodeIpv4, "tls_name" to tlsName)
|
||||||
|
if (isDualStack) {
|
||||||
|
k3sConfigFileName += ".dual"
|
||||||
|
k3sConfigMap = k3sConfigMap.plus("node_ipv6" to nodeIpv6!!)
|
||||||
|
/*
|
||||||
|
createFileFromResource(
|
||||||
|
k3sCalicoFile,
|
||||||
|
"calico.yaml",
|
||||||
|
k3sResourcePath,
|
||||||
|
"644",
|
||||||
|
sudo = true
|
||||||
|
)
|
||||||
|
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
k3sConfigFileName += ".ipv4"
|
||||||
|
}
|
||||||
createFileFromResourceTemplate(
|
createFileFromResourceTemplate(
|
||||||
k3sConfigFile,
|
k3sConfigFile,
|
||||||
"config.yaml.template",
|
k3sConfigFileName,
|
||||||
k3sResourcePath,
|
k3sResourcePath,
|
||||||
mapOf("loopback_ipv4" to "192.168.5.1", "loopback_ipv6" to "fc00::5:1",
|
k3sConfigMap,
|
||||||
"node_ipv4" to "159.69.176.151", "node_ipv6" to "2a01:4f8:c010:2f72::1"),
|
|
||||||
"644",
|
"644",
|
||||||
sudo = true
|
sudo = true
|
||||||
)
|
)
|
||||||
|
@ -45,15 +67,7 @@ fun Prov.provisionK3sInfra(docker: Boolean = false, tlsHost: String? = null, opt
|
||||||
"755",
|
"755",
|
||||||
sudo = true
|
sudo = true
|
||||||
)
|
)
|
||||||
createFileFromResource(
|
// TODO: doeas not work yet cmd("k3s-install.sh")
|
||||||
k3sCalicoFile,
|
|
||||||
"calico.yaml",
|
|
||||||
k3sResourcePath,
|
|
||||||
"644",
|
|
||||||
sudo = true
|
|
||||||
)
|
|
||||||
// TODO: verify the download !
|
|
||||||
//cmd("curl -sfL https://get.k3s.io | sh -")
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ fun Prov.testNetworkExists(): Boolean {
|
||||||
return fileExists(loopbackFile)
|
return fileExists(loopbackFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Prov.provisionNetwork() = task {
|
fun Prov.provisionNetwork(loopbackIpv4: String, loopbackIpv6: String) = task {
|
||||||
if(!testNetworkExists()) {
|
if(!testNetworkExists()) {
|
||||||
createFileFromResourceTemplate(
|
createFileFromResourceTemplate(
|
||||||
loopbackFile,
|
loopbackFile,
|
||||||
"99-loopback.yaml.template",
|
"99-loopback.yaml.template",
|
||||||
resourcePath,
|
resourcePath,
|
||||||
mapOf("loopback_ipv4" to "192.168.5.1/32", "loopback_ipv6" to "fc00::5:1/128"),
|
mapOf("loopback_ipv4" to loopbackIpv4, "loopback_ipv6" to loopbackIpv6),
|
||||||
"644",
|
"644",
|
||||||
sudo = true
|
sudo = true
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
etcd-disable-snapshots: true
|
etcd-disable-snapshots: true
|
||||||
default-local-storage-path: /var
|
default-local-storage-path: /var
|
||||||
flannel-backend: none
|
tls-san: ${tls_name}
|
||||||
disable-network-policy: true
|
disable-network-policy: true
|
||||||
cluster-cidr:
|
cluster-cidr:
|
||||||
- 10.42.0.0/16
|
- 10.42.0.0/16
|
|
@ -0,0 +1,10 @@
|
||||||
|
etcd-disable-snapshots: true
|
||||||
|
default-local-storage-path: /var
|
||||||
|
tls-san: ${tls_name}
|
||||||
|
cluster-cidr:
|
||||||
|
- 10.42.0.0/16
|
||||||
|
service-cidr:
|
||||||
|
- 10.43.0.0/16
|
||||||
|
node-ip:
|
||||||
|
- ${node_ipv4}
|
||||||
|
bind-address: ${loopback_ipv4}
|
|
@ -6,5 +6,5 @@ network:
|
||||||
match:
|
match:
|
||||||
name: lo
|
name: lo
|
||||||
addresses:
|
addresses:
|
||||||
- ${loopback_ipv4}
|
- ${loopback_ipv4}/32
|
||||||
- ${loopback_ipv6}
|
- ${loopback_ipv6}/128
|
||||||
|
|
Loading…
Reference in a new issue