Skip to content

Commit

Permalink
feat(kubernetes): add kured to automatically reboot nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Jul 6, 2024
1 parent 7a57e97 commit 25773d0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ No modules.
| [helm_release.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.hcloud_ccm](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.hcloud_csi](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.kured](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_annotations.hcloud_ccm](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/annotations) | resource |
| [kubernetes_namespace.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
| [kubernetes_secret_v1.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret_v1) | resource |
Expand All @@ -44,6 +45,7 @@ No modules.
| <a name="input_k3s_cluster_cidr"></a> [k3s\_cluster\_cidr](#input\_k3s\_cluster\_cidr) | CIDR used for the k3s cluster | `string` | `"10.244.0.0/16"` | no |
| <a name="input_kube_context"></a> [kube\_context](#input\_kube\_context) | Kubernetes context to use | `string` | `"default"` | no |
| <a name="input_kubeconfig"></a> [kubeconfig](#input\_kubeconfig) | Kubeconfig for the cluster | `string` | n/a | yes |
| <a name="input_kured_version"></a> [kured\_version](#input\_kured\_version) | Version of Kured to use - defaults to latest | `string` | `null` | no |
| <a name="input_worker_pools"></a> [worker\_pools](#input\_worker\_pools) | Cluster autoscaler configuration | <pre>list(object({<br> cloud_init = string<br> firewall_id = string<br> image = string<br> labels = list(object({<br> key = string<br> value = string<br> }))<br> network_id = string<br> pool = object({<br> instanceType = string<br> minSize = number<br> maxSize = number<br> name = string<br> region = string<br> })<br> ssh_key_id = string<br> taints = list(object({<br> key = string<br> value = string<br> effect = string<br> }))<br> }))</pre> | `[]` | no |

## Outputs
Expand Down
47 changes: 47 additions & 0 deletions modules/kubernetes/kured.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2024 Simon Emms <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resource "helm_release" "kured" {
chart = "kured"
name = "kured"
atomic = true
cleanup_on_fail = true
create_namespace = true
namespace = "kured"
repository = "https://kubereboot.github.io/charts"
reset_values = true
version = var.kured_version
wait = true

dynamic "set" {
for_each = flatten([
for i, taint in local.control_plane_taints :
[
for k, v in taint :
[
{
name = "tolerations[${i}].${k}"
value = v
},
]
]
])
iterator = each

content {
name = each.value.name
value = each.value.value
}
}
}
6 changes: 6 additions & 0 deletions modules/kubernetes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ variable "kube_context" {
default = "default"
}

variable "kured_version" {
type = string
description = "Version of Kured to use - defaults to latest"
default = null
}

variable "worker_pools" {
type = list(object({
cloud_init = string
Expand Down

0 comments on commit 25773d0

Please sign in to comment.