Skip to content

Fix --kubeconfig flag priority #15

@burtonr

Description

@burtonr

The kubeconfig flag on the app install command does not affect the actual kubernetes command execution. The kubernetes command is executed against the default kubeconfig file, not the one passed in via flags.

Expected Behaviour

Passing the kubeconfig flag on the app install command should use that kubeconfig file when installing the app.

Current Behaviour

The kubeconfig variable is only written out, but not utilized:
https://github.com/alexellis/k3sup/blob/master/pkg/cmd/openfaas_app.go#L42

Possible Solution

Since the kubernetes_exec.go file is also in the cmd package, it's possible for the kubectl and kubectlTask functions to look for changes on the flag to get that passed in value. Much the same as the above pasted code from one of the apps.

Steps to Reproduce (for bugs)

  1. k3sup app install openfaas --kubeconfig any/path/to/file
  2. Output will say something like: "Using kubeconfig {the path from above}"
  3. Run kubectl get pods --all-namespaces --kubeconfig /same/path/above
  4. Observe the app was not installed
  5. Run kubectl get pods --all-namespaces (without the kubeconfig)
  6. See the application was installed on the incorrect cluster

Context

I have several k8s cluster set up in various environments for testing. Swapping the config files, or env var is annoying, and really time consuming if I forget before I run the install command.

Your Environment

  • What OS or type or VM are you using? Where is it hosted?
    Linux/ARM
    Desktop (microk8s), GCP, DigitalOcean, Raspberry Pi 3+
  • Operating System and version (e.g. Linux, Windows, MacOS):
    Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions