Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

Commit 1fdae8a

Browse files
fix: update kube security config (#5573)
1 parent b95b1ef commit 1fdae8a

File tree

7 files changed

+46
-23
lines changed

7 files changed

+46
-23
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ ENV FTL_CONTROLLER_CONSOLE_URL="*"
4141
# Provisioner-specific configurations
4242
ENV FTL_PROVISIONER_PLUGIN_CONFIG_FILE="/home/ubuntu/ftl-provisioner-config.toml"
4343

44+
USER 1000:1000
45+
4446
# Default command
4547
CMD ["/home/ubuntu/svc"]

Dockerfile.runner-jvm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ RUN mvn -B --version
1212
# Finally create the runtime image.
1313
FROM ftl0/ftl-runner:latest
1414

15-
WORKDIR /root/
15+
WORKDIR /jdk/
16+
USER root:root
1617

17-
ENV PATH="/root/jdk/bin:$PATH"
18-
ENV JAVA_HOME="/root/jdk"
19-
COPY --from=builder /hermit/pkg/openjdk-21.0.3_9/ /root/jdk/
18+
ENV PATH="/jdk/bin:$PATH"
19+
ENV JAVA_HOME="/jdk"
20+
COPY --from=builder /hermit/pkg/openjdk-21.0.3_9/ /jdk/
21+
RUN chown -R 1000:1000 /jdk
22+
23+
USER 1000:1000

backend/runner/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ func (s *Service) deploy(ctx context.Context, key key.Deployment, module *schema
424424
"./launch",
425425
ftlv1connect.NewVerbServiceClient,
426426
true,
427+
plugin.WithNoWorkingDir(),
427428
plugin.WithEnvars(
428429
envVars...,
429430
),

charts/ftl/templates/_helpers.tpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ securityContext:
131131
- "ALL"
132132
seccompProfile:
133133
type: RuntimeDefault
134-
runAsUser: 1000
135-
runAsGroup: 1000
136134
{{- end -}}
137135
{{- define "ftl.resources" -}}
138136
resources:

charts/ftl/templates/runner.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,17 @@ data:
106106
containerPort: {{ .Values.runner.port }}
107107
protocol: "TCP"
108108
{{- include "ftl.healthProbes" .Values.timeline | nindent 14 }}
109+
{{- include "ftl.securityContext" .Values.cron | nindent 14 }}
109110
volumeMounts:
110111
- mountPath: /home/ubuntu/.cache
111112
name: cache
113+
- mountPath: /tmp
114+
name: tmp
112115
volumes:
113116
- name: cache
114117
emptyDir: {}
118+
- name: tmp
119+
emptyDir: {}
115120
{{- include "ftl.commonPodConfig" .Values.runner | nindent 10 }}
116121
serviceAccountTemplate: |-
117122
apiVersion: v1

common/plugin/spawn.go

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type pluginOptions struct {
3030
envars []string
3131
additionalClients []func(baseURL string, opts ...connect.ClientOption)
3232
startTimeout time.Duration
33+
noWorkingDir bool
3334
}
3435

3536
// Option used when creating a plugin.
@@ -51,6 +52,13 @@ func WithStartTimeout(timeout time.Duration) Option {
5152
}
5253
}
5354

55+
func WithNoWorkingDir() Option {
56+
return func(po *pluginOptions) error {
57+
po.noWorkingDir = true
58+
return nil
59+
}
60+
}
61+
5462
// WithExtraClient connects to an additional gRPC service in the same plugin.
5563
//
5664
// The client instance is written to "out".
@@ -101,16 +109,18 @@ func Spawn[Client rpc.Pingable[Req, Resp, RespPtr], Req any, Resp any, RespPtr r
101109
}
102110
}
103111
workingDir := filepath.Join(dir, ".ftl")
104-
err = os.Mkdir(workingDir, 0700)
105-
if err != nil && !errors.Is(err, os.ErrExist) {
106-
return nil, nil, errors.WithStack(err)
107-
}
108-
109-
// Clean up previous process.
110112
pidFile := filepath.Join(workingDir, filepath.Base(exe)+".pid")
111-
err = cleanup(logger, pidFile)
112-
if err != nil {
113-
return nil, nil, errors.WithStack(err)
113+
if !opts.noWorkingDir {
114+
err = os.Mkdir(workingDir, 0700)
115+
if err != nil && !errors.Is(err, os.ErrExist) {
116+
return nil, nil, errors.WithStack(err)
117+
}
118+
119+
// Clean up previous process.
120+
err = cleanup(logger, pidFile)
121+
if err != nil {
122+
return nil, nil, errors.WithStack(err)
123+
}
114124
}
115125

116126
// Find a free port.
@@ -176,10 +186,12 @@ func Spawn[Client rpc.Pingable[Req, Resp, RespPtr], Req any, Resp any, RespPtr r
176186
}
177187
}()
178188

179-
// Write the PID file.
180-
err = os.WriteFile(pidFile, []byte(strconv.Itoa(cmd.Process.Pid)), 0600)
181-
if err != nil {
182-
return nil, nil, errors.WithStack(err)
189+
if !opts.noWorkingDir {
190+
// Write the PID file.
191+
err = os.WriteFile(pidFile, []byte(strconv.Itoa(cmd.Process.Pid)), 0600)
192+
if err != nil {
193+
return nil, nil, errors.WithStack(err)
194+
}
183195
}
184196

185197
// Wait for the plugin to start.

internal/artefacts/oci_registry.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func (s *OCIArtefactService) DownloadArtifacts(ctx context.Context, dest string,
386386
}
387387
var mode os.FileMode = 0600
388388
if artefact.Executable {
389-
mode = 0700
389+
mode = 0755
390390
}
391391
w, err := os.OpenFile(filepath.Join(dest, artefact.Path), os.O_CREATE|os.O_WRONLY, mode)
392392
if err != nil {
@@ -553,7 +553,6 @@ func createLayer(path string, artifacts []*schema.MetadataArtefact) (v1.Layer, e
553553
if err := tw.Close(); err != nil {
554554
return nil, errors.Wrapf(err, "failed to create layer")
555555
}
556-
557556
// TODO: use a file
558557
return tarball.LayerFromReader(&buf) //nolint
559558
}
@@ -576,15 +575,17 @@ func addFileToTar(tw *tar.Writer, basepath string, path string, execuable bool)
576575

577576
mode := int64(0644)
578577
if execuable {
579-
mode = 755
578+
mode = 0755
580579
}
581580

582581
// TODO: hard coded deployments path
583582
hdr := &tar.Header{
584-
Name: "/deployments/" + path,
583+
Name: "deployments/" + path,
585584
Mode: mode,
586585
Size: stat.Size(),
587586
ModTime: time.Now(),
587+
Uid: 1000,
588+
Gid: 1000,
588589
}
589590

590591
if err := tw.WriteHeader(hdr); err != nil {

0 commit comments

Comments
 (0)