-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Terraform Version, Provider Version and Kubernetes Version
Terraform version: v1.12.2
Kubernetes provider version: 2.33.0
Kubernetes version: v1.33.5
Affected Resource(s)
kubernetes_resources(data source)
Terraform Configuration Files
data "kubernetes_resources" "ingresses" {
api_version = "networking.k8s.io/v1"
kind = "Ingress"
# namespace not specified — expected to list across all namespaces
}Debug Output
N/A
Panic Output
N/A
Steps to Reproduce
- Create Ingress resources in multiple namespaces (e.g.
fooandbar) - Configure
kubernetes_resourcesdata source without specifyingnamespace - Run
terraform apply - Observe that only resources in the
defaultnamespace are returned
Expected Behavior
When namespace is not specified (or set to ""), the data source should return resources across all namespaces, consistent with how kubectl get ingress --all-namespaces works.
Actual Behavior
The data source only returns resources in the default namespace. This happens because manifest/provider/datasource.go explicitly overrides an empty namespace string with "default", preventing a cluster-wide list request:
if ns {
var namespace string
dsConfig["namespace"].As(&namespace)
if namespace == "" {
namespace = "default" // silently falls back to "default"
}
res, err = rcl.Namespace(namespace).List(ctx, listOptions)
} else {
res, err = rcl.List(ctx, listOptions)
}Note: cluster-scoped resources (where IsResourceNamespaced returns false) are already handled correctly via the else branch and are unaffected.
Important Factoids
This is related to the investigation in #2830, but specifically addresses the incorrect namespace filtering logic.
References
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels