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

kubeconfig: unbound variable #46

Open
pizzapim opened this issue Nov 26, 2023 · 5 comments · May be fixed by #49
Open

kubeconfig: unbound variable #46

pizzapim opened this issue Nov 26, 2023 · 5 comments · May be fixed by #49

Comments

@pizzapim
Copy link
Contributor

Hi, I wanted to try Kubenix, but I couldn't get the example to work. I have the following flake taken from the examples:

{
  inputs.kubenix.url = "github:hall/kubenix";
  outputs = { self, ... }@inputs:
    let system = "x86_64-linux";
    in {
      kubenix = inputs.kubenix.packages.${system}.default.override {
        module = { kubenix, ... }: {
          imports = [ kubenix.modules.k8s ];
          kubernetes.resources.pods.example.spec.containers.nginx.image =
            "nginx";
        };
      };
    };
}

Then I use nix run .#kubenix, which produces:

error: builder for '/nix/store/7v7s2h891xicsa9bcijvsb6016aj82fk-kubenix.drv' failed with exit code 1;
       last 1 log lines:
       > /build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 8: kubeconfig: unbound variable
       For full logs, run 'nix log /nix/store/7v7s2h891xicsa9bcijvsb6016aj82fk-kubenix.drv'.
@hall
Copy link
Owner

hall commented Nov 27, 2023

Thanks for reporting, @pizzapim!

This error is because executing the kubenix package through nix run attempts to apply resources to a target cluster while something like nix build will only evaluate the output to ./result without touching any target cluster. So the former needs kubernetes.kubeconfig while the latter does not.

I do think we could throw a better error message though (and probably update the README.md CLI section to show more than a vague import ./cluster) so I'll leave this open to at least track that.

@pizzapim
Copy link
Contributor Author

Thanks for the reply, that makes total sense. Mentioning the kubeconfig option in the README would be useful for new users.

@zarelit
Copy link

zarelit commented Dec 8, 2023

I got the same error in the beginning as well. @hall many other tools rely on kubectl being "already configured" so maybe it makes sense to have $HOME/.kube/config as the default for kubernetes.kubeconfig option?

@hall hall linked a pull request Dec 10, 2023 that will close this issue
@hall hall linked a pull request Dec 10, 2023 that will close this issue
@hall
Copy link
Owner

hall commented Dec 10, 2023

Hey @zarelit! I agree that'd be a sensible default. I've started a PR to do just that.

@adrian-gierakowski
Copy link
Contributor

just got bitten by it as well trying to help with another issues :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants