Skip to content

Commit

Permalink
node: fix SetKubeletNodeIP when kubeletEnvFile does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmouchet committed Jan 25, 2022
1 parent 98ca36a commit 6b33849
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ limitations under the License.
package network

import (
"errors"
"fmt"
"github.com/txn2/txeh"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
"io/ioutil"
"net"
"os"
"os/exec"
"strings"
)
Expand Down Expand Up @@ -82,6 +84,9 @@ func SetHostname(hostname string) {

// SetKubeletNodeIP sets the node IP in the kubelet configuration.
func SetKubeletNodeIP(kubeletEnvFile string, ip net.IP) {
if _, err := os.Stat(kubeletEnvFile); errors.Is(err, os.ErrNotExist) {
return
}
// TODO: Do not override existing content?
s := fmt.Sprintf("KUBELET_EXTRA_ARGS=\"--node-ip=%s\"\n", ip.String())
check(ioutil.WriteFile(kubeletEnvFile, []byte(s), 0644))
Expand Down

0 comments on commit 6b33849

Please sign in to comment.