Skip to content

Commit

Permalink
fix(init): make /etc/hosts writable (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Jul 25, 2018
1 parent ca93ede commit 4014872
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/initramfs/cmd/init/pkg/rootfs/etc/etc.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ func Hosts(s, hostname, ip string) (err error) {
return
}

if err := ioutil.WriteFile(path.Join(s, "/etc/hosts"), writer.Bytes(), 0644); err != nil {
if err := ioutil.WriteFile(path.Join(s, "/var/run/hosts"), writer.Bytes(), 0644); err != nil {
return fmt.Errorf("write /etc/hosts: %v", err)
}
// The kubelet wants to manage /etc/hosts. Create a symlink there that
// points to a writable file.
if err := os.Symlink("/var/run/hosts", path.Join(s, "/etc/hosts")); err != nil {
return fmt.Errorf("symlink /etc/hosts: %v", err)
}

return nil
}
Expand Down

0 comments on commit 4014872

Please sign in to comment.