Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: K3D_FIX_MOUNTS fix to make / rshared (e.g. to make Cilium work) #1268

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
run: make ci-setup
# Go Build
- name: Build k3d Binary
run: make build-cross
run: make gen-checksum build-cross
# Wait for tests to pass and create release (ONLY ON TAG)
- name: Wait for tests to succeed
if: startsWith(github.ref, 'refs/tags/')
Expand Down
19 changes: 19 additions & 0 deletions pkg/client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,25 @@ func enableFixes(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node,
},
})
}

if fixes.FixEnabled(fixes.EnvFixMounts) {
l.Log().Debugf(">>> enabling mounts magic")

if nodeStartOpts.NodeHooks == nil {
nodeStartOpts.NodeHooks = []k3d.NodeHook{}
}

nodeStartOpts.NodeHooks = append(nodeStartOpts.NodeHooks, k3d.NodeHook{
Stage: k3d.LifecycleStagePreStart,
Action: actions.WriteFileAction{
Runtime: runtime,
Content: fixes.MountsEntrypoint,
Dest: "/bin/k3d-entrypoint-mounts.sh",
Mode: 0744,
Description: "Write entrypoint script for mounts fix",
},
})
}
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/types/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ const (
// Fixes
K3dEnvFixCgroupV2 = "K3D_FIX_CGROUPV2"
K3dEnvFixDNS = "K3D_FIX_DNS"
K3dEnvFixMounts = "K3D_FIX_MOUNTS"
)
8 changes: 8 additions & 0 deletions pkg/types/fixes/assets/k3d-entrypoint-mounts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -o errexit
set -o nounset

echo "[$(date -Iseconds)] [Mounts] Fixing Mountpoints..."

mount --make-rshared /
7 changes: 6 additions & 1 deletion pkg/types/fixes/fixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ type K3DFixEnv string

const (
EnvFixCgroupV2 K3DFixEnv = k3d.K3dEnvFixCgroupV2 // EnvFixCgroupV2 is the environment variable that k3d will check for to enable/disable the cgroupv2 workaround
EnvFixDNS K3DFixEnv = k3d.K3dEnvFixDNS // EnvFixDNS is the environment variable that check for to enable/disable the application of network magic related to DNS
EnvFixDNS K3DFixEnv = k3d.K3dEnvFixDNS // EnvFixDNS is the environment variable that k3d will check for to enable/disable the application of network magic related to DNS
EnvFixMounts K3DFixEnv = k3d.K3dEnvFixMounts // EnvFixMounts is the environment variable that k3d will check for to enable/disable the fixing of mountpoints
)

var FixEnvs []K3DFixEnv = []K3DFixEnv{
EnvFixCgroupV2,
EnvFixDNS,
EnvFixMounts,
}

//go:embed assets/k3d-entrypoint-cgroupv2.sh
Expand All @@ -57,6 +59,9 @@ var CgroupV2Entrypoint []byte
//go:embed assets/k3d-entrypoint-dns.sh
var DNSMagicEntrypoint []byte

//go:embed assets/k3d-entrypoint-mounts.sh
var MountsEntrypoint []byte

//go:embed assets/k3d-entrypoint.sh
var K3DEntrypoint []byte

Expand Down