Skip to content

Commit

Permalink
Configure docker on CoreOS/ContainerOS
Browse files Browse the repository at this point in the history
While the installation of docker should be skipped, docker should still be
configured to allow overriding the docker config using kops.

Fixes #3057
  • Loading branch information
johanneswuerbach committed Jul 31, 2017
1 parent d9427cf commit 1151d75
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion nodeup/pkg/model/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package model

import (
"fmt"
"strings"

"github.com/blang/semver"
"github.com/golang/glog"
"k8s.io/kops/nodeup/pkg/distros"
Expand All @@ -26,7 +28,6 @@ import (
"k8s.io/kops/pkg/systemd"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"strings"
)

// DockerBuilder install docker (just the packages at the moment)
Expand Down Expand Up @@ -295,10 +296,16 @@ func (b *DockerBuilder) Build(c *fi.ModelBuilderContext) error {
switch b.Distribution {
case distros.DistributionCoreOS:
glog.Infof("Detected CoreOS; won't install Docker")
if err := b.buildContainerOSConfigurationDropIn(c); err != nil {
return err
}
return nil

case distros.DistributionContainerOS:
glog.Infof("Detected ContainerOS; won't install Docker")
if err := b.buildContainerOSConfigurationDropIn(c); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -458,6 +465,27 @@ func (b *DockerBuilder) buildSystemdService(dockerVersion semver.Version) *nodet
return service
}

func (b *DockerBuilder) buildContainerOSConfigurationDropIn(c *fi.ModelBuilderContext) error {
lines := []string{
"[Service]",
"EnvironmentFile=/etc/sysconfig/docker",
}
contents := strings.Join(lines, "\n")

t := &nodetasks.File{
Path: "/etc/systemd/system/docker.service.d/10-kops.conf",
Contents: fi.NewStringResource(contents),
Type: nodetasks.FileType_File,
}
c.AddTask(t)

if err := b.buildSysconfig(c); err != nil {
return err
}

return nil
}

func (b *DockerBuilder) buildSysconfig(c *fi.ModelBuilderContext) error {
flagsString, err := flagbuilder.BuildFlags(b.Cluster.Spec.Docker)
if err != nil {
Expand Down

0 comments on commit 1151d75

Please sign in to comment.