func createPodManifest()

in dev-tools/mage/kubernetes/kuberemote.go [416:506]


func createPodManifest(name string, image string, env map[string]string, cmd []string, workDir string, destDir string, secretName string, svcAccName string) *apiv1.Pod {
	execEnv := []apiv1.EnvVar{
		apiv1.EnvVar{
			Name: "NODE_NAME",
			ValueFrom: &apiv1.EnvVarSource{
				FieldRef: &apiv1.ObjectFieldSelector{
					FieldPath: "spec.nodeName",
				},
			},
		},
	}
	for k, v := range env {
		execEnv = append(execEnv, apiv1.EnvVar{
			Name:  k,
			Value: v,
		})
	}
	return &apiv1.Pod{
		ObjectMeta: metav1.ObjectMeta{
			Name: name,
		},
		Spec: apiv1.PodSpec{
			ServiceAccountName: svcAccName,
			HostNetwork:        true,
			DNSPolicy:          apiv1.DNSClusterFirstWithHostNet,
			RestartPolicy:      apiv1.RestartPolicyNever,
			InitContainers: []apiv1.Container{
				{
					Name:  "sync-init",
					Image: "ernoaapa/sshd-rsync",
					Ports: []apiv1.ContainerPort{
						{
							Name:          "ssh",
							Protocol:      apiv1.ProtocolTCP,
							ContainerPort: 22,
						},
					},
					Env: []apiv1.EnvVar{
						{
							Name:  "ONE_TIME",
							Value: "true",
						},
					},
					VolumeMounts: []apiv1.VolumeMount{
						{
							Name:      "ssh-config",
							MountPath: "/root/.ssh/authorized_keys",
							SubPath:   "authorized_keys",
						},
						{
							Name:      "destdir",
							MountPath: destDir,
						},
					},
				},
			},
			Containers: []apiv1.Container{
				{
					Name:       "exec",
					Image:      image,
					Command:    cmd,
					WorkingDir: workDir,
					Env:        execEnv,
					VolumeMounts: []apiv1.VolumeMount{
						{
							Name:      "destdir",
							MountPath: destDir,
						},
					},
				},
			},
			Volumes: []apiv1.Volume{
				{
					Name: "ssh-config",
					VolumeSource: apiv1.VolumeSource{
						Secret: &apiv1.SecretVolumeSource{
							SecretName:  secretName,
							DefaultMode: &mode,
						},
					},
				},
				{
					Name: "destdir",
					VolumeSource: apiv1.VolumeSource{
						EmptyDir: &apiv1.EmptyDirVolumeSource{},
					},
				},
			},
		},
	}
}