@@ -14,16 +14,16 @@ import (
14
14
)
15
15
16
16
const (
17
- coreDNSDomain = "cluster.local"
18
- coreDNSIP = "10.96.0.10"
17
+ dnsDomain = "cluster.local"
18
+ dnsIP = "10.96.0.10"
19
19
)
20
20
21
- // getCoreDNSService fetches the CoreDNS Service
22
- func getCoreDNSService (ctx context.Context , c client.Client ) (* corev1.Service , error ) {
21
+ // getKubernetesService fetches the Kubernetes Service
22
+ func getKubernetesService (ctx context.Context , c client.Client ) (* corev1.Service , error ) {
23
23
kubernetesService := & corev1.Service {}
24
24
id := client.ObjectKey {Namespace : metav1 .NamespaceDefault , Name : "kubernetes" }
25
25
26
- // Get the CoreDNS Service
26
+ // Get the Kubernetes Service
27
27
err := c .Get (ctx , id , kubernetesService )
28
28
29
29
return kubernetesService , err
@@ -33,14 +33,14 @@ func getCoreDNSService(ctx context.Context, c client.Client) (*corev1.Service, e
33
33
// It is usually the 10th address to the Kubernetes Service Cluster IP
34
34
// If the Kubernetes Service Cluster IP is not found, we default it to be "10.96.0.10"
35
35
func FindDNSClusterIP (ctx context.Context , c client.Client ) (string , error ) {
36
- kubernetesService , err := getCoreDNSService (ctx , c )
36
+ kubernetesService , err := getKubernetesService (ctx , c )
37
37
if err != nil && ! apierrors .IsNotFound (err ) {
38
38
return "" , err
39
39
}
40
40
41
41
if apierrors .IsNotFound (err ) {
42
42
// If it cannot determine the Cluster IP, we default it to "10.96.0.10"
43
- return coreDNSIP , nil
43
+ return dnsIP , nil
44
44
}
45
45
46
46
ip := net .ParseIP (kubernetesService .Spec .ClusterIP )
@@ -49,7 +49,7 @@ func FindDNSClusterIP(ctx context.Context, c client.Client) (string, error) {
49
49
}
50
50
51
51
// The kubernetes Service ClusterIP is the 1st IP in the Service Subnet.
52
- // Increment the right-most byte by 9 to get to the 10th address, canonically used for CoreDNS .
52
+ // Increment the right-most byte by 9 to get to the 10th address, canonically used for DNS .
53
53
// This works for both IPV4, IPV6, and 16-byte IPV4 addresses.
54
54
ip [len (ip )- 1 ] += 9
55
55
@@ -67,14 +67,14 @@ func GetDNSDomain() string {
67
67
cname , err := net .LookupCNAME (svc )
68
68
if err != nil {
69
69
// If it cannot determine the domain, we default it to "cluster.local"
70
- klog .Infof ("determined DNS Domain for cluster should be %q" , coreDNSDomain )
71
- return coreDNSDomain
70
+ klog .Infof ("determined DNS Domain for cluster should be %q" , dnsDomain )
71
+ return dnsDomain
72
72
}
73
73
74
74
domain := strings .TrimPrefix (cname , svc )
75
- domain = strings .TrimSuffix (coreDNSDomain , "." )
75
+ domain = strings .TrimSuffix (dnsDomain , "." )
76
76
77
- klog .Infof ("determined DNS Domain for CoreDNS should be %q" , domain )
77
+ klog .Infof ("determined DNS Domain for DNS should be %q" , domain )
78
78
79
79
return domain
80
80
}
0 commit comments