コード例 #1
0
ファイル: k8s.go プロジェクト: giantswarm/yochu
func Setup(fsc *fs.FsClient, fc fetchclient.FetchClient, distributionPath, k8sVersion string) error {
	vLogger("\n# call k8s.Setup()")

	k8sRaw, err := fc.Get("k8s/" + k8sVersion + "/kubectl")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/kubectl", k8sRaw, fileMode); err != nil {
		return maskAny(err)
	}

	return nil
}
コード例 #2
0
ファイル: fleet.go プロジェクト: giantswarm/yochu
func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, fleetVersion string, startDaemon bool, useOverlay bool) error {
	vLogger("\n# call fleet.Setup()")

	fleetdRaw, err := fc.Get("fleet/" + fleetVersion + "/fleetd")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/fleet", fleetdRaw, fileMode); err != nil {
		return maskAny(err)
	}

	if err := fsc.Symlink(distributionPath+"/fleet", distributionPath+"/fleetd"); err != nil {
		return maskAny(err)
	}

	fleetctlRaw, err := fc.Get("fleet/" + fleetVersion + "/fleetctl")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/fleetctl", fleetctlRaw, fileMode); err != nil {
		return maskAny(err)
	}

	err = createFleetService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(fleetServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
コード例 #3
0
ファイル: etcd.go プロジェクト: giantswarm/yochu
func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, etcdVersion string, startDaemon bool, useOverlay bool) error {
	vLogger("\n# call etcd.Setup()")

	etcdRaw, err := fc.Get("etcd/" + etcdVersion + "/etcd")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/etcd2", etcdRaw, fileMode); err != nil {
		return maskAny(err)
	}

	etcdctlRaw, err := fc.Get("etcd/" + etcdVersion + "/etcdctl")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/etcdctl", etcdctlRaw, fileMode); err != nil {
		return maskAny(err)
	}

	err = createEtcdService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(etcdServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
コード例 #4
0
ファイル: rkt.go プロジェクト: giantswarm/yochu
func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, rktVersion string, startDaemon, useOverlay bool) error {
	vLogger("\n# call rkt.Setup()")

	rktRaw, err := fc.Get("rkt/" + rktVersion + "/rkt")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/rkt", rktRaw, binaryFileMode); err != nil {
		return maskAny(err)
	}

	err = createRktGarbageService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	err = createRktMetadataService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(rktGarbageTimerName); err != nil {
			return maskAny(err)
		}
		if err := sc.Start(rktMetadataServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
コード例 #5
0
ファイル: docker.go プロジェクト: giantswarm/yochu
func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, dockerVersion string, privateRegistry []string, useIPTables, restartDaemon bool, useOverlay bool) error {
	vLogger("\n# call docker.Setup()")

	// This is the version where Docker split into multiple binaries.
	dockerMultipleBinariesVersion, _ := semver.NewVersion("1.11.0")

	semverDockerVersion, err := semver.NewVersion(dockerVersion)
	if err != nil {
		return maskAny(err)
	}

	dockerBinariesToGetAndWrite := []string{}
	if semverDockerVersion.LessThan(*dockerMultipleBinariesVersion) {
		dockerBinariesToGetAndWrite = []string{"docker"}
	} else {
		dockerBinariesToGetAndWrite = []string{
			"docker",
			"docker-containerd",
			"docker-containerd-ctr",
			"docker-containerd-shim",
			"docker-runc",
		}
	}

	for _, dockerBinaryName := range dockerBinariesToGetAndWrite {
		dockerRaw, err := fc.Get("docker/" + dockerVersion + "/" + dockerBinaryName)
		if err != nil {
			return maskAny(err)
		}

		if err := fsc.Write(distributionPath+"/"+dockerBinaryName, dockerRaw, fileMode); err != nil {
			return maskAny(err)
		}
	}

	err = createDockerService(fsc, dockerVersion, privateRegistry, useIPTables, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	dockerTcpSocket, err := templates.Asset(socketTemplate)
	if err != nil {
		return maskAny(err)
	}

	// write docker-tcp.socket unit to host
	if err := fsc.Write(socketPath, dockerTcpSocket, fileMode); err != nil {
		return maskAny(err)
	}

	// reload unit files, that is, `systemctl daemon-reload`
	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if restartDaemon {
		// start docker-tcp.socket unit
		if err := sc.Start(socketName); err != nil {
			return maskAny(err)
		}

		// start docker.service unit
		if err := sc.Start(serviceName); err != nil {
			// If there is a dependency error, we just log it. This only happens in case
			// the provisioner is restarted. Then systemd throws an error when starting
			// docker, even though the only dependency (docker-tcp.socket) does not
			// fail.
			if systemd.IsJobDependency(err) {
				vLogger(err.Error())
			} else {
				return maskAny(err)
			}
		}
	}

	return nil
}