mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #92964 from vponomaryov/issue-88752-in-master
agnhost image: use actual DNS domain instead of hardcoded cluster.local
This commit is contained in:
commit
b58777eda0
@ -1,7 +1,7 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
# agnhost: bump this one first
|
# agnhost: bump this one first
|
||||||
- name: "agnhost"
|
- name: "agnhost"
|
||||||
version: "2.23"
|
version: "2.24"
|
||||||
refPaths:
|
refPaths:
|
||||||
- path: test/images/agnhost/VERSION
|
- path: test/images/agnhost/VERSION
|
||||||
match: \d.\d
|
match: \d.\d
|
||||||
|
@ -1 +1 @@
|
|||||||
2.23
|
2.24
|
||||||
|
@ -51,7 +51,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
rootCmd := &cobra.Command{
|
rootCmd := &cobra.Command{
|
||||||
Use: "app",
|
Use: "app",
|
||||||
Version: "2.23",
|
Version: "2.24",
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.AddCommand(auditproxy.CmdAuditProxy)
|
rootCmd.AddCommand(auditproxy.CmdAuditProxy)
|
||||||
|
@ -52,7 +52,7 @@ var CmdEtcHosts = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printDNSSuffixList(cmd *cobra.Command, args []string) {
|
func printDNSSuffixList(cmd *cobra.Command, args []string) {
|
||||||
dnsSuffixList := getDNSSuffixList()
|
dnsSuffixList := GetDNSSuffixList()
|
||||||
fmt.Println(strings.Join(dnsSuffixList, ","))
|
fmt.Println(strings.Join(dnsSuffixList, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ const etcHostsFile = "/etc/hosts"
|
|||||||
// nameserver DNS_CLUSTER_IP
|
// nameserver DNS_CLUSTER_IP
|
||||||
// search test-dns.svc.cluster.local svc.cluster.local cluster.local q53aahaikqaehcai3ylfqdtc5b.bx.internal.cloudapp.net
|
// search test-dns.svc.cluster.local svc.cluster.local cluster.local q53aahaikqaehcai3ylfqdtc5b.bx.internal.cloudapp.net
|
||||||
// options ndots:5
|
// options ndots:5
|
||||||
func getDNSSuffixList() []string {
|
|
||||||
|
// GetDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
||||||
|
func GetDNSSuffixList() []string {
|
||||||
fileData := readFile("/etc/resolv.conf")
|
fileData := readFile("/etc/resolv.conf")
|
||||||
lines := strings.Split(fileData, "\n")
|
lines := strings.Split(fileData, "\n")
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
@ -80,8 +80,8 @@ func getRegistryValue(reg, key string) string {
|
|||||||
return regValue
|
return regValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
// GetDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
||||||
func getDNSSuffixList() []string {
|
func GetDNSSuffixList() []string {
|
||||||
// We start with the general suffix list that apply to all network connections.
|
// We start with the general suffix list that apply to all network connections.
|
||||||
allSuffixes := []string{}
|
allSuffixes := []string{}
|
||||||
suffixes := getRegistryValue(netRegistry, "SearchList")
|
suffixes := getRegistryValue(netRegistry, "SearchList")
|
||||||
|
@ -10,6 +10,7 @@ go_library(
|
|||||||
srcs = ["controller.go"],
|
srcs = ["controller.go"],
|
||||||
importpath = "k8s.io/kubernetes/test/images/agnhost/resource-consumer-controller",
|
importpath = "k8s.io/kubernetes/test/images/agnhost/resource-consumer-controller",
|
||||||
deps = [
|
deps = [
|
||||||
|
"//test/images/agnhost/dns:go_default_library",
|
||||||
"//test/images/resource-consumer/common:go_default_library",
|
"//test/images/resource-consumer/common:go_default_library",
|
||||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -21,11 +21,13 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/test/images/agnhost/dns"
|
||||||
"k8s.io/kubernetes/test/images/resource-consumer/common"
|
"k8s.io/kubernetes/test/images/resource-consumer/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,8 +45,31 @@ var (
|
|||||||
consumerPort int
|
consumerPort int
|
||||||
consumerServiceName string
|
consumerServiceName string
|
||||||
consumerServiceNamespace string
|
consumerServiceNamespace string
|
||||||
|
dnsDomain string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getDNSDomain walks through DNS configuration and looks for "svc.foo" record
|
||||||
|
// where "foo" is currently configured DNS suffix. Then picks that 'foo' part up
|
||||||
|
// and returns to a caller.
|
||||||
|
func getDNSDomain() string {
|
||||||
|
if dnsDomain != "" {
|
||||||
|
return dnsDomain
|
||||||
|
}
|
||||||
|
dnsSuffixList := dns.GetDNSSuffixList()
|
||||||
|
r, _ := regexp.Compile("^svc.")
|
||||||
|
for _, currentDNSSuffix := range dnsSuffixList {
|
||||||
|
if r.MatchString(currentDNSSuffix) {
|
||||||
|
// Save DNS suffix without the 'svc.' part
|
||||||
|
dnsDomain = currentDNSSuffix[4:]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dnsDomain == "" {
|
||||||
|
panic("Could not find DNS suffix starting with 'svc.' substring")
|
||||||
|
}
|
||||||
|
return dnsDomain
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
CmdResourceConsumerController.Flags().IntVar(&port, "port", 8080, "Port number.")
|
CmdResourceConsumerController.Flags().IntVar(&port, "port", 8080, "Port number.")
|
||||||
CmdResourceConsumerController.Flags().IntVar(&consumerPort, "consumer-port", 8080, "Port number of consumers.")
|
CmdResourceConsumerController.Flags().IntVar(&consumerPort, "consumer-port", 8080, "Port number of consumers.")
|
||||||
@ -214,7 +239,8 @@ func (c *controller) sendConsumeCustomMetric(w http.ResponseWriter, metric strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createConsumerURL(suffix string) string {
|
func createConsumerURL(suffix string) string {
|
||||||
return fmt.Sprintf("http://%s.%s.svc.cluster.local:%d%s", consumerServiceName, consumerServiceNamespace, consumerPort, suffix)
|
// NOTE: full DNS name is used due to the Windows platform restriction where PQDNs are not supported.
|
||||||
|
return fmt.Sprintf("http://%s.%s.svc.%s:%d%s", consumerServiceName, consumerServiceNamespace, getDNSDomain(), consumerPort, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendOneConsumeCPURequest sends POST request for cpu consumption
|
// sendOneConsumeCPURequest sends POST request for cpu consumption
|
||||||
|
Loading…
Reference in New Issue
Block a user