Remove the requirement of Helm, and use the K3s HelmChart CRD installation method instead
This commit is contained in:
parent
547ca6d29b
commit
6fa7daa21d
@ -54,13 +54,12 @@ Follow those simple steps, and your world's cheapest Kube cluster will be up and
|
||||
|
||||
First and foremost, you need to have a Hetzner Cloud account. You can sign up for free [here](https://hetzner.com/cloud/).
|
||||
|
||||
Then you'll need to have [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli), [kubectl](https://kubernetes.io/docs/tasks/tools/) cli, [helm](<https://github.com/helm/helm>) Helm and [hcloud](<https://github.com/hetznercloud/cli>) the Hetzner cli. The easiest way is to use the [homebrew](https://brew.sh/) package manager to install them (available on Linux, Mac, and Windows Linux Subsystem).
|
||||
Then you'll need to have [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli), [kubectl](https://kubernetes.io/docs/tasks/tools/) cli and [hcloud](<https://github.com/hetznercloud/cli>) the Hetzner cli. The easiest way is to use the [homebrew](https://brew.sh/) package manager to install them (available on Linux, Mac, and Windows Linux Subsystem).
|
||||
|
||||
```sh
|
||||
brew install terraform
|
||||
brew install kubectl
|
||||
brew install hcloud
|
||||
brew install helm
|
||||
|
||||
```
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
---
|
||||
helmDefaults:
|
||||
timeout: 3600
|
||||
wait: true
|
||||
force: false
|
||||
atomic: true
|
||||
|
||||
repositories:
|
||||
- name: longhorn
|
||||
url: https://charts.longhorn.io
|
||||
|
||||
releases:
|
||||
- name: longhorn
|
||||
namespace: longhorn
|
||||
chart: longhorn/longhorn
|
||||
values:
|
||||
- persistence:
|
||||
defaultClass: {{ requiredEnv "HETZNER_CSI_DISABLED" }}
|
||||
defaultFsType: ext4
|
||||
defaultClassReplicaCount: 2
|
||||
- defaultSettings:
|
||||
defaultDataPath: /var/longhorn
|
32
init.tf
32
init.tf
@ -87,6 +87,7 @@ resource "null_resource" "kustomization" {
|
||||
"https://raw.githubusercontent.com/rancher/system-upgrade-controller/master/manifests/system-upgrade-controller.yaml",
|
||||
],
|
||||
var.disable_hetzner_csi ? [] : ["https://raw.githubusercontent.com/hetznercloud/csi-driver/${local.csi_version}/deploy/kubernetes/hcloud-csi.yml"],
|
||||
var.enable_longhorn ? ["longhorn.yaml"] : [],
|
||||
local.is_single_node_cluster ? [] : var.traefik_enabled ? ["traefik_config.yaml"] : [],
|
||||
var.cni_plugin == "calico" ? ["https://projectcalico.docs.tigera.io/manifests/calico.yaml"] : []
|
||||
),
|
||||
@ -128,6 +129,16 @@ resource "null_resource" "kustomization" {
|
||||
destination = "/var/post_install/plans.yaml"
|
||||
}
|
||||
|
||||
# Upload the Longhorn config
|
||||
provisioner "file" {
|
||||
content = templatefile(
|
||||
"${path.module}/templates/longhorn.yaml.tpl",
|
||||
{
|
||||
disable_hetzner_csi = var.disable_hetzner_csi
|
||||
})
|
||||
destination = "/var/post_install/longhorn.yaml"
|
||||
}
|
||||
|
||||
# Deploy secrets, logging is automatically disabled due to sensitive variables
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
@ -171,24 +182,3 @@ resource "null_resource" "kustomization" {
|
||||
local_sensitive_file.kubeconfig
|
||||
]
|
||||
}
|
||||
|
||||
resource "null_resource" "longhorn" {
|
||||
# If longhorn isn't enabled, we don't want any Helm resources
|
||||
count = var.enable_longhorn ? 1 : 0
|
||||
|
||||
# Install Helm charts
|
||||
provisioner "local-exec" {
|
||||
when = create
|
||||
command = <<-EOT
|
||||
export KUBECONFIG=$(readlink -f ${path.module}/kubeconfig.yaml)
|
||||
export HETZNER_CSI_DISABLED=${var.disable_hetzner_csi ? "true" : "false"}
|
||||
helmfile -f ${path.module}/helm/longhorn.yaml apply
|
||||
EOT
|
||||
on_failure = continue
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
null_resource.first_control_plane,
|
||||
local_sensitive_file.kubeconfig
|
||||
]
|
||||
}
|
||||
|
22
templates/longhorn.yaml.tpl
Normal file
22
templates/longhorn.yaml.tpl
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: longhorn
|
||||
---
|
||||
apiVersion: helm.cattle.io/v1
|
||||
kind: HelmChart
|
||||
metadata:
|
||||
name: longhorn
|
||||
namespace: kube-system
|
||||
spec:
|
||||
chart: longhorn
|
||||
repo: https://charts.longhorn.io
|
||||
targetNamespace: longhorn
|
||||
valuesContent: |-
|
||||
defaultSettings:
|
||||
defaultDataPath: /var/longhorn
|
||||
persistence:
|
||||
defaultFsType: ext4
|
||||
defaultClassReplicaCount: 2
|
||||
%{ if disable_hetzner_csi ~}defaultClass: true%{ else ~}defaultClass: false%{ endif ~}
|
@ -47,4 +47,4 @@ spec:
|
||||
serviceAccountName: system-upgrade
|
||||
cordon: true
|
||||
upgrade:
|
||||
image: rancher/k3s-upgrade
|
||||
image: rancher/k3s-upgrade
|
||||
|
Loading…
Reference in New Issue
Block a user