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

pull/1215/head^2
Thorsten Klein 1 year ago committed by GitHub
parent 88c5f18792
commit 8d54019838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/release.yaml
  2. 19
      pkg/client/node.go
  3. 1
      pkg/types/env.go
  4. 8
      pkg/types/fixes/assets/k3d-entrypoint-mounts.sh
  5. 7
      pkg/types/fixes/fixes.go

@ -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/')

@ -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
}

@ -39,4 +39,5 @@ const (
// Fixes
K3dEnvFixCgroupV2 = "K3D_FIX_CGROUPV2"
K3dEnvFixDNS = "K3D_FIX_DNS"
K3dEnvFixMounts = "K3D_FIX_MOUNTS"
)

@ -0,0 +1,8 @@
#!/bin/sh
set -o errexit
set -o nounset
echo "[$(date -Iseconds)] [Mounts] Fixing Mountpoints..."
mount --make-rshared /

@ -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
@ -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

Loading…
Cancel
Save