Make version of CCM / CSI configurable
This commit is contained in:
parent
db3876bca4
commit
05332e7ae3
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,9 @@
|
|||||||
.terraform*
|
.terraform*
|
||||||
*.tfstate*
|
*.tfstate*
|
||||||
crash.log
|
crash.log
|
||||||
|
hetzner/ccm/kustomization.yaml
|
||||||
|
hetzner/csi/kustomization.yaml
|
||||||
kubeconfig.yaml
|
kubeconfig.yaml
|
||||||
|
kubeconfig.yaml-e
|
||||||
terraform.tfvars
|
terraform.tfvars
|
||||||
templates/rendered/traefik_config.yaml
|
templates/rendered/traefik_config.yaml
|
15
data.tf
Normal file
15
data.tf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
data "github_release" "hetzner_ccm" {
|
||||||
|
repository = "hcloud-cloud-controller-manager"
|
||||||
|
owner = "hetznercloud"
|
||||||
|
retrieve_by = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
data "github_release" "hetzner_csi" {
|
||||||
|
repository = "csi-driver"
|
||||||
|
owner = "hetznercloud"
|
||||||
|
retrieve_by = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
data "hcloud_image" "linux" {
|
||||||
|
name = local.hcloud_image_name
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
|
|
||||||
resources:
|
|
||||||
- https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/latest/download/ccm-networks.yaml
|
|
||||||
|
|
||||||
patchesStrategicMerge:
|
|
||||||
- patch.yaml
|
|
@ -1,8 +0,0 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
|
|
||||||
resources:
|
|
||||||
- https://raw.githubusercontent.com/hetznercloud/csi-driver/master/deploy/kubernetes/hcloud-csi.yml
|
|
||||||
|
|
||||||
patchesStrategicMerge:
|
|
||||||
- patch.yaml
|
|
20
main.tf
20
main.tf
@ -144,8 +144,22 @@ resource "hcloud_firewall" "k3s" {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data "hcloud_image" "linux" {
|
resource "local_file" "hetzner_ccm_config" {
|
||||||
name = local.hcloud_image_name
|
content = templatefile("${path.module}/templates/hetzner_ccm.yaml.tpl", {
|
||||||
|
ccm_version = var.hetzner_ccm_version != null ? var.hetzner_ccm_version : data.github_release.hetzner_ccm.release_tag
|
||||||
|
})
|
||||||
|
filename = "${path.module}/hetzner/ccm/kustomization.yaml"
|
||||||
|
file_permission = "0644"
|
||||||
|
directory_permission = "0755"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "local_file" "hetzner_csi_config" {
|
||||||
|
content = templatefile("${path.module}/templates/hetzner_csi.yaml.tpl", {
|
||||||
|
csi_version = var.hetzner_csi_version != null ? var.hetzner_csi_version : data.github_release.hetzner_csi.release_tag
|
||||||
|
})
|
||||||
|
filename = "${path.module}/hetzner/csi/kustomization.yaml"
|
||||||
|
file_permission = "0644"
|
||||||
|
directory_permission = "0755"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "local_file" "traefik_config" {
|
resource "local_file" "traefik_config" {
|
||||||
@ -154,4 +168,6 @@ resource "local_file" "traefik_config" {
|
|||||||
location = var.location
|
location = var.location
|
||||||
})
|
})
|
||||||
filename = "${path.module}/templates/rendered/traefik_config.yaml"
|
filename = "${path.module}/templates/rendered/traefik_config.yaml"
|
||||||
|
file_permission = "0644"
|
||||||
|
directory_permission = "0755"
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ resource "hcloud_server" "first_control_plane" {
|
|||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
command = <<-EOT
|
command = <<-EOT
|
||||||
kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${hcloud_network.k3s.name} --kubeconfig ${path.module}/kubeconfig.yaml
|
kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${hcloud_network.k3s.name} --kubeconfig ${path.module}/kubeconfig.yaml
|
||||||
kubectl apply -k ${path.module}/hetzner/ccm --kubeconfig ${path.module}/kubeconfig.yaml
|
kubectl apply -k ${dirname(local_file.hetzner_ccm_config.filename)} --kubeconfig ${path.module}/kubeconfig.yaml
|
||||||
kubectl -n kube-system create secret generic hcloud-csi --from-literal=token=${var.hcloud_token} --kubeconfig ${path.module}/kubeconfig.yaml
|
kubectl -n kube-system create secret generic hcloud-csi --from-literal=token=${var.hcloud_token} --kubeconfig ${path.module}/kubeconfig.yaml
|
||||||
kubectl apply -k ${path.module}/hetzner/csi --kubeconfig ${path.module}/kubeconfig.yaml
|
kubectl apply -k ${dirname(local_file.hetzner_csi_config.filename)} --kubeconfig ${path.module}/kubeconfig.yaml
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
provider "github" {}
|
||||||
|
|
||||||
provider "hcloud" {
|
provider "hcloud" {
|
||||||
token = var.hcloud_token
|
token = var.hcloud_token
|
||||||
}
|
}
|
||||||
|
8
templates/hetzner_ccm.yaml.tpl
Normal file
8
templates/hetzner_ccm.yaml.tpl
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- "https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/download/${ccm_version}/ccm-networks.yaml"
|
||||||
|
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
8
templates/hetzner_csi.yaml.tpl
Normal file
8
templates/hetzner_csi.yaml.tpl
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- "https://raw.githubusercontent.com/hetznercloud/csi-driver/${csi_version}/deploy/kubernetes/hcloud-csi.yml"
|
||||||
|
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch.yaml
|
12
variables.tf
12
variables.tf
@ -42,3 +42,15 @@ variable "agents_num" {
|
|||||||
description = "Number of agent nodes."
|
description = "Number of agent nodes."
|
||||||
type = number
|
type = number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "hetzner_ccm_version" {
|
||||||
|
type = string
|
||||||
|
default = null
|
||||||
|
description = "Version of Kubernetes Cloud Controller Manager for Hetzner Cloud"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "hetzner_csi_version" {
|
||||||
|
type = string
|
||||||
|
default = null
|
||||||
|
description = "Version of Container Storage Interface driver for Hetzner Cloud"
|
||||||
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
|
github = {
|
||||||
|
source = "integrations/github"
|
||||||
|
version = ">= 4.0.0, < 5.0.0"
|
||||||
|
}
|
||||||
hcloud = {
|
hcloud = {
|
||||||
source = "hetznercloud/hcloud"
|
source = "hetznercloud/hcloud"
|
||||||
version = ">= 1.0.0, < 2.0.0"
|
version = ">= 1.0.0, < 2.0.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user