Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[BUG] Unable to create cluster when using go get to install k3d #565

Closed
FedericoAntoniazzi opened this issue Apr 18, 2021 · 4 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@FedericoAntoniazzi
Copy link

What did you do

I've upgraded k3d to v4.4.1 using go get -u github.com/rancher/k3d/[email protected] but when I try to create a new cluster using k3d cluster create I get the following error:

WARN[0000] No node filter specified
FATA[0000] Portmapping '[]' lacks a node filter, but there's more than one node
  • How was the cluster created?

    • k3d cluster create
  • What did you do afterwards?

    • Tried using a config file but nothing changed
    • k3d node list but it's empty

What did you expect to happen

I expect a new cluster to be created and ready to be used.

Screenshots or terminal output

❯ k3d cluster create mycluster
WARN[0000] No node filter specified                     
FATA[0000] Portmapping '[]' lacks a node filter, but there's more than one node 
❯ k3d cluster create mycluster --trace
DEBU[0000] Selected runtime is 'docker.Docker' on GOOS 'linux/amd64' 
DEBU[0000] Configuration:
agents: 0
image: docker.io/rancher/k3s:v1.20.0-k3s2
network: ""
options:
  k3d:
    disablehostipinjection: false
    disableimagevolume: false
    disableloadbalancer: false
    disablerollback: false
    timeout: 0s
    wait: true
  k3s:
    extraagentargs: '[]'
    extraserverargs: '[]'
  kubeconfig:
    switchcurrentcontext: true
    updatedefaultkubeconfig: true
  runtime:
    agentsmemory: ""
    gpurequest: ""
    serversmemory: ""
registries:
  config: ""
  create: false
  use: '[]'
servers: 1
token: "" 
DEBU[0000] Additional CLI Configuration:
cli:
  api-port: ""
  env: '[]'
  labels: '[]'
  ports: '[]'
  volumes: '[]' 
DEBU[0000] ========== Simple Config ==========
{TypeMeta:{Kind: APIVersion:} Name: Servers:1 Agents:0 ExposeAPI:{Host: HostIP: HostPort:} Image:docker.io/rancher/k3s:v1.20.0-k3s2 Network: ClusterToken: Volumes:[] Ports:[] Labels:[] Options:{K3dOptions:{Wait:true Timeout:0s DisableLoadbalancer:false DisableImageVolume:false NoRollback:false PrepDisableHostIPInjection:false NodeHookActions:[]} K3sOptions:{ExtraServerArgs:[[]] ExtraAgentArgs:[[]]} KubeconfigOptions:{UpdateDefaultKubeconfig:true SwitchCurrentContext:true} Runtime:{GPURequest: ServersMemory: AgentsMemory:}} Env:[] Registries:{Use:[[]] Create:false Config:}}
========================== 
DEBU[0000] Port Exposure Mapping didn't specify hostPort, choosing one randomly... 
DEBU[0000] Got free port for Port Exposure: '39359'     
TRAC[0000] VolumeFilterMap: map[[]:[]]                  
TRAC[0000] PortFilterMap: map[[]:[]]                    
TRAC[0000] LabelFilterMap: map[[]:[]]                   
TRAC[0000] EnvFilterMap: map[[]:[]]                     
DEBU[0000] ========== Merged Simple Config ==========
{TypeMeta:{Kind: APIVersion:} Name: Servers:1 Agents:0 ExposeAPI:{Host: HostIP:0.0.0.0 HostPort:39359} Image:docker.io/rancher/k3s:v1.20.0-k3s2 Network: ClusterToken: Volumes:[{Volume:[] NodeFilters:[]}] Ports:[{Port:[] NodeFilters:[]}] Labels:[{Label:[] NodeFilters:[]}] Options:{K3dOptions:{Wait:true Timeout:0s DisableLoadbalancer:false DisableImageVolume:false NoRollback:false PrepDisableHostIPInjection:false NodeHookActions:[]} K3sOptions:{ExtraServerArgs:[[]] ExtraAgentArgs:[[]]} KubeconfigOptions:{UpdateDefaultKubeconfig:true SwitchCurrentContext:true} Runtime:{GPURequest: ServersMemory: AgentsMemory:}} Env:[{EnvVar:[] NodeFilters:[]}] Registries:{Use:[[]] Create:false Config:}}
========================== 
WARN[0000] No node filter specified                     
FATA[0000] Portmapping '[]' lacks a node filter, but there's more than one node 

