MCPcopy Index your code
hub / github.com/eksctl-io/eksctl / GetClusterDNS

Function GetClusterDNS

pkg/nodebootstrap/userdata.go:88–121  ·  view source on GitHub ↗

GetClusterDNS returns the DNS address to use

(clusterConfig *api.ClusterConfig)

Source from the content-addressed store, hash-verified

86
87// GetClusterDNS returns the DNS address to use
88func GetClusterDNS(clusterConfig *api.ClusterConfig) (string, error) {
89 networkConfig := clusterConfig.Status.KubernetesNetworkConfig
90 if networkConfig == nil {
91 return "", nil
92 }
93
94 var (
95 serviceCIDR string
96 toClusterDNS func(net.IP) string
97 )
98
99 if networkConfig.ServiceIPv4CIDR != "" {
100 serviceCIDR = networkConfig.ServiceIPv4CIDR
101 toClusterDNS = func(parsedIP net.IP) string {
102 ip := parsedIP.To4()
103 ip[net.IPv4len-1] = 10
104 return ip.String()
105 }
106 }
107 if networkConfig.ServiceIPv6CIDR != "" {
108 serviceCIDR = networkConfig.ServiceIPv6CIDR
109 toClusterDNS = func(parsedIP net.IP) string {
110 ip := parsedIP.To16()
111 ip[net.IPv6len-1] = 10
112 return ip.String()
113 }
114 }
115
116 parsedIP, _, err := net.ParseCIDR(serviceCIDR)
117 if err != nil {
118 return "", fmt.Errorf("unexpected error parsing KubernetesNetworkConfig service CIDR: %q: %w", serviceCIDR, err)
119 }
120 return toClusterDNS(parsedIP), nil
121}
122
123func linuxConfig(clusterConfig *api.ClusterConfig, bootScriptName, bootScriptContent, clusterDNS string, np api.NodePool, scripts ...script) (string, error) {
124 config := cloudconfig.New()

Callers 4

al2023_test.goFile · 0.92
NewBootstrapperFunction · 0.85
NewManagedBootstrapperFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected