Cannot add local k8s as cloud in juju

Hi There,

I have a three node cluster k8s which has been setup via kubeadm, I just heard about juju recently and I’m completely new. what I want is that to register my local k8s into my local juju node but as long as I go for registration I come across the following error.

nasri@juju:~$ add-k8s kubeadm-cluster --storage=openebs-hostpath

here I can see juju is trying to connect to 10.96.39.217 where as it is a clusterIP thus it is private and inaccessible from my machine, but why?
after a period it ends up with the error that cannot access to the k8s.

nasri@juju:~$ juju bootstrap kubeadm-cluster
Creating Juju controller “kubeadm-cluster” on kubeadm-cluster
Fetching Juju Dashboard 0.3.0
Creating k8s resources for controller “controller-kubeadm-cluster”
Starting controller pod
Bootstrap agent now started
Contacting Juju controller at 10.96.39.217 to verify accessibility…
ERROR unable to contact api server after 1 attempts: dial tcp 10.96.39.217:17070: i/o timeout

Hello! Thank you for the question.

Juju is looking up the ip address of the kubernetes cluster in ~/.kube/config. It’s being told to talk to 10.96.39.217, but can’t route to that address.

I’m not super familiar w/ kubeadm, but it sounds like you need to configure things so that the machine running your Juju client can talk to your cluster, either by calling out a different ip in your kubernetes configuration, or by running the juju client from a machine that has access to that address.

@pengale , Thank you for the reply but the ip address is pointed to the kubemaster - controlplane in the /.kube/config file as thus it could connect to the cluster and I can see it was able to create necessary pods and services but it had chosen a wrong ip address.

I believe this is a minor bug in selecting proper IP address, instead of connecting to NodePort, juju tries to connect to ClusterIP which is wrong approach.

if you look at these sentences you’d confirm my idea.
it was able to create controller but was not able to connect to it.

Creating k8s resources for controller “controller-kubeadm-cluster”
Starting controller pod
Bootstrap agent now started

We’ve opened a launchpad bug to track this and what looks like some related issues: Bug #1905320 “Juju bootstrap failing with various Kubernetes” : Bugs : juju

@wallyworld do we have an override that folks can drop in for a caas controller ip? Or does this require a code change in the way that juju reads the ~/.kube/config?

Edit: we do have flags to pass. Please see the bug linked above for details.

To confirm, as per the comments on bug https://bugs.launchpad.net/bugs/1905320 and the discourse posts:

https://discourse.charmhub.io/t/juju-add-k8s-in-openstack-no-route-to-controller
https://discourse.charmhub.io/t/new-features-and-changes-in-juju-2-7

There’s bootstrap options to set up the controller service as needed to allow ingress.
The official Juju-k8s doc is a little behind where it needs to be unfortunately.

With the CA cert issue, that’s now being worked on and a fix will hopefully land soon.