Skip to content

Commit

Permalink
Merge pull request #8978 from hakman/flatcar-remove-static-utils
Browse files Browse the repository at this point in the history
Don't install static utils for Flatcar
  • Loading branch information
k8s-ci-robot committed May 4, 2020
2 parents 58c3dcd + 95ab317 commit e54559b
Showing 1 changed file with 20 additions and 49 deletions.
69 changes: 20 additions & 49 deletions nodeup/pkg/model/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 asset == nil {
return fmt.Errorf("unable to locate asset %q", assetName)
}
}

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)
t := &nodetasks.File{
Path: "/opt/kubernetes/bin/" + binary,
Contents: asset,
Type: nodetasks.FileType_File,
Mode: s("0755"),
}
c.AddTask(t)
}

return nil
Expand Down

0 comments on commit e54559b

Please sign in to comment.