diff --git a/.run/provs-server statistics.prod.run.xml b/.run/provs-server statistics.prod.run.xml
deleted file mode 100644
index 5dacf84..0000000
--- a/.run/provs-server statistics.prod.run.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.run/provs-server.run.xml b/.run/provs-server.run.xml
index 5753a1f..e0cf282 100644
--- a/.run/provs-server.run.xml
+++ b/.run/provs-server.run.xml
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/application/Application.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/application/Application.kt
index 3dc12c0..fd387b8 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/application/Application.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/application/Application.kt
@@ -13,7 +13,7 @@ import kotlin.system.exitProcess
*/
fun main(args: Array) {
- val checkedArgs = if (args.size == 0) arrayOf("-h") else args
+ val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
val cmd = CliArgumentsParser("java -jar provs-server.jar").parseCommand(checkedArgs)
if (!cmd.isValid()) {
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sConfig.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sConfig.kt
index 89b4dee..04796ca 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sConfig.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sConfig.kt
@@ -12,9 +12,6 @@ data class K3sConfig(
val apple: Apple? = null,
val reprovision: Reprovision = false
) {
-
- // valid only if: apple != null >> certmanager != null
-
fun isDualStack(): Boolean {
return node.ipv6 != null && loopback.ipv6 != null
}
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt
index d615589..3ab669e 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt
@@ -21,7 +21,7 @@ fun Prov.provisionK3s(configFileName: ConfigFileName?) = task {
provisionK3sCertManager(k3sConfig.certmanager)
}
if (k3sConfig.apple != null && k3sConfig.apple) {
- provisionK3sApple(k3sConfig.fqdn, k3sConfig.certmanager!!.letsencryptEndpoint)
+ provisionK3sApple(k3sConfig.fqdn, k3sConfig.certmanager?.letsencryptEndpoint)
}
ProvResult(true)
}
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt
index 2799324..041be05 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt
@@ -78,7 +78,7 @@ fun Prov.provisionK3sInfra(k3sConfig: K3sConfig) = task {
"644",
sudo = true
)
- cmd ("kubectl apply -f $k3sTraeficWorkaround", sudo = true)
+ cmd("kubectl apply -f $k3sTraeficWorkaround", sudo = true)
} else {
ProvResult(true)
}
@@ -97,7 +97,7 @@ fun Prov.provisionK3sCertManager(certmanager: Certmanager) = task {
"644",
sudo = true
)
- cmd ("kubectl apply -f $certManagerDeployment", sudo = true)
+ cmd("kubectl apply -f $certManagerDeployment", sudo = true)
createFileFromResourceTemplate(
certManagerIssuer,
"le-issuer.template.yaml",
@@ -115,12 +115,28 @@ fun Prov.provisionK3sCertManager(certmanager: Certmanager) = task {
}
}
-fun Prov.provisionK3sApple(fqdn: String, endpoint: CertmanagerEndpoint) = task {
+fun Prov.provisionK3sApple(fqdn: String, endpoint: CertmanagerEndpoint?) = task {
+ val endpointName = endpoint?.name?.lowercase()
+
+ val issuer = if (endpointName != null)
+ endpointName
+ else {
+ createFileFromResourceTemplate(
+ k3sApple,
+ "selfsigned-certificate.template.yaml",
+ k3sResourcePath,
+ mapOf("host" to fqdn),
+ "644",
+ sudo = true
+ )
+ "selfsigned-issuer"
+ }
+
createFileFromResourceTemplate(
k3sApple,
"apple.template.yaml",
k3sResourcePath,
- mapOf("fqdn" to fqdn, "issuer_name" to endpoint.name.lowercase()),
+ mapOf("fqdn" to fqdn, "issuer_name" to issuer),
"644",
sudo = true
)
diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/ConfigRepository.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/ConfigRepository.kt
index c164a88..7b18566 100644
--- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/ConfigRepository.kt
+++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/ConfigRepository.kt
@@ -4,11 +4,16 @@ import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
import org.domaindrivenarchitecture.provs.framework.core.readFromFile
import org.domaindrivenarchitecture.provs.framework.core.yamlToType
import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig
+import org.domaindrivenarchitecture.provs.server.domain.k3s.Node
+import java.io.File
-
-private const val DEFAULT_CONFIG_FILE = "ServerConfig.yaml"
+private const val DEFAULT_CONFIG_FILE = "server-config.yaml"
fun getK3sConfig(fileName: ConfigFileName?): K3sConfig {
- return readFromFile(fileName?.fileName ?: DEFAULT_CONFIG_FILE).yamlToType()
+ val filename = fileName?.fileName ?: DEFAULT_CONFIG_FILE
+ return if (File(filename).exists()) {
+ readFromFile(filename).yamlToType()
+ } else {
+ K3sConfig("localhost", Node("127.0.0.1"), apple = true)
+ }
}
-
diff --git a/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/selfsigned-certificate.template.yaml b/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/selfsigned-certificate.template.yaml
new file mode 100644
index 0000000..139f76c
--- /dev/null
+++ b/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/selfsigned-certificate.template.yaml
@@ -0,0 +1,20 @@
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+ name: self-signed-certificate
+ namespace: default
+spec:
+ secretName: self-signed-certificate-secret
+ commonName: ${host}
+ dnsNames:
+ - ${host}
+ issuerRef:
+ name: selfsigned-issuer
+ kind: ClusterIssuer
+---
+apiVersion: cert-manager.io/v1
+kind: ClusterIssuer
+metadata:
+ name: selfsigned-issuer
+spec:
+ selfSigned: {}
\ No newline at end of file