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

kubelet may detect GCE when running kind on GCE #426

Closed
BenTheElder opened this issue Apr 2, 2019 · 5 comments
Closed

kubelet may detect GCE when running kind on GCE #426

BenTheElder opened this issue Apr 2, 2019 · 5 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@BenTheElder
Copy link
Member

What happened: kubelet appears to have read /sys/class/dmi/id/product_name when running kind on GCE and detected "Google Compute Engine", it appears to fail if it can't talk to the metadata server.

What you expected to happen: Kubernetes should not "be in cloud mode" so to speak.

How to reproduce it (as minimally and precisely as possible): run a kind cluster on GCE

Anything else we need to know?:

Environment:

  • kind version: (use kind version): 0.2.1
  • Kubernetes version: (use kubectl version): 1.13.4
  • Docker version: (use docker info):
  • OS (e.g. from /etc/os-release):
@BenTheElder BenTheElder added the kind/bug Categorizes issue or PR as related to a bug. label Apr 2, 2019
@BenTheElder
Copy link
Member Author

BenTheElder commented Apr 3, 2019

/assign

we should probably try to properly set cloud provider to none by default AND/OR always mount a special product_name by default.

current workaround:

# create a fake entry with our own "product name" to 
# mount at /sys/class/dmi/id/product_name
echo "kind" >./product_name

# create a kind cluster config equivalent to the current 
# default, but additionally mounting the above file
cat <<EOF >"./kind-config.yaml"
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
  extraMounts:
  - containerPath: /sys/class/dmi/id/product_name
    hostPath: ${PWD}/product_name
EOF

# when creating a cluster be sure to use
# this config with  `--config=./kind-config.yaml`
kind create cluster --config=./kind-config.yaml

...

@BenTheElder BenTheElder added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Apr 3, 2019
@BenTheElder BenTheElder added this to the 0.3 milestone Apr 3, 2019
@BenTheElder
Copy link
Member Author

This seems to be one of the blockers for #182.

@aojea
Copy link
Contributor

aojea commented Apr 22, 2019

kind remounts the /sys folder in the nodes as ro

if err := n.Command("mount", "-o", "remount,ro", "/sys").Run(); err != nil {
thus we can´t rewrite the file.

However, seems that kubernetes only uses the /sys/class/dmi/id/product_name to check if is running on a GCE VM
https://github.com/kubernetes/kubernetes/blob/716344fd7d68f92d9a16280be1feae0ffe122bb4/pkg/credentialprovider/gcp/metadata.go#L47 when using the GCP credential provider.

@BenTheElder I´m not familiar with the credential provider feature, is it possible to disable it?

@aojea
Copy link
Contributor

aojea commented Apr 25, 2019

Ben´s idea works
echo kind > /kind/product_name && mount -o ro,bind /kind/product_name /sys/class/dmi/id/product_name

@BenTheElder
Copy link
Member Author

fixed by #461

stg-0 pushed a commit to stg-0/kind that referenced this issue Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants