Skip to content

"fleet apply --output" fails on empty kubeconfig #5426

Description

@mearsten

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Take an valid empty kubeconfig, then try to render a bundle locally. Fleet CLI is supposed to work with no k8s cluster accessible:

% cat kubeconfig-empty.yaml
apiVersion: v1
kind: Config
preferences: {}
clusters: []
users: []
contexts: []

% env KUBECONFIG=kubeconfig-empty.yaml ./fleet-linux-amd64-0.15.4 apply -o bundle.yaml some ./some || echo "rc=$?"
rc=1

% env KUBECONFIG=kubeconfig-empty.yaml ./fleet-linux-amd64-0.16.0-rc.4 apply -o bundle.yaml some ./some || echo "rc=$?"
rc=1

% ls -l bundle.yaml
"bundle.yaml": No such file or directory (os error 2)

% ./fleet-linux-amd64-0.15.4 --version; ./fleet-linux-amd64-0.16.0-rc.4 --version
fleet version v0.15.4 (7b97db764df7de385e0572eab6da959e0bd22569)
fleet version v0.16.0-rc.4 (4b6976899c8cfc16317e7e5d610c74caa56ddd34)

It is working fine with a dummy cluster added:

% cat kubeconfig-dummy.yaml
apiVersion: v1
kind: Config
preferences: {}
clusters:
  - {name: dummy, cluster: {server: whatever}}
contexts:
  - {name: dummy, context: {cluster: dummy}}
current-context: dummy

% env KUBECONFIG=kubeconfig-dummy.yaml ./fleet-linux-amd64-0.15.4 apply -o bundle.yaml some ./some || echo "rc=$?"

% ls -l bundle.yaml
.rw------- 86k user 10 Jul 13:30 bundle.yaml

Expected Behavior

fleet apply -o bundle.yaml … should produce output with valid empty kubeconfig.

Steps To Reproduce

All info is in the "Current behaviour" section.

Environment

- Architecture: amd64
- Fleet Version: 0.15.4, 0.16.0-rc.4
- Cluster: N/A

Logs

Anything else?

It seems the CLI tries to detect whether it is run locally or in a pod and fails:

% env KUBECONFIG=kubeconfig-empty.yaml strace -et=%file -es=none -eq=all -s99999 -f ./fleet-linux-amd64-0.15.4 apply -o bundle.yaml some ./some
…
[pid 1617654] openat(AT_FDCWD, "kubeconfig-empty.yaml", O_RDONLY|O_CLOEXEC) = 3
[pid 1617654] newfstatat(AT_FDCWD, "/var/run/secrets/kubernetes.io/serviceaccount/token", 0xc0007cd628, 0) = -1 ENOENT (No such file or directory)

It shouldn't do that check if run with -o / --output option.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions