Skip to content

Commit cd2cd79

Browse files
authored
Harden the server pod & update the default server image (#39)
* chore(slog): use default slog handler Signed-off-by: Jian Zeng <[email protected]> * chore: update default server image Signed-off-by: Jian Zeng <[email protected]> * feat: harden the server pod Signed-off-by: Jian Zeng <[email protected]> --------- Signed-off-by: Jian Zeng <[email protected]>
1 parent cad54d6 commit cd2cd79

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmd/client/main.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,7 @@ service, ip and hostname rather than only pods.`,
238238
})
239239
}
240240

241-
h := slog.NewTextHandler(cmd.ErrOrStderr(), &slog.HandlerOptions{
242-
Level: slogutil.MapVerbosityToLogLevel(o.verbosity),
243-
})
244-
slog.SetDefault(slog.New(h))
241+
slog.SetLogLoggerLevel(slogutil.MapVerbosityToLogLevel(o.verbosity))
245242
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
246243
defer cancel()
247244
return o.Run(ctx, args)
@@ -258,9 +255,8 @@ service, ip and hostname rather than only pods.`,
258255
flags.BoolVarP(&printVersion, "version", "V", false, "Print version info and exit.")
259256
flags.StringVar(&o.address, "address", "127.0.0.1", "Address to listen on. Only accepts IP addresses as a value.")
260257
flags.StringVarP(&o.targetsFile, "file", "f", "", "Forward to the targets specified in the given file, with one target per line.")
261-
flags.StringVar(&o.serverImage, "server.image", "ghcr.io/knight42/krelay-server:v0.0.2", "The krelay-server image to use.")
258+
flags.StringVar(&o.serverImage, "server.image", "ghcr.io/knight42/krelay-server:v0.0.3", "The krelay-server image to use.")
262259
flags.StringVar(&o.serverNamespace, "server.namespace", metav1.NamespaceDefault, "The namespace in which krelay-server is located.")
263260
flags.IntVarP(&o.verbosity, "v", "v", 3, "Number for the log level verbosity. The bigger the more verbose.")
264-
265261
_ = c.Execute()
266262
}

cmd/client/utils.go

+9
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,20 @@ func createServerPod(ctx context.Context, cs kubernetes.Interface, svrImg, names
4646
},
4747
},
4848
Spec: corev1.PodSpec{
49+
AutomountServiceAccountToken: toPtr(false),
50+
EnableServiceLinks: toPtr(false),
51+
SecurityContext: &corev1.PodSecurityContext{
52+
RunAsNonRoot: toPtr(true),
53+
},
4954
Containers: []corev1.Container{
5055
{
5156
Name: constants.ServerName,
5257
Image: svrImg,
5358
ImagePullPolicy: corev1.PullAlways,
59+
SecurityContext: &corev1.SecurityContext{
60+
ReadOnlyRootFilesystem: toPtr(true),
61+
AllowPrivilegeEscalation: toPtr(false),
62+
},
5463
},
5564
},
5665
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{

0 commit comments

Comments
 (0)