Which OS & Architecture

  • Arch Linux, amd64

Which version of k3d

k3d version v4-dev
k3s version v1.20.0-k3s2 (default)

Which version of docker

❯ docker version
Client:
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c28948e
 Built:             Mon Apr 12 14:10:41 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.3
  Git commit:       8728dd246c
  Built:            Mon Apr 12 14:10:25 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e.m
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
❯ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-tp-docker)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.6
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e.m
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.11.15-zen1-2-zen
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.47GiB
 Name: dev
 ID: S7DW:V43R:JF3Y:SGJL:LDF3:CUCI:TSET:EYL5:FM2E:3ZAI:LJRJ:FKS5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No kernel memory limit support
WARNING: No oom kill disable support
@FedericoAntoniazzi FedericoAntoniazzi added the bug Something isn't working label Apr 18, 2021
@iwilltry42 iwilltry42 added this to the v4.4.3 milestone Apr 26, 2021
@iwilltry42
Copy link
Member

Hi @FedericoAntoniazzi , thanks for opening this issue!
This looks like a problem with the Cobra/Viper modules used for CLI/Config 🤔

The []s should not be quoted in the config output. E.g.

  k3s:
    extraagentargs: '[]'
    extraserverargs: '[]'

should actually be

  k3s:
    extraagentargs: []
    extraserverargs: []

The way it happens to be in your case, the brackets will be treated as text/string instead of array/slice.
I cannot reproduce this on my Ubuntu and Windows machines 🤔
Does the problem still exist with k3d v4.4.2?

@iwilltry42 iwilltry42 self-assigned this Apr 26, 2021
@FedericoAntoniazzi
Copy link
Author

Hi @iwilltry42, thank you for your reply.

I've just tried compiling k3d on my pc and installing using curl/wget, both methods work. On the other hand, using go get -u github.com/rancher/k3d/[email protected] causes the issue discussed in this topic so I don't think it's a k3d problem.

Extra notes:

The README.md and k3d.io include the installation using go install github.com/rancher/k3d but it doesn't work. Here's why:

❯ go install github.com/rancher/k3d
go install: version is required when current directory is not in a module
	Try 'go install github.com/rancher/k3d@latest' to install the latest version

so I append @v4.4.2

❯ go install github.com/rancher/[email protected]
go install github.com/rancher/[email protected]: github.com/rancher/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4

Looking at the go.mod file, it has /v4 after the module's name and I try to add it to the install command

ust be compatible: should be v0 or v1, not v4
❯ go install github.com/rancher/k3d/[email protected]
go install github.com/rancher/k3d/[email protected]: github.com/rancher/k3d/[email protected]
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

I don't know a lot about go packages but the go.mod file contains a replace at the end and I think this is causing that problem
https://github.com/rancher/k3d/blob/bfcac7ec4a92b436a9c8bd20250b0a7704a934a6/go.mod#L53

@iwilltry42
Copy link
Member

You're actually right there.
We're currently using a Viper Fork as we're waiting for a PR to be merged upstream.
Since go get doesn't honor replace directives (golang/go#30354), this fails when using the go get install method.
As mentioned, this is intended to be temporary, so I hope that go getting k3d for installation will work again soon.

@FedericoAntoniazzi
Copy link
Author

Thank you @iwilltry42. Shall I close the issue and edit the title since this is not a bug?

@FedericoAntoniazzi FedericoAntoniazzi changed the title [BUG] Unable to create cluster [BUG] Unable to create cluster when using go get to install k3d Apr 26, 2021
@k3d-io k3d-io locked and limited conversation to collaborators Apr 26, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants