Error: no configuration has been provided, try setting KUBERNETES_MASTER environment

Hi,
I am able to create pods in master node

however if I ssh to one of the cluster node(node03), I cant create/fetch Pod info.

Probably due to missing configuration context.

Any suggestions? Can I copy the config-context of master(where its working) to this node ?

node03 kubectl version --client Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"} **node03 kubectl get pods**
error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
node03 $ echo $KUBECONFIG

node03 $ exit

Hi @debu3645,

Kindly provide me with the Lab link so can I help you properly

Hi @KodeKloud

I was trying this lab test of CKA: https://kodekloud.com/courses/539883/lectures/9816785

Appreciate if you could share details on how to resolve such issues as I have come across similar issues elsewhere as well.

Thanks

@KodeKloud

I think (not sure though) what the issue may be.

I was trying to run Kubectl and create a Pod directly at the worker node (i.e. node03) which, I think is not allowed. Only master node is allowed to execute Kubectl command.

If the above assumption is correct - can you guide how to solve this question?

Can I create a Pod from master node with (nodeName: node03 or with a nodeaffinity for node03) and then open the Pod(describe Pod) and check the IP address of the Pod?

But by checking the IP address of Pod, can I know the IP range of node03? I dont think so. Please suggest.

Hello, @debu3645
Have you tried nodeName or nodeSelector? After specifying one of the field. You can schedule your pod on the desire nodes.
nodeName
nodeSelector
Hope it will help you.

Hi @player001
Yes, I have tried with nodeName and nodeSelector to place the pod on a specific node.
However here my intention was to check the IP range (that each node can use to assign IP to pods) of each node.

You can do kubeadm config view where you can see the pod cidr.

I think you aware of this one too.
kubectl get pods -o wide --> To view the Pod IP’s and additional information.

Thanks. Can I see the IP range of the worker nodes for assigning IPs to pods?

e.g.
worker1 can assign ip range of 10.32.0.0 - 10.32.1.255 to Pods created in that node,
worker2 can assign ip range of 10.32.2.0 - 10.32.3.255.

This process only done in the master node.