Skip to content

Commit

Permalink
Update command string handling in K8s templates
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Dec 5, 2024
1 parent 6fe944e commit f82d70f
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 18 deletions.
12 changes: 6 additions & 6 deletions config/internal/bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions config/kubernetes-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Worker/Executor PV
apiVersion: v1
kind: PersistentVolume
metadata:
name: funnel-pv-{{.TaskId}}
labels:
app: funnel
taskId: {{.TaskId}}
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- allow-delete
- allow-overwrite
- region={{.Region}}
- file-mode=0755
csi:
driver: s3.csi.aws.com
volumeHandle: s3-csi-{{.TaskId}}
volumeAttributes:
bucketName: {{.Bucket}}
claimRef:
namespace: {{.Namespace}}
name: funnel-pvc-{{.TaskId}}
16 changes: 16 additions & 0 deletions config/kubernetes-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Worker/Executor PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: funnel-pvc-{{.TaskId}}
namespace: {{ .Namespace }}
labels:
app: funnel
taskId: {{.TaskId}}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
volumeName: funnel-pv-{{.TaskId}}
8 changes: 0 additions & 8 deletions funnel.config.yml

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ require (
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/olivere/elastic.v5 v5.0.86 h1:xFy6qRCGAmo5Wjx96srho9BitLhZl2fcnpuidPwduXM=
Expand Down
4 changes: 3 additions & 1 deletion website/content/docs/compute/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ funnel task create hello-world.json

# Storage Architecture

![K8s Storage](/img/k8s-pvc.png)
<a href="https://www.figma.com/board/bzgv8kVL2QKESU3Sqn7S1a/Funnel-%2B-Gen3?node-id=2-1059&t=9bcuG0bMAcxBLcRD-1">
<img title="K8s Storage" src="/img/k8s-pvc.png" />
</a>

# Additional Resources 📚

Expand Down
Binary file modified website/static/img/k8s-pvc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions worker/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"io"
"strings"
"text/template"

"github.com/ohsu-comp-bio/funnel/tes"
Expand All @@ -26,6 +27,7 @@ type KubernetesCommand struct {
Namespace string
Resources *tes.Resources
ServiceAccount string
Clientset kubernetes.Interface
Command
}

Expand All @@ -43,6 +45,11 @@ func (kcmd KubernetesCommand) Run(ctx context.Context) error {
if kcmd.StdinFile != "" {
command = append(command, "<", kcmd.StdinFile)
}
for i, v := range command {
if strings.Contains(v, " ") {
command[i] = fmt.Sprintf("'%s'", v)
}
}

var buf bytes.Buffer
err = tpl.Execute(&buf, map[string]interface{}{
Expand Down Expand Up @@ -74,9 +81,13 @@ func (kcmd KubernetesCommand) Run(ctx context.Context) error {
return err
}

clientset, err := getKubernetesClientset()
if err != nil {
return err
clientset := kcmd.Clientset
if clientset == nil {
var err error
clientset, err = getKubernetesClientset()
if err != nil {
return err
}
}

var client = clientset.BatchV1().Jobs(kcmd.Namespace)
Expand Down

0 comments on commit f82d70f

Please sign in to comment.