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

Tilt cannot connect to a cluster context that's not named "minikube" when using Colima and Minikube #6510

Open
adamlwatson opened this issue Feb 26, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@adamlwatson
Copy link

adamlwatson commented Feb 26, 2025

Expected Behavior

Running on a Macbook Pro M1 on OSX Sequoia 15.2, Colima and Minikube.

When I use the allow_k8s_contexts directive in a Tiltfile, I should be able to specify a local minikube cluster name that is prefixed with "minikube-".

Current Behavior

Instead, the only cluster name that seems to be allowed is simply "minikube". If I rename my current context to "minikube-test", or anything other than just "minikube", tilt doctor will show that the cluster cannot be found.

Also, specifiying the "allow_k8s_contexts" directive in the Tiltfile seems to just be ignored.

Steps to Reproduce

In the "tilt demo" repository:

  1. colima start
  2. minikube start
  3. kubectl config rename-context minikube minikube-test
  4. tilt up
  5. Notice that the build fails
  6. Add allow_k8s_contexts('minikube-test') to the Tiltfile
  7. tilt up
  8. Notice the build still fails

Context

tilt doctor Output

$ tilt doctor
Tilt: v0.33.22, built 2025-01-03
System: darwin-arm64
---
Docker (cluster)
- Host: [default]
- Server Version: Error: Could not read docker env from minikube.
Did you forget to run `minikube start`?

- API Version: Error: Could not read docker env from minikube.
Did you forget to run `minikube start`?

- Builder: Error: Could not read docker env from minikube.
Did you forget to run `minikube start`?

---
Docker (local)
- Host: unix:///Users/adamwatson/.colima/default/docker.sock
- Server Version: 24.0.9
- Version: 1.43
- Builder: 2
- Compose Version: v2.24.6
---
Kubernetes
- Env: minikube
- Context: minikube-test
- Cluster Name: minikube
- Namespace: rostr-development
- Container Runtime: docker
- Version: v1.28.3
- Cluster Local Registry: none
---
Thanks for seeing the Tilt Doctor!
Please send the info above when filing bug reports. 💗

The info below helps us understand how you're using Tilt so we can improve,
but is not required to ask for help.
---
Analytics Settings
--> (These results reflect your personal opt in/out status and may be overridden by an `analytics_settings` call in your Tiltfile)
- User Mode: opt-out
- Machine: 0cfb365d34cc0d5baab9ecf591a01e11
- Repo: F4wTCmBQzRGXa7ZQXqTUHQ==

colima config

> colima version
colima version 0.8.1
git commit: 96598cc5b64e5e9e1e64891642b91edc8ac49d16

runtime: docker
arch: aarch64
client: v26.1.4
server: v24.0.9

----- 

# Number of CPUs to be allocated to the virtual machine.
# Default: 2
cpu: 6

# Size of the disk in GiB to be allocated to the virtual machine.
# NOTE: value can only be increased after virtual machine has been created.
#
# Default: 100
disk: 100

# Size of the memory in GiB to be allocated to the virtual machine.
# Default: 2
memory: 12

# Architecture of the virtual machine (x86_64, aarch64, host).
#
# NOTE: value cannot be changed after virtual machine is created.
# Default: host
arch: aarch64

# Container runtime to be used (docker, containerd).
#
# NOTE: value cannot be changed after virtual machine is created.
# Default: docker
runtime: docker

# Set custom hostname for the virtual machine.
# Default: colima
#          colima-profile_name for other profiles
hostname: colima

# Kubernetes configuration for the virtual machine.
kubernetes:
  # Enable kubernetes.
  # Default: false
  enabled: false

  # Kubernetes version to use.
  # This needs to exactly match a k3s version https://github.com/k3s-io/k3s/releases
  # Default: latest stable release
  version: v1.28.3+k3s2

  # Additional args to pass to k3s https://docs.k3s.io/cli/server
  # Default: traefik is disabled
  k3sArgs:
    - --disable=traefik

# Auto-activate on the Host for client access.
# Setting to true does the following on startup
#  - sets as active Docker context (for Docker runtime).
#  - sets as active Kubernetes context (if Kubernetes is enabled).
# Default: true
autoActivate: true

# Network configurations for the virtual machine.
network:
  # Assign reachable IP address to the virtual machine.
  # NOTE: this is currently macOS only and ignored on Linux.
  # Default: false
  address: false

  # Custom DNS resolvers for the virtual machine.
  #
  # EXAMPLE
  # dns: [8.8.8.8, 1.1.1.1]
  #
  # Default: []
  dns: []

  # DNS hostnames to resolve to custom targets using the internal resolver.
  # This setting has no effect if a custom DNS resolver list is supplied above.
  # It does not configure the /etc/hosts files of any machine or container.
  # The value can be an IP address or another host.
  #
  # EXAMPLE
  # dnsHosts:
  #   example.com: 1.2.3.4
  dnsHosts: {}

  # Replicate host IP addresses in the VM. This enables port forwarding to specific
  # host IP addresses.
  #   e.g. `docker run --port 10.0.1.2:8080:8080 alpine` would only forward to the
  #   specified IP address.
  #
  # Default: false
  hostAddresses: false

# ===================================================================== #
# ADVANCED CONFIGURATION
# ===================================================================== #

