@@ -41,25 +41,42 @@ const (
4141 registryConfigEnvName = "DRUID_RUNTIME_REGISTRY_CONFIG_JSON"
4242 registryConfigSecretKey = "config.json"
4343 registryConfigScript = `printf '%s' "$DRUID_RUNTIME_REGISTRY_CONFIG_JSON" > /tmp/druid-registry.json && exec druid --config /tmp/druid-registry.json "$@"`
44+ workerPullRootEnvName = "DRUID_WORKER_ROOT"
45+ workerPullScript = `set -eu
46+ if [ -n "${DRUID_RUNTIME_REGISTRY_CONFIG_JSON:-}" ]; then
47+ printf '%s' "$DRUID_RUNTIME_REGISTRY_CONFIG_JSON" > /tmp/druid-registry.json
48+ druid --config /tmp/druid-registry.json "$@"
49+ else
50+ druid "$@"
51+ fi
52+ chown -R 1000:1000 "$DRUID_WORKER_ROOT"`
4453)
4554
4655func workerPullJobSpec (namespace string , jobName string , pvc string , image string , action ports.RuntimeWorkerAction , imagePullSecret string , registryConfigSecret string , registryPlainHTTP bool ) * batchv1.Job {
4756 command := []string {
48- "druid" , "worker" , "pull" ,
57+ "sh" , "-c" , workerPullScript , "druid-worker-pull" ,
58+ "worker" , "pull" ,
4959 "--artifact" , action .Artifact ,
5060 "--runtime-id" , action .RuntimeID ,
5161 "--mode" , string (action .Mode ),
5262 "--root" , action .MountPath ,
5363 "--callback-url" , action .CallbackURL ,
5464 }
55- if registryConfigSecret != "" {
56- command = append ([]string {"sh" , "-c" , registryConfigScript , "sh" }, command [1 :]... )
57- }
5865 job := helperJobSpec (namespace , jobName , pvc , image , command , imagePullSecret , map [string ]string {
5966 labelComponent : "worker-pull" ,
6067 })
6168 container := & job .Spec .Template .Spec .Containers [0 ]
62- container .Env = append (container .Env , corev1.EnvVar {Name : "DRUID_WORKER_TOKEN" , Value : action .CallbackToken })
69+ runAsRoot := int64 (0 )
70+ runAsNonRoot := false
71+ container .SecurityContext = & corev1.SecurityContext {
72+ RunAsUser : & runAsRoot ,
73+ RunAsGroup : & runAsRoot ,
74+ RunAsNonRoot : & runAsNonRoot ,
75+ }
76+ container .Env = append (container .Env ,
77+ corev1.EnvVar {Name : "DRUID_WORKER_TOKEN" , Value : action .CallbackToken },
78+ corev1.EnvVar {Name : workerPullRootEnvName , Value : action .MountPath },
79+ )
6380 if registryConfigSecret != "" {
6481 container .Env = append (container .Env , corev1.EnvVar {
6582 Name : registryConfigEnvName ,
0 commit comments