pinning k3s version

This commit is contained in:
ansgarz 2022-05-20 10:11:16 +02:00
parent 47ba42bd0b
commit 91e334c3fa

View file

@ -11,8 +11,11 @@ import org.domaindrivenarchitecture.provs.server.domain.k3s.FileMode
import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig
import java.io.File import java.io.File
// ----------------------------------- directories -------------------------------- // ----------------------------------- versions --------------------------------
const val K3S_VERSION = "v1.23.6+k3s1"
// ----------------------------------- directories --------------------------------
const val k3sManualManifestsDir = "/etc/rancher/k3s/manifests/" const val k3sManualManifestsDir = "/etc/rancher/k3s/manifests/"
private const val k3sAutomatedManifestsDir = "/var/lib/rancher/k3s/server/manifests/" private const val k3sAutomatedManifestsDir = "/var/lib/rancher/k3s/server/manifests/"
@ -52,7 +55,8 @@ fun Prov.deprovisionK3sInfra() = task {
} }
fun Prov.installK3s(k3sConfig: K3sConfig) = taskWithResult { fun Prov.installK3s(k3sConfig: K3sConfig): ProvResult {
return taskWithResult {
if (testConfigExists()) { if (testConfigExists()) {
return@taskWithResult ProvResult(true, out = "K3s config is already in place, so skip (re)provisioning.") return@taskWithResult ProvResult(true, out = "K3s config is already in place, so skip (re)provisioning.")
} }
@ -82,7 +86,7 @@ fun Prov.installK3s(k3sConfig: K3sConfig) = taskWithResult {
createK3sFileFromResourceTemplate(k3sConfigFile, k3sConfigMap, alternativeResourceTemplate = File(k3sConfigResourceFileName)) createK3sFileFromResourceTemplate(k3sConfigFile, k3sConfigMap, alternativeResourceTemplate = File(k3sConfigResourceFileName))
createK3sFileFromResource(k3sInstallScript, posixFilePermission = "755") createK3sFileFromResource(k3sInstallScript, posixFilePermission = "755")
cmd("INSTALL_K3S_VERSION=v1.23.6+k3s1 k3s-install.sh") cmd("INSTALL_K3S_VERSION=$K3S_VERSION k3s-install.sh")
// metallb // metallb
applyK3sFileFromResource(File(k3sManualManifestsDir, "metallb-namespace.yaml")) applyK3sFileFromResource(File(k3sManualManifestsDir, "metallb-namespace.yaml"))
@ -107,6 +111,7 @@ fun Prov.installK3s(k3sConfig: K3sConfig) = taskWithResult {
cmd("ln -sf $k3sKubeConfig " + k8sCredentialsDir + "admin.conf", sudo = true) cmd("ln -sf $k3sKubeConfig " + k8sCredentialsDir + "admin.conf", sudo = true)
} }
}
fun Prov.provisionK3sCertManager(certmanager: Certmanager) = task { fun Prov.provisionK3sCertManager(certmanager: Certmanager) = task {