# Forward the host's SSH agent to the virtual machine.
# Default: false
forwardAgent: false

# Docker daemon configuration that maps directly to daemon.json.
# https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file.
# NOTE: some settings may affect Colima's ability to start docker. e.g. `hosts`.
#
# EXAMPLE - disable buildkit
# docker:
#   features:
#     buildkit: false
#
# EXAMPLE - add insecure registries
# docker:
#   insecure-registries:
#     - myregistry.com:5000
#     - host.docker.internal:5000
#
# Colima default behaviour: buildkit enabled
# Default: {}
# docker:
#   insecure-registries:
#    - 192.168.106.5:32000
#    - microk8s:32000

# Virtual Machine type (qemu, vz)
# NOTE: this is macOS 13 only. For Linux and macOS <13.0, qemu is always used.
#
# vz is macOS virtualization framework and requires macOS 13
#
# NOTE: value cannot be changed after virtual machine is created.
# Default: qemu
vmType: vz

# Utilise rosetta for amd64 emulation (requires m1 mac and vmType `vz`)
# Default: false
rosetta: true

# Enable nested virtualization for the virtual machine (requires m3 mac and vmType `vz`)
# Default: false
nestedVirtualization: false

# Volume mount driver for the virtual machine (virtiofs, 9p, sshfs).
#
# virtiofs is limited to macOS and vmType `vz`. It is the fastest of the options.
#
# 9p is the recommended and the most stable option for vmType `qemu`.
#
# sshfs is faster than 9p but the least reliable of the options (when there are lots
# of concurrent reads or writes).
#
# NOTE: value cannot be changed after virtual machine is created.
# Default: virtiofs (for vz), sshfs (for qemu)
mountType: virtiofs

# Propagate inotify file events to the VM.
# NOTE: this is experimental.
mountInotify: true

# The CPU type for the virtual machine (requires vmType `qemu`).
# Options available for host emulation can be checked with: `qemu-system-$(arch) -cpu help`.
# Instructions are also supported by appending to the cpu type e.g. "qemu64,+ssse3".
# Default: host
cpuType: ""

# Custom provision scripts for the virtual machine.
# Provisioning scripts are executed on startup and therefore needs to be idempotent.
#
# EXAMPLE - script executed as root
# provision:
#   - mode: system
#     script: apt-get install htop vim
#
# EXAMPLE - script executed as user
# provision:
#   - mode: user
#     script: |
#       [ -f ~/.provision ] && exit 0;
#       echo provisioning as $USER...
#       touch ~/.provision
#
# Default: []
provision: []

# Modify ~/.ssh/config automatically to include a SSH config for the virtual machine.
# SSH config will still be generated in $COLIMA_HOME/ssh_config regardless.
# Default: true
sshConfig: true

# The port number for the SSH server for the virtual machine.
# When set to 0, a random available port is used.
#
# Default: 0
sshPort: 0

# Configure volume mounts for the virtual machine.
# Colima mounts user's home directory by default to provide a familiar
# user experience.
#
# EXAMPLE
# mounts:
#   - location: ~/secrets
#     writable: false
#   - location: ~/projects
#     writable: true
#
# Colima default behaviour: $HOME and /tmp/colima are mounted as writable.
# Default: []
mounts: []

# Specify a custom disk image for the virtual machine.
# When not specified, Colima downloads an appropriate disk image from Github at
# https://github.com/abiosoft/colima-core/releases.
# The file path to a custom disk image can be specified to override the behaviour.
#
# Default: ""
diskImage: ""

# Environment variables for the virtual machine.
#
# EXAMPLE
# env:
#   KEY: value
#   ANOTHER_KEY: another value
#
# Default: {}
env: {}

minikube config

> minikube version
minikube version: v1.33.1
commit: 5883c09216182566a63dff4c326a6fc9ed2982ff

-----
- cpus: 6
- disk-size: 100g
- insecure-registry: true
- memory: 11g

About Your Use Case

I use several development environments, and having to rename each one to "minikube" before using the context with Tilt is very cumbersome. Also, the docs state that you should be able to use any context prefixed with "minikube-" to have it auto-detected.

@adamlwatson adamlwatson added the bug Something isn't working label Feb 26, 2025
@nicks
Copy link
Member

nicks commented Feb 27, 2025

hello! thanks for the report! some additional details:

  • when you say "the build fails", what happens exactly? what error message do you see?
  • the Could not read docker env from minikube. part of your bug report is ... curious. Can you run minikube docker-env and post the output?

to answer your other questions - i would expect this to work out of the box. allow_k8s_contexts is for enabling remote clusters and wouldn't apply in this case.

@adamlwatson
Copy link
Author

Sure thing. When I say 'the build fails', I mean the Tiltfile is read but the context cannot be found. The actual error message in the console is:

Successfully loaded Tiltfile (10.428625ms)
Failed to connect to Docker: Could not read docker env from minikube.
Did you forget to run `minikube start`?

Here is the output of minikube docker-env:

> minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://127.0.0.1:32792"
export DOCKER_CERT_PATH="/Users/adamwatson/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube"

# To point your shell to minikube's docker-daemon, run:
# eval $(minikube -p minikube docker-env)

And of course, once I rename the context back to just simply "minikube", everything works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants