Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit 6e86796

Browse files
committed
[WIP] Experiment with option to link kmsg
THe current approach to link `/dev/kmsg` to `/dev/console` only works on images that we build ourselves. Let's see if we can mess with the running container and create the link at runtime / on the fly. As this is fixed in kind already [0], we can remove that hack probably when kind 0.5.0 is out. Why is this linking even needed? See also [0]! [0]: kubernetes-sigs/kind#662
1 parent d1bad52 commit 6e86796

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

entrypoint.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,45 @@ kind::start::fromSource() {
239239
# create the node image
240240
GOPATH="$(pwd)/go" \
241241
kind build node-image --image "$imageName"
242-
kind::hack::inject_kmsg_linking "$imageName"
242+
# kind::hack::inject_kmsg_linking "$imageName"
243243

244244
# bring up kind
245+
kind::hack::kmsg_linker "$clusterName" &
245246
kind create cluster --config "$KIND_CONFIG" --image "$imageName" --name "$clusterName" --loglevel "$loglevel" --retain
246247

247248
# get the (compiled) version of kubectl
248249
cp ./go/src/k8s.io/kubernetes/_output/dockerized/bin/linux/amd64/kubectl ./bin/kubectl
249250
}
250251

252+
kind::hack::kmsg_linker() {
253+
local node clusterName sleepDur
254+
255+
clusterName="$1"
256+
sleepDur="1s"
257+
258+
while sleep "$sleepDur"
259+
do
260+
echo '### trying to link'
261+
262+
node="$(kind get nodes --name "$clusterName")" || continue
263+
264+
docker exec "$node" sh -c \
265+
'set -e; [ ! -e /dev/kmsg ] && ln -s /dev/console /dev/kmsg' \
266+
|| continue
267+
268+
break
269+
done
270+
271+
echo "### linking worked"
272+
}
273+
251274
# Start kind with the (latest) node image published by kind upstream
252275
kind::start::fromUpstream() {
253276
local clusterName="$1"
254277

255278
log::warn "no k8s source found, using newest node image from kind upstream"
256279

280+
kind::hack::kmsg_linker "$clusterName" &
257281
kind create cluster --config "$KIND_CONFIG" --name "$clusterName" --loglevel "$loglevel" --retain
258282

259283
# get kubectl from upstream

0 commit comments

Comments
 (0)