cluster-api: clusterctl inside cluster in pod cannot find management cluster
What steps did you take and what happened: [A clear and concise description on how to REPRODUCE the bug.]
- Deploy Pod in cluster
- Install vsphere provider
- Generate configuration
clusterctl generate cluster $(TEST_CLUSTER_NAME)
–infrastructure vsphere
-n $(TEST_CLUSTER_NAME)
–control-plane-machine-count 1
–worker-machine-count 0 > /tmp/vsphere-test-cluster.yaml
Error: management cluster not available. Cannot auto-discover target namespace. Please specify a target namespace: invalid kubeconfig file; clusterctl requires a valid kubeconfig file to connect to the management cluster: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
What did you expect to happen:
It is supposed to find the local capi installation
Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]
Environment:
- Cluster-api version: v1.1.2
- Minikube/KIND version:
- Kubernetes version: (use
kubectl version): v1.21.8 - OS (e.g. from
/etc/os-release):
runner@mvm-runner-2:~$ cat /etc/os-release NAME=“Ubuntu” VERSION=“20.04.3 LTS (Focal Fossa)” ID=ubuntu ID_LIKE=debian PRETTY_NAME=“Ubuntu 20.04.3 LTS” VERSION_ID=“20.04” HOME_URL=“https://www.ubuntu.com/” SUPPORT_URL=“https://help.ubuntu.com/” BUG_REPORT_URL=“https://bugs.launchpad.net/ubuntu/” PRIVACY_POLICY_URL=“https://www.ubuntu.com/legal/terms-and-policies/privacy-policy” VERSION_CODENAME=focal UBUNTU_CODENAME=focal
/kind bug [One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels]
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 25 (21 by maintainers)
Sounds good. I’ll take a look at kubectl’s implementation when I get the chance and follow up here.
Our organization is looking to create vclusters in our CI/CD pipeline, which runs jobs as Kubernetes pods, and clusterctl not being able to detect it’s running in a pod like kubectl is somewhat blocking us from doing so (we can use vcluster directly)
I’ll take a look at this and see what’s possible (looking at the code it’s not as trivial as I thought 😆
/assign
As for kubectl, I tried running it on a pod but it seems like it doesn’t work out of the box.
It seems like we need to set up permissions for it to work, and as a result I’m not too clear on how find the relevant code in their repo.
We’re also in need of this issue. We want to use
clusterctl backupin a CronJob in the management cluster. As @sbueringer mentioned I’d expect this to work like most other k8s clients using https://github.com/kubernetes/client-go/blob/master/rest/config.go#L512 that works out the box if it’s running inside the cluster.