Skip to content

Commit

Permalink
Allow configuring NodeAffinity for ingress-nginx controller. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivours committed Feb 16, 2024
1 parent 675a20f commit 110b6dd
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.1.0] - 2024-02-15

- Allow configuring NodeAffinity for ingress-nginx controller.

## [5.0.0] - 2024-01-21

- Add dynamic root volume name depending on the AMI that is being used for the worker nodes.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ module "eks_main" {
helm_cluster_autoscaler_enabled = true
helm_metrics_server_enabled = true
helm_cert_manager_enabled = true
ingress_node_affinity = {
enabled = true,
label_key = "nodegroup",
label_value = "${var.env}-eks-spot"
}
create_ebs_csi_role = true
Expand Down Expand Up @@ -230,6 +235,7 @@ module "eks_main" {
| ingress\_http\_nodeport | Set port for ingress http nodePort | `int` | `32080` | no |
| ingress\_https\_nodeport | Set port for ingress https nodePort | `int` | `32443` | no |
| ingress\_https\_traffic\_enabled | Set https traffic for ingress | `bool` | `false` | no |
| ingress\_node\_affinity | Set nodeAffinity for ingress | `map` | `{ enabled = false, label_key = null, label_value = null}` | no |
| ingress\_requests\_cpu | Set how much cpu will be assigned to the request | `string` | `100m` | no |
| ingress\_requests\_memory | Set how much memory will be assigned to the request | `string` | `90Mi` | no |
| ingress\_service\_monitor\_enabled | Enable serviceMonitor for ingress-nginx helm chart | `bool` | `false` | no |
Expand Down
23 changes: 0 additions & 23 deletions helm-values/ingress-nginx.yaml

This file was deleted.

34 changes: 34 additions & 0 deletions helm-values/ingress-nginx.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
controller:
service:
type: NodePort
nodePorts:
http: 32080
https: 32443
tcp:
8080: 32808

admissionWebhooks:
enabled: false

metrics:
port: 10254
service:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10254"
serviceMonitor:
additionalLabels:
release: prometheus-stack

%{if enableNodeAffinity }
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: ${nodeAffinityLabelKey}
operator: In
values:
- ${nodeAffinityLabelValue}
%{endif}
7 changes: 6 additions & 1 deletion helm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ resource "helm_release" "ingress_nginx" {
version = var.ingress_chart_version

values = [
file("${path.module}/helm-values/ingress-nginx.yaml")
templatefile("${path.module}/helm-values/ingress-nginx.yaml.tpl",
{
enableNodeAffinity = var.ingress_node_affinity["enabled"],
nodeAffinityLabelKey = var.ingress_node_affinity["label_key"],
nodeAffinityLabelValue = var.ingress_node_affinity["label_value"]
})
]

set {
Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,19 @@ variable "ingress_requests_cpu" {
variable "ingress_requests_memory" {
default = "90Mi"
}

variable "ingress_priority_class_name"{
default = ""
}

variable "ingress_node_affinity" {
default = {
enabled = "false",
label_key = null,
label_value = null
}
}

# ================== ingress-nginx-additional =================

variable "helm_ingress_nginx_additional_enabled" {
Expand Down

0 comments on commit 110b6dd

Please sign in to comment.