mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #750 from erikwilson/unresolvable-hostname
Remove hostname requirement in `/etc/hosts`
This commit is contained in:
commit
bcd1fce4a1
@ -396,19 +396,3 @@ func getConfig(info *clientaccess.Info) (*config.Control, error) {
|
||||
controlControl := &config.Control{}
|
||||
return controlControl, json.Unmarshal(data, controlControl)
|
||||
}
|
||||
|
||||
func HostnameCheck(cfg cmds.Agent) error {
|
||||
hostname, _, err := getHostnameAndIP(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
_, err = sysnet.LookupHost(hostname)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
logrus.Infof("Waiting for hostname %s to be resolvable: %v", hostname, err)
|
||||
time.Sleep(time.Second * 3)
|
||||
}
|
||||
return fmt.Errorf("Timed out waiting for hostname %s to be resolvable: %v", hostname, err)
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ import (
|
||||
func run(ctx context.Context, cfg cmds.Agent, lb *loadbalancer.LoadBalancer) error {
|
||||
nodeConfig := config.Get(ctx, cfg)
|
||||
|
||||
if err := config.HostnameCheck(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !nodeConfig.NoFlannel {
|
||||
if err := flannel.Prepare(ctx, nodeConfig); err != nil {
|
||||
return err
|
||||
|
@ -17,7 +17,7 @@ const ContainerdConfigTemplate = `
|
||||
path = "{{ .NodeConfig.Containerd.Opt }}"
|
||||
|
||||
[plugins.cri]
|
||||
stream_server_address = "{{ .NodeConfig.AgentConfig.NodeName }}"
|
||||
stream_server_address = "127.0.0.1"
|
||||
stream_server_port = "10010"
|
||||
|
||||
{{- if .IsRunningInUserNS }}
|
||||
|
@ -165,7 +165,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||
}
|
||||
ip := serverConfig.TLSConfig.BindAddress
|
||||
if ip == "" {
|
||||
ip = "localhost"
|
||||
ip = "127.0.0.1"
|
||||
}
|
||||
url := fmt.Sprintf("https://%s:%d", ip, serverConfig.TLSConfig.HTTPSPort)
|
||||
token := server.FormatToken(serverConfig.ControlConfig.Runtime.NodeToken, certs)
|
||||
|
@ -474,7 +474,7 @@ func genClientCerts(config *config.Control, runtime *config.ControlRuntime) erro
|
||||
factory := getSigningCertFactory(regen, nil, []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, runtime.ClientCA, runtime.ClientCAKey)
|
||||
|
||||
var certGen bool
|
||||
apiEndpoint := fmt.Sprintf("https://localhost:%d", config.ListenPort)
|
||||
apiEndpoint := fmt.Sprintf("https://127.0.0.1:%d", config.ListenPort)
|
||||
|
||||
certGen, err = factory("system:admin", []string{"system:masters"}, runtime.ClientAdminCert, runtime.ClientAdminKey)
|
||||
if err != nil {
|
||||
|
@ -193,7 +193,7 @@ func printTokens(certs, advertiseIP string, tlsConfig *dynamiclistener.UserConfi
|
||||
)
|
||||
|
||||
if advertiseIP == "" {
|
||||
advertiseIP = "localhost"
|
||||
advertiseIP = "127.0.0.1"
|
||||
}
|
||||
|
||||
if len(config.Runtime.NodeToken) > 0 {
|
||||
@ -213,7 +213,7 @@ func writeKubeConfig(certs string, tlsConfig *dynamiclistener.UserConfig, config
|
||||
clientToken := FormatToken(config.ControlConfig.Runtime.ClientToken, certs)
|
||||
ip := tlsConfig.BindAddress
|
||||
if ip == "" {
|
||||
ip = "localhost"
|
||||
ip = "127.0.0.1"
|
||||
}
|
||||
url := fmt.Sprintf("https://%s:%d", ip, tlsConfig.HTTPSPort)
|
||||
kubeConfig, err := HomeKubeConfig(true, config.Rootless)
|
||||
|
Loading…
Reference in New Issue
Block a user