Skip to content

Commit

Permalink
fix: volumes mount for python job (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
italux authored Feb 25, 2021
1 parent 722a0b0 commit 4e1c4d5
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions cli/cmd/kubernetes/job/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@ package job
import (
"fmt"

"github.com/VerizonMedia/kubectl-flame/cli/cmd/data"
"github.com/VerizonMedia/kubectl-flame/cli/cmd/version"
batchv1 "k8s.io/api/batch/v1"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"

"github.com/VerizonMedia/kubectl-flame/cli/cmd/data"
"github.com/VerizonMedia/kubectl-flame/cli/cmd/version"
)

type pythonCreator struct{}

func (p *pythonCreator) create(targetPod *apiv1.Pod, cfg *data.FlameConfig) (string, *batchv1.Job, error) {
id := string(uuid.NewUUID())
var imageName string
args := []string{
id,
string(targetPod.UID),
cfg.TargetConfig.ContainerName,
cfg.TargetConfig.ContainerId,
cfg.TargetConfig.Duration.String(),
string(cfg.TargetConfig.Language),
cfg.TargetConfig.Pgrep,
}

if cfg.TargetConfig.Image != "" {
imageName = cfg.TargetConfig.Image
} else {
Expand Down Expand Up @@ -51,22 +62,30 @@ func (p *pythonCreator) create(targetPod *apiv1.Pod, cfg *data.FlameConfig) (str
Template: apiv1.PodTemplateSpec{
ObjectMeta: commonMeta,
Spec: apiv1.PodSpec{
HostPID: true,
HostPID: true,
Volumes: []apiv1.Volume{
{
Name: "target-filesystem",
VolumeSource: apiv1.VolumeSource{
HostPath: &apiv1.HostPathVolumeSource{
Path: cfg.TargetConfig.DockerPath,
},
},
},
},
InitContainers: nil,
Containers: []apiv1.Container{
{
ImagePullPolicy: apiv1.PullAlways,
Name: ContainerName,
Image: imageName,
Command: []string{"/app/agent"},
Args: []string{
id,
string(targetPod.UID),
cfg.TargetConfig.ContainerName,
cfg.TargetConfig.ContainerId,
cfg.TargetConfig.Duration.String(),
string(cfg.TargetConfig.Language),
cfg.TargetConfig.Pgrep,
Args: args,
VolumeMounts: []apiv1.VolumeMount{
{
Name: "target-filesystem",
MountPath: "/var/lib/docker",
},
},
SecurityContext: &apiv1.SecurityContext{
Privileged: boolPtr(true),
Expand Down

0 comments on commit 4e1c4d5

Please sign in to comment.