abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
17.97k stars 368 forks source link

feat: add support for setting kubernetes server port (or automate based on profiles to avoid overlap) #467

Open dmccaffery opened 1 year ago

dmccaffery commented 1 year ago

Description

When starting two instances of colima, both with kubernetes enabled, they use the same server port mapped to the host (6443). Only the first instance is mapped correctly. When the kube config context is activated, it no longer works as the certificates do not align.

Expected:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0t...
    server: https://127.0.0.1:6443
  name: colima
- cluster:
    certificate-authority-data: LS0t...
    server: https://127.0.0.1:6444
  name: colima-backup

Actual:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0t...
    server: https://127.0.0.1:6443
  name: colima
- cluster:
    certificate-authority-data: LS0t...
    server: https://127.0.0.1:6443
  name: colima-backup

You can switch between the two by starting one and stopping the other, but it would be nice to be able to run different versions of kubernetes, or different instances at the same time to support a backup in demo / presentation settings.

abiosoft commented 1 year ago

If you start with network address enabled, it would avoid the clash.

But yeah, that's a good point you raised.

colima start --network-address
daBrian commented 4 months ago

In ~/.colima/{profile}/colima.yaml you can specify the port as described by @abiosoft (thank you for the hint)

#(...)
# 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: https://127.0.0.1:6444
#(...)