Skip to content

Commit 884175b

Browse files
committed
1.12.0 allow remapping of ports for all service types
1 parent 670fa2b commit 884175b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

14_service.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ variable "service" {
4646
publishNotReadyAddresses = bool
4747
sessionAffinity = string
4848
annotations = map(string)
49+
remapPorts = map(string)
4950
})
5051
headless = object({
5152
publishNotReadyAddresses = bool
5253
sessionAffinity = string
5354
annotations = map(string)
55+
remapPorts = map(string)
5456
})
5557
loadBalancer = list(object({
5658
publishNotReadyAddresses = bool
@@ -84,7 +86,7 @@ resource "kubernetes_service_v1" "clusterIp" {
8486
content {
8587
name = port.value.name
8688
target_port = port.value.name
87-
port = port.value.port
89+
port = lookup(var.service.clusterIp.remapPorts, port.value.name, port.value.port)
8890
protocol = port.value.protocol
8991
}
9092
}
@@ -115,7 +117,7 @@ resource "kubernetes_service_v1" "headless" {
115117
content {
116118
name = port.value.name
117119
target_port = port.value.name
118-
port = port.value.port
120+
port = lookup(var.service.headless.remapPorts, port.value.name, port.value.port)
119121
protocol = port.value.protocol
120122
}
121123
}

24_release.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
output "version" {
2-
value = "1.11.0"
2+
value = "1.12.0"
33
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.12.0] - 2023-06-12
2+
3+
- add `remapPorts` to `var.service.clusterIp` and `var.service.headless` to allow remapping of ports for all service types
4+
15
## [1.11.0] - 2023-06-11
26

37
- port now supports `hostIp` if `hostNetwork == true`

example/module/submodules/replaceMe/11_service.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ locals {
77
annotations = merge({
88

99
}, var.additionalAnnotations.service)
10+
remapPorts = {}
1011
}
1112
headless = {
1213
publishNotReadyAddresses = false
1314
sessionAffinity = "None"
1415
annotations = merge({
1516

1617
}, var.additionalAnnotations.service)
18+
remapPorts = {}
1719
}
1820
loadBalancer = [
1921
#{

0 commit comments

Comments
 (0)