terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
Support endPort in kubernetes_network_policy
Description
Kubernetes NetPols support specifying a range of ports (stable as of 1.25) using endPort. It isn't possible to specify that using the current Kubernetes provider.
Potential Terraform Configuration
resource "kubernetes_network_policy" "example" {
metadata {
name = "terraform-example-network-policy"
namespace = "default"
}
spec {
pod_selector {
match_expressions {
key = "name"
operator = "In"
values = ["webfront", "api"]
}
}
ingress {
ports {
port = 1025
endPort = 65535
protocol = "TCP"
}
from {
namespace_selector {
match_labels = {
name = "default"
}
}
}
}
policy_types = ["Ingress"]
}
}
References
- User docs: https://kubernetes.io/docs/concepts/services-networking/network-policies/#targeting-a-range-of-ports
- golang API docs: https://pkg.go.dev/k8s.io/[email protected]/networking/v1#NetworkPolicyPort (specifically
EndPort)
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Thanks for opening this @joelthompson. We should add this here: https://github.com/hashicorp/terraform-provider-kubernetes/blob/fc43163245701e874bcb8ec82d1166f62582ca23/kubernetes/resource_kubernetes_network_policy_v1.go#L144-L155
I would like to work on this 🙂