mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/kubernetes: correctly set NODATA for ns (#1229)
* plugin/kubernetes: Add GetNamespaceByName A bare or wildcard query for just the namespace should return NODATA, not NXDOMAIN, otherwise we deny the entirety of the names under the namespace. Add test to check for this in pod verified mode. * Review More comments and move namespace code to namespace.go
This commit is contained in:
@@ -36,6 +36,7 @@ type dnsController interface {
|
||||
EndpointsList() []*api.Endpoints
|
||||
|
||||
GetNodeByName(string) (*api.Node, error)
|
||||
GetNamespaceByName(string) (*api.Namespace, error)
|
||||
|
||||
Run()
|
||||
HasSynced() bool
|
||||
@@ -388,6 +389,9 @@ func (dns *dnsControl) EndpointsList() (eps []*api.Endpoints) {
|
||||
return eps
|
||||
}
|
||||
|
||||
// GetNodeByName return the node by name. If nothing is found an error is
|
||||
// returned. This query causes a roundtrip to the k8s API server, so use
|
||||
// sparingly. Currently this is only used for Federation.
|
||||
func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) {
|
||||
v1node, err := dns.client.Nodes().Get(name, meta.GetOptions{})
|
||||
if err != nil {
|
||||
@@ -395,3 +399,14 @@ func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) {
|
||||
}
|
||||
return v1node, nil
|
||||
}
|
||||
|
||||
// GetNamespaceByName returns the namespace by name. If nothing is found an
|
||||
// error is returned. This query causes a roundtrip to the k8s API server, so
|
||||
// use sparingly.
|
||||
func (dns *dnsControl) GetNamespaceByName(name string) (*api.Namespace, error) {
|
||||
v1ns, err := dns.client.Namespaces().Get(name, meta.GetOptions{})
|
||||
if err != nil {
|
||||
return &api.Namespace{}, err
|
||||
}
|
||||
return v1ns, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user