func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) {
	k8sVersion, err := util.ParseKubernetesVersion(t.Cluster.Spec.KubernetesVersion)
	if err != nil || k8sVersion == nil {
		return nil, fmt.Errorf("unable to parse KubernetesVersion %q", t.Cluster.Spec.KubernetesVersion)
	}

	protokubeFlags, err := t.ProtokubeFlags(*k8sVersion)
	if err != nil {
		return nil, err
	}
	protokubeFlagsArgs, err := flagbuilder.BuildFlags(protokubeFlags)
	if err != nil {
		return nil, err
	}

	dockerArgs := []string{
		"/usr/bin/docker", "run",
		"-v", "/:/rootfs/",
		"-v", "/var/run/dbus:/var/run/dbus",
		"-v", "/run/systemd:/run/systemd",
	}

	// add kubectl only if a master
	// path changes depending on distro, and always mount it on /opt/kops/bin
	// kubectl is downloaded and installed by other tasks
	if t.IsMaster {
		dockerArgs = append(dockerArgs, []string{
			"-v", t.KubectlPath() + ":/opt/kops/bin:ro",
			"--env", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kops/bin",
		}...)
	}

	dockerArgs = append(dockerArgs, []string{
		"--net=host",
		"--pid=host",   // Needed for mounting in a container (when using systemd mounting?)
		"--privileged", // We execute in the host namespace
		"--env", "KUBECONFIG=/rootfs/var/lib/kops/kubeconfig",
		t.ProtokubeEnvironmentVariables(),
		t.ProtokubeImageName(),
		"/usr/bin/protokube",
	}...)

	protokubeCommand := strings.Join(dockerArgs, " ") + " " + protokubeFlagsArgs

	manifest := &systemd.Manifest{}
	manifest.Set("Unit", "Description", "Kubernetes Protokube Service")
	manifest.Set("Unit", "Documentation", "https://github.com/kubernetes/kops")

	// @step: let need a dependency for any volumes to be mounted first
	manifest.Set("Service", "ExecStartPre", t.ProtokubeImagePullCommand())
	manifest.Set("Service", "ExecStart", protokubeCommand)
	manifest.Set("Service", "Restart", "always")
	manifest.Set("Service", "RestartSec", "2s")
	manifest.Set("Service", "StartLimitInterval", "0")
	manifest.Set("Install", "WantedBy", "multi-user.target")

	manifestString := manifest.Render()
	klog.V(8).Infof("Built service manifest %q\n%s", "protokube", manifestString)

	service := &nodetasks.Service{
		Name:       "protokube.service",
		Definition: s(manifestString),
	}

	service.InitDefaults()

	return service, nil
}
// buildSystemdService generates the manifest for the protokube service
buildSystemdService generates the manifest for the protokube service
// buildSystemdService generates the manifest for the protokube service
func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) {
	k8sVersion, err := util.ParseKubernetesVersion(t.Cluster.Spec.KubernetesVersion)
	if err != nil || k8sVersion == nil {
		return nil, fmt.Errorf("unable to parse KubernetesVersion %q", t.Cluster.Spec.KubernetesVersion)
	}
	protokubeFlags, err := t.ProtokubeFlags(*k8sVersion)
	if err != nil {
		return nil, err
	}
	protokubeFlagsArgs, err := flagbuilder.BuildFlags(protokubeFlags)
	if err != nil {
		return nil, err
	}
	dockerArgs := []string{
		"/usr/bin/docker", "run",
		"-v", "/:/rootfs/",
		"-v", "/var/run/dbus:/var/run/dbus",
		"-v", "/run/systemd:/run/systemd",
	}
	if t.IsMaster {
		dockerArgs = append(dockerArgs, []string{
			"-v", t.KubectlPath() + ":/opt/kops/bin:ro",
			"--env", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/kops/bin",
		}...)
	}
	dockerArgs = append(dockerArgs, []string{
		"--net=host",
		"--pid=host",   
		"--privileged", 
		"--env", "KUBECONFIG=/rootfs/var/lib/kops/kubeconfig",
		t.ProtokubeEnvironmentVariables(),
		t.ProtokubeImageName(),
		"/usr/bin/protokube",
	}...)
	protokubeCommand := strings.Join(dockerArgs, " ") + " " + protokubeFlagsArgs
	manifest := &systemd.Manifest{}
	manifest.Set("Unit", "Description", "Kubernetes Protokube Service")
	manifest.Set("Unit", "Documentation", "https://github.com/kubernetes/kops")
	manifest.Set("Service", "ExecStartPre", t.ProtokubeImagePullCommand())
	manifest.Set("Service", "ExecStart", protokubeCommand)
	manifest.Set("Service", "Restart", "always")
	manifest.Set("Service", "RestartSec", "2s")
	manifest.Set("Service", "StartLimitInterval", "0")
	manifest.Set("Install", "WantedBy", "multi-user.target")
	manifestString := manifest.Render()
	klog.V(8).Infof("Built service manifest %q\n%s", "protokube", manifestString)
	service := &nodetasks.Service{
		Name:       "protokube.service",
		Definition: s(manifestString),
	}
	service.InitDefaults()
	return service, nil
}
func ( t * ProtokubeBuilder ) buildSystemdService ( ) ( * nodetasks . Service , error ) { k8sVersion , err := util . ParseKubernetesVersion ( t . Cluster . Spec . KubernetesVersion ) if err != nil || k8sVersion == nil { return nil , fmt . Errorf ( " " , t . Cluster . Spec . KubernetesVersion ) } protokubeFlags , err := t . ProtokubeFlags ( * k8sVersion ) if err != nil { return nil , err } protokubeFlagsArgs , err := flagbuilder . BuildFlags ( protokubeFlags ) if err != nil { return nil , err } dockerArgs := [ ] string { " " , " " , " " , " " , " " , " " , " " , " " , } if t . IsMaster { dockerArgs = append ( dockerArgs , [ ] string { " " , t . KubectlPath ( ) + " " , " " , " " , } ... ) } dockerArgs = append ( dockerArgs , [ ] string { " " , " " , " " , " " , " " , t . ProtokubeEnvironmentVariables ( ) , t . ProtokubeImageName ( ) , " " , } ... ) protokubeCommand := strings . Join ( dockerArgs , " " ) + " " + protokubeFlagsArgs manifest := & systemd . Manifest { } manifest . Set ( " " , " " , " " ) manifest . Set ( " " , " " , " " ) manifest . Set ( " " , " " , t . ProtokubeImagePullCommand ( ) ) manifest . Set ( " " , " " , protokubeCommand ) manifest . Set ( " " , " " , " " ) manifest . Set ( " " , " " , " " ) manifest . Set ( " " , " " , " " ) manifest . Set ( " " , " " , " " ) manifestString := manifest . Render ( ) klog . V ( 8 ) . Infof ( " \n " , " " , manifestString ) service := & nodetasks . Service { Name : " " , Definition : s ( manifestString ) , } service . InitDefaults ( ) return service , nil }
buildSystemdService generates the manifest for the protokube service
buildSystemdService generates the manifest for the protokube service
// add kubectl only if a master // path changes depending on distro, and always mount it on /opt/kops/bin // kubectl is downloaded and installed by other tasks // Needed for mounting in a container (when using systemd mounting?) // We execute in the host namespace // @step: let need a dependency for any volumes to be mounted first