Skip to content

Commit

Permalink
Merge pull request #2068 from vbatts/crio-insecure-registry
Browse files Browse the repository at this point in the history
buildroot: output flags for crio
  • Loading branch information
r2d4 authored Oct 17, 2017
2 parents 0df72ca + 50570f6 commit 5ccaae8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions deploy/iso/minikube-iso/package/crio-bin/crio.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ Requires=minikube-automount.service
[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/crio
EnvironmentFile=-/etc/sysconfig/crio.minikube
EnvironmentFile=/var/run/minikube/env
Environment=GOTRACEBACK=crash
ExecStartPre=/bin/mkdir -p ${PERSISTENT_DIR}/var/lib/containers
ExecStart=/usr/bin/crio \
$CRIO_OPTIONS \
$CRIO_MINIKUBE_OPTIONS \
--root ${PERSISTENT_DIR}/var/lib/containers
ExecReload=/bin/kill -s HUP $MAINPID
TasksMax=8192
Expand Down
39 changes: 36 additions & 3 deletions pkg/provision/buildroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ WantedBy=multi-user.target
EngineOptions: p.EngineOptions,
}

t.Execute(&engineCfg, engineConfigContext)
if err := t.Execute(&engineCfg, engineConfigContext); err != nil {
return nil, err
}

return &provision.DockerOptions{
EngineOptions: engineCfg.String(),
Expand All @@ -149,20 +151,24 @@ func (p *BuildrootProvisioner) Provision(swarmOptions swarm.Options, authOptions
log.Debugf("set auth options %+v", p.AuthOptions)

log.Debugf("setting up certificates")

configureAuth := func() error {
if err := configureAuth(p); err != nil {
return &util.RetriableError{Err: err}
}
return nil
}

err := util.RetryAfter(5, configureAuth, time.Second*10)
if err != nil {
log.Debugf("Error configuring auth during provisioning %v", err)
return err
}

log.Debugf("setting minikube options for container-runtime")
if err := setMinikubeOptions(p); err != nil {
log.Debugf("Error setting container-runtime options during provisioning %v", err)
return err
}

return nil
}

Expand All @@ -179,6 +185,33 @@ func setRemoteAuthOptions(p provision.Provisioner) auth.Options {
return authOptions
}

func setMinikubeOptions(p *BuildrootProvisioner) error {
// pass through --insecure-registry
var (
crioOptsTmpl = `
CRIO_MINIKUBE_OPTIONS='{{ range .EngineOptions.InsecureRegistry }}--insecure-registry {{.}} {{ end }}'
`
crioOptsPath = "/etc/sysconfig/crio.minikube"
)
t, err := template.New("crioOpts").Parse(crioOptsTmpl)
if err != nil {
return err
}
var crioOptsBuf bytes.Buffer
if err := t.Execute(&crioOptsBuf, p); err != nil {
return err
}
if _, err = p.SSHCommand(fmt.Sprintf("sudo mkdir -p %s && printf %%s \"%s\" | sudo tee %s", path.Dir(crioOptsPath), crioOptsBuf.String(), crioOptsPath)); err != nil {
return err
}

if err := p.Service("crio", serviceaction.Restart); err != nil {
return err
}

return nil
}

func configureAuth(p *BuildrootProvisioner) error {
driver := p.GetDriver()
machineName := driver.GetMachineName()
Expand Down

0 comments on commit 5ccaae8

Please sign in to comment.