Skip to content

Commit

Permalink
Add IPv6-only support for moonray (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 authored Sep 18, 2024
1 parent 1a993cc commit e8475bf
Show file tree
Hide file tree
Showing 22 changed files with 361 additions and 95 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration-informing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ jobs:
export TEST_SUBSTRATE=lxd
export TEST_LXD_IMAGE=${{ matrix.os }}
export TEST_INSPECTION_REPORTS_DIR="$HOME/inspection-reports"
# IPv6-only is only supported on moonray
if [[ "${{ matrix.patch }}" == "moonray" ]]; then
export TEST_IPV6_ONLY="true"
fi
cd tests/integration && sg lxd -c 'tox -e integration'
- name: Prepare inspection reports
if: failure()
Expand Down
9 changes: 8 additions & 1 deletion src/k8s/pkg/client/kubernetes/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"sort"

"github.com/canonical/k8s/pkg/utils"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/retry"
Expand Down Expand Up @@ -40,7 +41,13 @@ func (c *Client) GetKubeAPIServerEndpoints(ctx context.Context) ([]string, error
}
for _, addr := range subset.Addresses {
if addr.IP != "" {
addresses = append(addresses, fmt.Sprintf("%s:%d", addr.IP, portNumber))
var address string
if utils.IsIPv4(addr.IP) {
address = addr.IP
} else {
address = fmt.Sprintf("[%s]", addr.IP)
}
addresses = append(addresses, fmt.Sprintf("%s:%d", address, portNumber))
}
}
}
Expand Down
25 changes: 22 additions & 3 deletions src/k8s/pkg/k8sd/api/certificates_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ func refreshCertsRunControlPlane(s state.State, r *http.Request, snap snap.Snap)
return response.InternalError(fmt.Errorf("failed to parse node IP address %q", s.Address().Hostname()))
}

var localhostAddress string
if nodeIP.To4() == nil {
localhostAddress = "[::1]"
} else {
localhostAddress = "127.0.0.1"
}

serviceIPs, err := utils.GetKubernetesServiceIPsFromServiceCIDRs(clusterConfig.Network.GetServiceCIDR())
if err != nil {
return response.InternalError(fmt.Errorf("failed to get IP address(es) from ServiceCIDR %q: %w", clusterConfig.Network.GetServiceCIDR(), err))
Expand Down Expand Up @@ -119,7 +126,7 @@ func refreshCertsRunControlPlane(s state.State, r *http.Request, snap snap.Snap)
return response.InternalError(fmt.Errorf("failed to write control plane certificates: %w", err))
}

if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), clusterConfig.APIServer.GetSecurePort(), *certificates); err != nil {
if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), localhostAddress, clusterConfig.APIServer.GetSecurePort(), *certificates); err != nil {
return response.InternalError(fmt.Errorf("failed to generate control plane kubeconfigs: %w", err))
}

Expand Down Expand Up @@ -262,11 +269,23 @@ func refreshCertsRunWorker(s state.State, r *http.Request, snap snap.Snap) respo
return response.InternalError(fmt.Errorf("failed to write worker PKI: %w", err))
}

nodeIP := net.ParseIP(s.Address().Hostname())
if nodeIP == nil {
return response.InternalError(fmt.Errorf("failed to parse node IP address %q", s.Address().Hostname()))
}

var localhostAddress string
if nodeIP.To4() == nil {
localhostAddress = "[::1]"
} else {
localhostAddress = "127.0.0.1"
}

// Kubeconfigs
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "kubelet.conf"), "127.0.0.1:6443", certificates.CACert, certificates.KubeletClientCert, certificates.KubeletClientKey); err != nil {
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "kubelet.conf"), fmt.Sprintf("%s:6443", localhostAddress), certificates.CACert, certificates.KubeletClientCert, certificates.KubeletClientKey); err != nil {
return response.InternalError(fmt.Errorf("failed to generate kubelet kubeconfig: %w", err))
}
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "proxy.conf"), "127.0.0.1:6443", certificates.CACert, certificates.KubeProxyClientCert, certificates.KubeProxyClientKey); err != nil {
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "proxy.conf"), fmt.Sprintf("%s:6443", localhostAddress), certificates.CACert, certificates.KubeProxyClientCert, certificates.KubeProxyClientKey); err != nil {
return response.InternalError(fmt.Errorf("failed to generate kube-proxy kubeconfig: %w", err))
}

Expand Down
31 changes: 23 additions & 8 deletions src/k8s/pkg/k8sd/app/hooks_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,18 @@ func (a *App) onBootstrapWorkerNode(ctx context.Context, s state.State, encodedT
return fmt.Errorf("failed to write worker node certificates: %w", err)
}

var localhostAddress string
if nodeIP.To4() == nil {
localhostAddress = "[::1]"
} else {
localhostAddress = "127.0.0.1"
}

// Kubeconfigs
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "kubelet.conf"), "127.0.0.1:6443", certificates.CACert, certificates.KubeletClientCert, certificates.KubeletClientKey); err != nil {
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "kubelet.conf"), fmt.Sprintf("%s:6443", localhostAddress), certificates.CACert, certificates.KubeletClientCert, certificates.KubeletClientKey); err != nil {
return fmt.Errorf("failed to generate kubelet kubeconfig: %w", err)
}
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "proxy.conf"), "127.0.0.1:6443", certificates.CACert, certificates.KubeProxyClientCert, certificates.KubeProxyClientKey); err != nil {
if err := setup.Kubeconfig(filepath.Join(snap.KubernetesConfigDir(), "proxy.conf"), fmt.Sprintf("%s:6443", localhostAddress), certificates.CACert, certificates.KubeProxyClientCert, certificates.KubeProxyClientKey); err != nil {
return fmt.Errorf("failed to generate kube-proxy kubeconfig: %w", err)
}

Expand Down Expand Up @@ -229,10 +236,10 @@ func (a *App) onBootstrapWorkerNode(ctx context.Context, s state.State, encodedT
if err := setup.KubeletWorker(snap, s.Name(), nodeIP, response.ClusterDNS, response.ClusterDomain, response.CloudProvider, joinConfig.ExtraNodeKubeletArgs); err != nil {
return fmt.Errorf("failed to configure kubelet: %w", err)
}
if err := setup.KubeProxy(ctx, snap, s.Name(), response.PodCIDR, joinConfig.ExtraNodeKubeProxyArgs); err != nil {
if err := setup.KubeProxy(ctx, snap, s.Name(), response.PodCIDR, localhostAddress, joinConfig.ExtraNodeKubeProxyArgs); err != nil {
return fmt.Errorf("failed to configure kube-proxy: %w", err)
}
if err := setup.K8sAPIServerProxy(snap, response.APIServers, joinConfig.ExtraNodeK8sAPIServerProxyArgs); err != nil {
if err := setup.K8sAPIServerProxy(snap, response.APIServers, localhostAddress, joinConfig.ExtraNodeK8sAPIServerProxyArgs); err != nil {
return fmt.Errorf("failed to configure k8s-apiserver-proxy: %w", err)
}
if err := setup.ExtraNodeConfigFiles(snap, joinConfig.ExtraNodeConfigFiles); err != nil {
Expand Down Expand Up @@ -277,6 +284,13 @@ func (a *App) onBootstrapControlPlane(ctx context.Context, s state.State, bootst
return fmt.Errorf("failed to parse node IP address %q", s.Address().Hostname())
}

var localhostAddress string
if nodeIP.To4() == nil {
localhostAddress = "[::1]"
} else {
localhostAddress = "127.0.0.1"
}

// Create directories
if err := setup.EnsureAllDirectories(snap); err != nil {
return fmt.Errorf("failed to create directories: %w", err)
Expand All @@ -296,7 +310,7 @@ func (a *App) onBootstrapControlPlane(ctx context.Context, s state.State, bootst
// NOTE: Default certificate expiration is set to 20 years.
certificates := pki.NewK8sDqlitePKI(pki.K8sDqlitePKIOpts{
Hostname: s.Name(),
IPSANs: []net.IP{{127, 0, 0, 1}},
IPSANs: []net.IP{net.ParseIP("127.0.0.1"), net.ParseIP("::1")},
NotBefore: notBefore,
NotAfter: notBefore.AddDate(20, 0, 0),
AllowSelfSignedCA: true,
Expand Down Expand Up @@ -395,14 +409,15 @@ func (a *App) onBootstrapControlPlane(ctx context.Context, s state.State, bootst
}

// Generate kubeconfigs
if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), cfg.APIServer.GetSecurePort(), *certificates); err != nil {
if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), localhostAddress, cfg.APIServer.GetSecurePort(), *certificates); err != nil {
return fmt.Errorf("failed to generate kubeconfigs: %w", err)
}

// Configure datastore
switch cfg.Datastore.GetType() {
case "k8s-dqlite":
if err := setup.K8sDqlite(snap, fmt.Sprintf("%s:%d", nodeIP.String(), cfg.Datastore.GetK8sDqlitePort()), nil, bootstrapConfig.ExtraNodeK8sDqliteArgs); err != nil {
address := fmt.Sprintf("%s:%d", utils.ToIPString(nodeIP), cfg.Datastore.GetK8sDqlitePort())
if err := setup.K8sDqlite(snap, address, nil, bootstrapConfig.ExtraNodeK8sDqliteArgs); err != nil {
return fmt.Errorf("failed to configure k8s-dqlite: %w", err)
}
case "external":
Expand All @@ -417,7 +432,7 @@ func (a *App) onBootstrapControlPlane(ctx context.Context, s state.State, bootst
if err := setup.KubeletControlPlane(snap, s.Name(), nodeIP, cfg.Kubelet.GetClusterDNS(), cfg.Kubelet.GetClusterDomain(), cfg.Kubelet.GetCloudProvider(), cfg.Kubelet.GetControlPlaneTaints(), bootstrapConfig.ExtraNodeKubeletArgs); err != nil {
return fmt.Errorf("failed to configure kubelet: %w", err)
}
if err := setup.KubeProxy(ctx, snap, s.Name(), cfg.Network.GetPodCIDR(), bootstrapConfig.ExtraNodeKubeProxyArgs); err != nil {
if err := setup.KubeProxy(ctx, snap, s.Name(), cfg.Network.GetPodCIDR(), localhostAddress, bootstrapConfig.ExtraNodeKubeProxyArgs); err != nil {
return fmt.Errorf("failed to configure kube-proxy: %w", err)
}
if err := setup.KubeControllerManager(snap, bootstrapConfig.ExtraNodeKubeControllerManagerArgs); err != nil {
Expand Down
23 changes: 18 additions & 5 deletions src/k8s/pkg/k8sd/app/hooks_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ func (a *App) onPostJoin(ctx context.Context, s state.State, initConfig map[stri
return fmt.Errorf("failed to parse node IP address %q", s.Address().Hostname())
}

var localhostAddress string
if nodeIP.To4() == nil {
localhostAddress = "[::1]"
} else {
localhostAddress = "127.0.0.1"
}

// Create directories
if err := setup.EnsureAllDirectories(snap); err != nil {
return fmt.Errorf("failed to create directories: %w", err)
Expand All @@ -64,7 +71,7 @@ func (a *App) onPostJoin(ctx context.Context, s state.State, initConfig map[stri
// NOTE: Default certificate expiration is set to 20 years.
certificates := pki.NewK8sDqlitePKI(pki.K8sDqlitePKIOpts{
Hostname: s.Name(),
IPSANs: []net.IP{{127, 0, 0, 1}},
IPSANs: []net.IP{net.ParseIP("127.0.0.1"), net.ParseIP("::1")},
NotBefore: notBefore,
NotAfter: notBefore.AddDate(20, 0, 0),
})
Expand Down Expand Up @@ -140,7 +147,7 @@ func (a *App) onPostJoin(ctx context.Context, s state.State, initConfig map[stri
return fmt.Errorf("failed to write control plane certificates: %w", err)
}

if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), cfg.APIServer.GetSecurePort(), *certificates); err != nil {
if err := setup.SetupControlPlaneKubeconfigs(snap.KubernetesConfigDir(), localhostAddress, cfg.APIServer.GetSecurePort(), *certificates); err != nil {
return fmt.Errorf("failed to generate kubeconfigs: %w", err)
}

Expand All @@ -158,10 +165,16 @@ func (a *App) onPostJoin(ctx context.Context, s state.State, initConfig map[stri
}
cluster := make([]string, len(members))
for _, member := range members {
cluster = append(cluster, fmt.Sprintf("%s:%d", member.Address.Addr(), cfg.Datastore.GetK8sDqlitePort()))
var address string
if member.Address.Addr().Is6() {
address = fmt.Sprintf("[%s]", member.Address.Addr())
} else {
address = member.Address.Addr().String()
}
cluster = append(cluster, fmt.Sprintf("%s:%d", address, cfg.Datastore.GetK8sDqlitePort()))
}

address := fmt.Sprintf("%s:%d", nodeIP.String(), cfg.Datastore.GetK8sDqlitePort())
address := fmt.Sprintf("%s:%d", utils.ToIPString(nodeIP), cfg.Datastore.GetK8sDqlitePort())
if err := setup.K8sDqlite(snap, address, cluster, joinConfig.ExtraNodeK8sDqliteArgs); err != nil {
return fmt.Errorf("failed to configure k8s-dqlite with address=%s cluster=%v: %w", address, cluster, err)
}
Expand All @@ -177,7 +190,7 @@ func (a *App) onPostJoin(ctx context.Context, s state.State, initConfig map[stri
if err := setup.KubeletControlPlane(snap, s.Name(), nodeIP, cfg.Kubelet.GetClusterDNS(), cfg.Kubelet.GetClusterDomain(), cfg.Kubelet.GetCloudProvider(), cfg.Kubelet.GetControlPlaneTaints(), joinConfig.ExtraNodeKubeletArgs); err != nil {
return fmt.Errorf("failed to configure kubelet: %w", err)
}
if err := setup.KubeProxy(ctx, snap, s.Name(), cfg.Network.GetPodCIDR(), joinConfig.ExtraNodeKubeProxyArgs); err != nil {
if err := setup.KubeProxy(ctx, snap, s.Name(), cfg.Network.GetPodCIDR(), localhostAddress, joinConfig.ExtraNodeKubeProxyArgs); err != nil {
return fmt.Errorf("failed to configure kube-proxy: %w", err)
}
if err := setup.KubeControllerManager(snap, joinConfig.ExtraNodeKubeControllerManagerArgs); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/pki/k8sdqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *K8sDqlitePKI) CompleteCertificates() error {
return fmt.Errorf("k8s-dqlite certificate not specified and generating self-signed certificates is not allowed")
}

template, err := pkiutil.GenerateCertificate(pkix.Name{CommonName: "k8s"}, c.notBefore, c.notAfter, false, append(c.dnsSANs, c.hostname), append(c.ipSANs, net.IP{127, 0, 0, 1}))
template, err := pkiutil.GenerateCertificate(pkix.Name{CommonName: "k8s"}, c.notBefore, c.notAfter, false, append(c.dnsSANs, c.hostname), append(c.ipSANs, net.ParseIP("127.0.0.1"), net.ParseIP("::1")))
if err != nil {
return fmt.Errorf("failed to generate k8s-dqlite certificate: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/pki/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c *ControlPlanePKI) CompleteWorkerNodePKI(hostname string, nodeIP net.IP,
c.notAfter,
false,
[]string{hostname},
[]net.IP{{127, 0, 0, 1}, nodeIP},
[]net.IP{net.ParseIP("127.0.0.1"), net.ParseIP("::1"), nodeIP},
)
if err != nil {
return nil, fmt.Errorf("failed to generate kubelet certificate for hostname=%s address=%s: %w", hostname, nodeIP.String(), err)
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/setup/k8s_apiserver_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// K8sAPIServerProxy prepares configuration for k8s-apiserver-proxy.
func K8sAPIServerProxy(snap snap.Snap, servers []string, extraArgs map[string]*string) error {
func K8sAPIServerProxy(snap snap.Snap, servers []string, localhostAddress string, extraArgs map[string]*string) error {
configFile := filepath.Join(snap.ServiceExtraConfigDir(), "k8s-apiserver-proxy.json")
if err := proxy.WriteEndpointsConfig(servers, configFile); err != nil {
return fmt.Errorf("failed to write proxy configuration file: %w", err)
Expand All @@ -20,7 +20,7 @@ func K8sAPIServerProxy(snap snap.Snap, servers []string, extraArgs map[string]*s
if _, err := snaputil.UpdateServiceArguments(snap, "k8s-apiserver-proxy", map[string]string{
"--endpoints": configFile,
"--kubeconfig": filepath.Join(snap.KubernetesConfigDir(), "kubelet.conf"),
"--listen": "127.0.0.1:6443",
"--listen": fmt.Sprintf("%s:6443", localhostAddress),
}, nil); err != nil {
return fmt.Errorf("failed to write arguments file: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions src/k8s/pkg/k8sd/setup/k8s_apiserver_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestK8sApiServerProxy(t *testing.T) {

s := mustSetupSnapAndDirectories(t, setK8sApiServerMock)

g.Expect(setup.K8sAPIServerProxy(s, nil, nil)).To(Succeed())
g.Expect(setup.K8sAPIServerProxy(s, nil, "127.0.0.1", nil)).To(Succeed())

tests := []struct {
key string
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestK8sApiServerProxy(t *testing.T) {
"--listen": nil, // This should trigger a delete
"--my-extra-arg": utils.Pointer("my-extra-val"),
}
g.Expect(setup.K8sAPIServerProxy(s, nil, extraArgs)).To(Succeed())
g.Expect(setup.K8sAPIServerProxy(s, nil, "127.0.0.1", extraArgs)).To(Succeed())

tests := []struct {
key string
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestK8sApiServerProxy(t *testing.T) {
s := mustSetupSnapAndDirectories(t, setK8sApiServerMock)

s.Mock.ServiceExtraConfigDir = "nonexistent"
g.Expect(setup.K8sAPIServerProxy(s, nil, nil)).ToNot(Succeed())
g.Expect(setup.K8sAPIServerProxy(s, nil, "127.0.0.1", nil)).ToNot(Succeed())
})

t.Run("MissingServiceArgumentsDir", func(t *testing.T) {
Expand All @@ -107,7 +107,7 @@ func TestK8sApiServerProxy(t *testing.T) {
s := mustSetupSnapAndDirectories(t, setK8sApiServerMock)

s.Mock.ServiceArgumentsDir = "nonexistent"
g.Expect(setup.K8sAPIServerProxy(s, nil, nil)).ToNot(Succeed())
g.Expect(setup.K8sAPIServerProxy(s, nil, "127.0.0.1", nil)).ToNot(Succeed())
})

t.Run("JSONFileContent", func(t *testing.T) {
Expand All @@ -118,7 +118,7 @@ func TestK8sApiServerProxy(t *testing.T) {
endpoints := []string{"192.168.0.1", "192.168.0.2", "192.168.0.3"}
fileName := filepath.Join(s.Mock.ServiceExtraConfigDir, "k8s-apiserver-proxy.json")

g.Expect(setup.K8sAPIServerProxy(s, endpoints, nil)).To(Succeed())
g.Expect(setup.K8sAPIServerProxy(s, endpoints, "127.0.0.1", nil)).To(Succeed())

b, err := os.ReadFile(fileName)
g.Expect(err).NotTo(HaveOccurred())
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/setup/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

// KubeProxy configures kube-proxy on the local node.
func KubeProxy(ctx context.Context, snap snap.Snap, hostname string, podCIDR string, extraArgs map[string]*string) error {
func KubeProxy(ctx context.Context, snap snap.Snap, hostname string, podCIDR string, localhostAddress string, extraArgs map[string]*string) error {
serviceArgs := map[string]string{
"--cluster-cidr": podCIDR,
"--healthz-bind-address": "127.0.0.1",
"--healthz-bind-address": fmt.Sprintf("%s:10256", localhostAddress),
"--kubeconfig": filepath.Join(snap.KubernetesConfigDir(), "proxy.conf"),
"--profiling": "false",
}
Expand Down
8 changes: 4 additions & 4 deletions src/k8s/pkg/k8sd/setup/kube_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestKubeProxy(t *testing.T) {
g.Expect(setup.EnsureAllDirectories(s)).To(BeNil())

t.Run("Args", func(t *testing.T) {
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", nil)).To(BeNil())
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", "127.0.0.1", nil)).To(BeNil())

for key, expectedVal := range map[string]string{
"--cluster-cidr": "10.1.0.0/16",
Expand All @@ -55,7 +55,7 @@ func TestKubeProxy(t *testing.T) {
"--healthz-bind-address": nil,
"--my-extra-arg": utils.Pointer("my-extra-val"),
}
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", extraArgs)).To(BeNil())
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", "127.0.0.1", extraArgs)).To(BeNil())

for key, expectedVal := range map[string]string{
"--cluster-cidr": "10.1.0.0/16",
Expand All @@ -80,7 +80,7 @@ func TestKubeProxy(t *testing.T) {

s.Mock.OnLXD = true
t.Run("ArgsOnLXD", func(t *testing.T) {
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", nil)).To(BeNil())
g.Expect(setup.KubeProxy(context.Background(), s, "myhostname", "10.1.0.0/16", "127.0.0.1", nil)).To(BeNil())

for key, expectedVal := range map[string]string{
"--conntrack-max-per-core": "0",
Expand All @@ -103,7 +103,7 @@ func TestKubeProxy(t *testing.T) {
s.Mock.ServiceArgumentsDir = filepath.Join(dir, "k8s")

g.Expect(setup.EnsureAllDirectories(s)).To(BeNil())
g.Expect(setup.KubeProxy(context.Background(), s, "dev", "10.1.0.0/16", nil)).To(BeNil())
g.Expect(setup.KubeProxy(context.Background(), s, "dev", "10.1.0.0/16", "127.0.0.1", nil)).To(BeNil())

val, err := snaputil.GetServiceArgument(s, "kube-proxy", "--hostname-override")
g.Expect(err).To(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/setup/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func kubelet(snap snap.Snap, hostname string, nodeIP net.IP, clusterDNS string,
args["--cluster-domain"] = clusterDomain
}
if nodeIP != nil && !nodeIP.IsLoopback() {
args["--node-ip"] = nodeIP.String()
args["--node-ip"] = utils.ToIPString(nodeIP)
}
if _, err := snaputil.UpdateServiceArguments(snap, "kubelet", args, nil); err != nil {
return fmt.Errorf("failed to render arguments file: %w", err)
Expand Down
Loading

0 comments on commit e8475bf

Please sign in to comment.