Merge branch 'master' of gitlab.com:domaindrivenarchitecture/provs
This commit is contained in:
commit
85b999245b
3 changed files with 15 additions and 13 deletions
|
@ -18,7 +18,7 @@ apply plugin: "kotlinx-serialization"
|
||||||
|
|
||||||
|
|
||||||
group = "org.domaindrivenarchitecture.provs"
|
group = "org.domaindrivenarchitecture.provs"
|
||||||
version = "0.16.1-SNAPSHOT"
|
version = "0.17.1-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -15,10 +15,8 @@ fun Prov.provisionK3sCommand(cli: K3sCliCommand) = task {
|
||||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||||
DefaultApplicationFileRepository().assertExists(cli.applicationFileName)
|
DefaultApplicationFileRepository().assertExists(cli.applicationFileName)
|
||||||
|
|
||||||
if (cli.reprovision || k3sConfig.reprovision) {
|
val k3sConfigReprovision = k3sConfig.copy(reprovision = cli.reprovision || k3sConfig.reprovision)
|
||||||
deprovisionK3sInfra()
|
provisionK3s(k3sConfigReprovision, grafanaConfigResolved, cli.applicationFileName)
|
||||||
}
|
|
||||||
provisionK3s(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
|
||||||
} else {
|
} else {
|
||||||
provisionGrafana(cli.onlyModules, grafanaConfigResolved)
|
provisionGrafana(cli.onlyModules, grafanaConfigResolved)
|
||||||
}
|
}
|
||||||
|
@ -32,6 +30,10 @@ fun Prov.provisionK3s(
|
||||||
grafanaConfigResolved: GrafanaAgentConfigResolved? = null,
|
grafanaConfigResolved: GrafanaAgentConfigResolved? = null,
|
||||||
applicationFileName: ApplicationFileName? = null) = task {
|
applicationFileName: ApplicationFileName? = null) = task {
|
||||||
|
|
||||||
|
if (k3sConfig.reprovision) {
|
||||||
|
deprovisionK3sInfra()
|
||||||
|
}
|
||||||
|
|
||||||
provisionNetwork(k3sConfig)
|
provisionNetwork(k3sConfig)
|
||||||
|
|
||||||
installK3s(k3sConfig)
|
installK3s(k3sConfig)
|
||||||
|
|
|
@ -111,7 +111,7 @@ fun Prov.installK3s(k3sConfig: K3sConfig): ProvResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
applyK3sFileFromResource(localPathProvisionerConfig)
|
applyK3sFileFromResource(localPathProvisionerConfig)
|
||||||
cmd("kubectl set env deployment -n kube-system local-path-provisioner DEPLOY_DATE=\"$(date)\"")
|
cmd("kubectl set env deployment -n kube-system local-path-provisioner DEPLOY_DATE=\"$(date)\"", sudo = true)
|
||||||
|
|
||||||
cmd("ln -sf $k3sKubeConfig " + k8sCredentialsDir + "admin.conf", sudo = true)
|
cmd("ln -sf $k3sKubeConfig " + k8sCredentialsDir + "admin.conf", sudo = true)
|
||||||
|
|
||||||
|
@ -160,13 +160,13 @@ fun Prov.provisionK3sApplication(applicationFileName: ApplicationFileName) = tas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ============================ private and internal functions =============================
|
// ============================ functions to create k3s files and apply =============================
|
||||||
|
|
||||||
internal fun Prov.applyK3sFile(file: File) = task {
|
fun Prov.applyK3sFile(file: File) = task {
|
||||||
cmd("kubectl apply -f ${file.path}", sudo = true)
|
cmd("kubectl apply -f ${file.path}", sudo = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.createK3sFileFromResource(
|
fun Prov.createK3sFileFromResource(
|
||||||
file: File,
|
file: File,
|
||||||
posixFilePermission: FileMode? = "644"
|
posixFilePermission: FileMode? = "644"
|
||||||
) = task {
|
) = task {
|
||||||
|
@ -179,12 +179,12 @@ private fun Prov.createK3sFileFromResource(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.applyK3sFileFromResource(file: File, posixFilePermission: String? = "644") = task {
|
fun Prov.applyK3sFileFromResource(file: File, posixFilePermission: String? = "644") = task {
|
||||||
createK3sFileFromResource(file, posixFilePermission)
|
createK3sFileFromResource(file, posixFilePermission)
|
||||||
applyK3sFile(file)
|
applyK3sFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.applyK3sFileFromResourceTemplate(
|
fun Prov.applyK3sFileFromResourceTemplate(
|
||||||
file: File,
|
file: File,
|
||||||
values: Map<String, String>,
|
values: Map<String, String>,
|
||||||
posixFilePermission: String? = "644",
|
posixFilePermission: String? = "644",
|
||||||
|
@ -194,7 +194,7 @@ private fun Prov.applyK3sFileFromResourceTemplate(
|
||||||
applyK3sFile(file)
|
applyK3sFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.createK3sFileFromResourceTemplate(
|
fun Prov.createK3sFileFromResourceTemplate(
|
||||||
file: File,
|
file: File,
|
||||||
values: Map<String, String>,
|
values: Map<String, String>,
|
||||||
posixFilePermission: String? = "644",
|
posixFilePermission: String? = "644",
|
||||||
|
@ -215,5 +215,5 @@ private fun File.templateName(): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Prov.configureShellAliases() = task {
|
internal fun Prov.configureShellAliases() = task {
|
||||||
addTextToFile( "\nalias k=kubectl\n", File(".bash_aliases",))
|
addTextToFile( "\nalias k=\"sudo kubectl\"\n", File(".bash_aliases",))
|
||||||
}
|
}
|
Loading…
Reference in a new issue