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

extraMounts does not sync between host and kube node #3674

Open
vitalik opened this issue Jun 30, 2024 · 3 comments
Open

extraMounts does not sync between host and kube node #3674

vitalik opened this issue Jun 30, 2024 · 3 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@vitalik
Copy link

vitalik commented Jun 30, 2024

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: mycluster
nodes:
- role: control-plane
  extraMounts:
    - hostPath: /home/ubuntu/.docker/config.json
      containerPath: /var/lib/kubelet/config.json

when I create this cluster - it works fine - my k8s can pull images from private repo

but over time (I guess once docker re-authenticates on host machine and /home/ubuntu/.docker/config.json changes) it no longer able to pull images

when I docker shell into node I see that /var/lib/kubelet/config.json does not match the host config...

so extraMounts does only one time sync ? how to make it work as usuakl docker volume mounts ?

@vitalik vitalik added the kind/support Categorizes issue or PR as a support question. label Jun 30, 2024
@vitalik
Copy link
Author

vitalik commented Jun 30, 2024

I guess /var shadowing /var/lib/kublet/config.json volume ?

docker inspect mycluster-control-plane
...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "adf6381bc73c8af0588f7fb8ed00aebc56790e7d66430389df00b46e040827d2",
                "Source": "/var/lib/docker/volumes/adf6381bc73c8af0588f7fb8ed00aebc56790e7d66430389df00b46e040827d2/_data",
                "Destination": "/var",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "/home/ubuntu/.docker/config.json",
                "Destination": "/var/lib/kubelet/config.json",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },

what's the solution ? how can I keep something in sync with host that mounted on /var/xxx inside kube node ?

@aojea
Copy link
Contributor

aojea commented Jun 30, 2024

Try to mount it in a different folder , one that is not being shadowed kubernetes/kubernetes#115389

@BenTheElder
Copy link
Member

I think this would work with a directory instead of a file, or as mentioned you can mount at a different path (there are multiple kubelet reads, I'm not actually sure where that is documented but the code is here https://github.com/kubernetes/kubernetes/blob/688c1c3b5e7ff344524bc11d5dc9b3f7dbeccd93/pkg/credentialprovider/config.go#L38)

FWIW I Recommend using imagepullSecrets instead (which can be set on the namespace without mutating the pod) https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

3 participants