add-k8s ignores KUBECONFIG env var if ~/.kube/config exists
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Triaged
|
Undecided
|
Harry Pidcock |
Bug Description
If I run `juju add-k8s` with the KUBECONFIG environment variable set, that variable seems to be ignored, but only if a kubeconfig exists in the default ~/.kube/config location.
I have the environment variable set, and kubectl commands work:
$ echo $KUBECONFIG
/home/gkk/
$ kubectl get po
No resources found in default namespace.
But juju add-k8s fails:
$ juju add-k8s --client k8s --skip-storage
ERROR making juju admin credentials in cluster: ensuring cluster role "juju-credentia
The 10.246.154.123 IP comes from a stale kubeconfig located at ~/.kube/config whose cluster no longer exists. If I delete that kubeconfig, then try again, it now works:
$ rm ~/.kube/config
$ juju add-k8s --client k8s --skip-storage
k8s substrate added as cloud "k8s" with no configured storage provisioning capability.
You can now bootstrap to this cloud by running 'juju bootstrap k8s'.
$ juju version
3.1.2-genericli
$ snap list juju
Name Version Rev Tracking Publisher Notes
juju 3.1.2 22722 3.1/stable canonical✓ -
Changed in juju: | |
assignee: | nobody → Harry Pidcock (hpidcock) |
status: | New → Triaged |
Command output with --debug:
$ juju add-k8s --client k8s --skip-storage --debug 51beece481aa744 1ce3388519 gc go1.20.2] "/snap/ juju/22722/ bin/juju" , "add-k8s", "--client", "k8s", "--skip-storage", "--debug"} 22722/bin/ juju 71643520b933824 ff15dc9c5ed0f1f f42cbbcf3199099 55d0 .provider detectcloud.go:33 failed to query local microk8s: "/var/snap/ juju/22722/ microk8s/ credentials/ client. config" does not exist: juju "3.1.2" can only work with strictly confined microk8s l-9eef92ca" in namespace "kube-system": Get "https:/ /10.246. 154.123: 6443/apis/ rbac.authorizat ion.k8s. io/v1/clusterro les/juju- credential- 9eef92ca": dial tcp 10.246. 154.123: 6443: connect: connection refused /10.246. 154.123: 6443/apis/ rbac.authorizat ion.k8s. io/v1/clusterro les/juju- credential- 9eef92ca": dial tcp 10.246. 154.123: 6443: connect: connection refused com/juju/ juju/caas/ kubernetes/ clientconfig. getOrCreateClus terRole: 167: com/juju/ juju/caas/ kubernetes/ clientconfig. ensureJujuAdmin ServiceAccount: 88: ensuring cluster role "juju-credentia l-9eef92ca" in namespace "kube-system" com/juju/ juju/cmd/ juju/caas. (*AddCAASComman d).Run: 503: making juju admin credentials in cluster
16:13:38 INFO juju.cmd supercommand.go:56 running juju [3.1.2 f43d417390caeba
16:13:38 DEBUG juju.cmd supercommand.go:57 args: []string{
16:13:38 DEBUG juju.environs.tools build.go:122 looking for: /snap/juju/
16:13:38 DEBUG juju.environs.tools versionfile.go:54 looking for sha256 f5f009bdc970444
16:13:38 DEBUG juju.kubernetes
ERROR making juju admin credentials in cluster: ensuring cluster role "juju-credentia
16:13:38 DEBUG cmd supercommand.go:548 error stack:
Get "https:/
github.
github.
github.