From 95ab317c8ae7edd6e9a37eef0854cb2e0ba1105f Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sat, 25 Apr 2020 14:59:55 +0300 Subject: [PATCH] Don't install static utils for Flatcar --- nodeup/pkg/model/kubelet.go | 71 +++++++++++-------------------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/nodeup/pkg/model/kubelet.go b/nodeup/pkg/model/kubelet.go index fb41444dc8..488dd411e2 100644 --- a/nodeup/pkg/model/kubelet.go +++ b/nodeup/pkg/model/kubelet.go @@ -141,8 +141,11 @@ func (b *KubeletBuilder) Build(c *fi.ModelBuilderContext) error { }) } - if err := b.addStaticUtils(c); err != nil { - return err + if b.Distribution == distros.DistributionCoreOS { + // CoreOS does not ship with socat or conntrack. Install our own (statically linked) version + if err := b.addStaticUtils(c); err != nil { + return err + } } if err := b.addContainerizedMounter(c); err != nil { @@ -278,10 +281,6 @@ func (b *KubeletBuilder) buildSystemdService() *nodetasks.Service { // We add /opt/kubernetes/bin for our utilities (socat, conntrack) manifest.Set("Service", "Environment", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kubernetes/bin") } - if b.Distribution == distros.DistributionFlatcar { - // We add /opt/kubernetes/bin for our utilities (conntrack) - manifest.Set("Service", "Environment", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kubernetes/bin") - } manifest.Set("Service", "EnvironmentFile", "/etc/sysconfig/kubelet") // @check if we are using bootstrap tokens and file checker @@ -333,52 +332,24 @@ func (b *KubeletBuilder) buildKubeletConfig() (*kops.KubeletConfigSpec, error) { } func (b *KubeletBuilder) addStaticUtils(c *fi.ModelBuilderContext) error { - if b.Distribution == distros.DistributionCoreOS { - // CoreOS does not ship with socat or conntrack. Install our own (statically linked) version - // TODO: Extract to common function? - for _, binary := range []string{"socat", "conntrack"} { - assetName := binary - assetPath := "" - asset, err := b.Assets.Find(assetName, assetPath) - if err != nil { - return fmt.Errorf("error trying to locate asset %q: %v", assetName, err) - } - if asset == nil { - return fmt.Errorf("unable to locate asset %q", assetName) - } - - t := &nodetasks.File{ - Path: "/opt/kubernetes/bin/" + binary, - Contents: asset, - Type: nodetasks.FileType_File, - Mode: s("0755"), - } - c.AddTask(t) + for _, binary := range []string{"socat", "conntrack"} { + assetName := binary + assetPath := "" + asset, err := b.Assets.Find(assetName, assetPath) + if err != nil { + return fmt.Errorf("error trying to locate asset %q: %v", assetName, err) } - } - - if b.Distribution == distros.DistributionFlatcar { - // Flatcar does not ship with conntrack. Install our own (statically linked) version - // TODO: Extract to common function? - for _, binary := range []string{"conntrack"} { - assetName := binary - assetPath := "" - asset, err := b.Assets.Find(assetName, assetPath) - if err != nil { - return fmt.Errorf("error trying to locate asset %q: %v", assetName, err) - } - if asset == nil { - return fmt.Errorf("unable to locate asset %q", assetName) - } - - t := &nodetasks.File{ - Path: "/opt/kubernetes/bin/" + binary, - Contents: asset, - Type: nodetasks.FileType_File, - Mode: s("0755"), - } - c.AddTask(t) + if asset == nil { + return fmt.Errorf("unable to locate asset %q", assetName) } + + t := &nodetasks.File{ + Path: "/opt/kubernetes/bin/" + binary, + Contents: asset, + Type: nodetasks.FileType_File, + Mode: s("0755"), + } + c.AddTask(t) } return nil