-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Users can create WebAssembly workloads that execute once leveraging the Command Trigger, which allows us to build and run Jobs and CronJobs in Kubernetes environments.
Although I was able to create the corresponding Kubernetes manifests manually, it is tedious to create full fledged manifests that use Runtime Configuration Files.
Being able to scaffold both Jobs and CronJobs would be very handy.
CLI Interface Suggestions
IMO, the most intuitive CLI interface would rely on using flags:
# Create a manifest of kind Job when --job is present
spin kube scaffold -f ttl.sh/job:12h --runtime-config-file ./rtc.toml --job
# Create a manifest of kind CronJob when --cron and --schedule are present
spin kube scaffold -f tt.sh/cronjob:12h --runtime-config-file ./rtc.toml --cron --schedule "* * * * *"
# Alternatively --cron could take the actual schedule as value
spin kube scaffold -f tt.sh/cronjob:12h --runtime-config-file ./rtc.toml --cron "* * * * *"As an alternative, job and cron could be defined as sub-commands of scaffold:
# Create a manifest of kind Job
spin kube scaffold job -f ttl.sh/job:12h --runtime-config-file ./rtc.toml
# Create a manifest of kind CronJob
spin kube scaffold cron -f tt.sh/cronjob:12h --runtime-config-file ./rtc.toml --schedule "* * * * *"Sample CronJob Manifest
See the following CronJob manifest for reference:
apiVersion: batch/v1
kind: CronJob
metadata:
name: wasm-cronjob
spec:
schedule: '* * * * *'
jobTemplate:
metadata:
name: wasm-cronjob
spec:
template:
spec:
runtimeClassName: wasmtime-spin-v2
containers:
- image: ttl.sh/wasm-cron:12h
command:
- /
name: main
volumeMounts:
- mountPath: /runtime-config.toml
name: spin-runtime-config
readOnly: true
subPath: runtime-config.toml
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-876nv
readOnly: true
restartPolicy: OnFailure
volumes:
- name: spin-runtime-config
secret:
defaultMode: 420
items:
- key: runtime-config.toml
path: runtime-config.toml
optional: true
secretName: api-runtime-config
- name: kube-api-access-876nv
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespacechokosabe
Metadata
Metadata
Assignees
Labels
No labels